Merge pull request #10525 from 9999years/field-stanza-names
[cabal.git] / .github / workflows / bootstrap.yml
blobd85b2ae4f12a5491deef201534342087c7ce5929
1 name: Bootstrap
3 # See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency.
4 concurrency:
5   group: ${{ github.ref }}-${{ github.workflow }}
6   cancel-in-progress: true
8 # Note: This workflow file contains the required job "Bootstrap post job". We are using path filtering
9 # here to ignore PRs which only change documentation. This can cause a problem, see the workflow file
10 # "bootstrap.skip.yml" for a description of the problem and the solution provided in that file.
11 on:
12   push:
13     paths-ignore:
14       - 'doc/**'
15       - '**/README.md'
16       - 'CONTRIBUTING.md'
17       - "changelog.d/**"
18       # only top level for these, because various test packages have them too
19       - "*/ChangeLog.md"
20       - "*/changelog.md"
21       - "release-notes/**"
22     branches:
23       - master
24   pull_request:
25     paths-ignore:
26       - 'doc/**'
27       - '**/README.md'
28       - 'CONTRIBUTING.md'
29       - "changelog.d/**"
30       - "*/ChangeLog.md"
31       - "*/changelog.md"
32       - "release-notes/**"
33   release:
34     types:
35       - created
37 jobs:
38   bootstrap:
39     strategy:
40       matrix:
41         os: [ubuntu-latest]
42         ghc: ["9.0.2", "9.2.8", "9.4.8", "9.6.6", "9.8.2"]
43         include:
44           - os: macos-latest
45             ghc: "9.2.8"
46     name: Bootstrap ${{ matrix.os }} ghc-${{ matrix.ghc }}
47     runs-on: ${{ matrix.os }}
48     steps:
49       - name: Work around XDG directories existence (haskell-actions/setup#62)
50         if: ${{ runner.os == 'macOS' }}
51         run: |
52           rm -rf ~/.config/cabal
53           rm -rf ~/.cache/cabal
55       - uses: actions/cache@v4
56         name: Cache the downloads
57         id: bootstrap-cache
58         with:
59           path: "/home/runner/work/cabal/cabal/_build"
60           key: bootstrap-${{ runner.os }}-${{ matrix.ghc }}-20221115-${{ github.sha }}
61           restore-keys: bootstrap-${{ runner.os }}-${{ matrix.ghc }}-20221115-
63       - uses: actions/checkout@v4
64       - uses: haskell-actions/setup@v2
65         with:
66           ghc-version: ${{ matrix.ghc }}
68       - name: bootstrap.py
69         run: |
70           GHC_VERSION=${{ matrix.ghc }}
71           # Fetch the bootstrap sources (we use linux dependencies also on macos)
72           python3 bootstrap/bootstrap.py -d bootstrap/linux-$GHC_VERSION.json fetch
74           # Bootstrap using the bootstrap sources
75           python3 bootstrap/bootstrap.py --bootstrap-sources bootstrap-sources.tar.gz
77       - name: Smoke test
78         run: |
79           _build/bin/cabal --version
81       - uses: actions/upload-artifact@v4
82         with:
83           name: cabal-${{ matrix.os }}-${{ matrix.ghc }}-bootstrapped
84           path: _build/artifacts/*
86   # We use this job as a summary of the workflow
87   # It will fail if any of the previous jobs does it
88   # This way we can use it exclusively in branch protection rules
89   # and abstract away the concrete jobs of the workflow, including their names
90   bootstrap-post-job:
91     if: always()
92     name: Bootstrap post job
93     runs-on: ubuntu-latest
94     # IMPORTANT! Any job added to the workflow should be added here too
95     needs: [bootstrap]
97     steps:
98       - run: |
99           echo "jobs info: ${{ toJSON(needs) }}"
100       - if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
101         run: exit 1