CI: GitHub MacOS runners lost ghcup since 2024-04-27, so use haskell-action/setup...
[cabal.git] / .github / workflows / bootstrap.yml
blob569704482390c5c4e603d233a7bdfeb22f971f90
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     branches:
18       - master
19   pull_request:
20     paths-ignore:
21       - 'doc/**'
22       - '**/README.md'
23       - 'CONTRIBUTING.md'
24   release:
25     types:
26       - created
28 jobs:
29   bootstrap:
30     strategy:
31       matrix:
32         os: [ubuntu-latest]
33         ghc: ["8.10.7", "9.0.2", "9.2.8", "9.4.8", "9.6.4", "9.8.2"]
34         include:
35           - os: macos-latest
36             ghc: "9.2.8"
37     name: Bootstrap ${{ matrix.os }} ghc-${{ matrix.ghc }}
38     runs-on: ${{ matrix.os }}
39     steps:
40       - name: Work around XDG directories existence (haskell-actions/setup#62)
41         if: ${{ runner.os == 'macOS' }}
42         run: |
43           rm -rf ~/.config/cabal
44           rm -rf ~/.cache/cabal
46       - uses: actions/cache@v3
47         name: Cache the downloads
48         id: bootstrap-cache
49         with:
50           path: "/home/runner/work/cabal/cabal/_build"
51           key: bootstrap-${{ runner.os }}-${{ matrix.ghc }}-20221115-${{ github.sha }}
52           restore-keys: bootstrap-${{ runner.os }}-${{ matrix.ghc }}-20221115-
54       - uses: actions/checkout@v4
55       - uses: haskell-actions/setup@v2
56         with:
57           ghc-version: ${{ matrix.ghc }}
59       - name: bootstrap.py
60         run: |
61           GHC_VERSION=${{ matrix.ghc }}
62           # Fetch the bootstrap sources (we use linux dependencies also on macos)
63           python3 bootstrap/bootstrap.py -d bootstrap/linux-$GHC_VERSION.json fetch
65           # Bootstrap using the bootstrap sources
66           python3 bootstrap/bootstrap.py --bootstrap-sources bootstrap-sources.tar.gz
68       - name: Smoke test
69         run: |
70           _build/bin/cabal --version
72       - uses: actions/upload-artifact@v3
73         with:
74           name: cabal-${{ matrix.os }}-${{ matrix.ghc }}-bootstrapped
75           path: _build/artifacts/*
77   # We use this job as a summary of the workflow
78   # It will fail if any of the previous jobs does it
79   # This way we can use it exclusively in branch protection rules
80   # and abstract away the concrete jobs of the workflow, including their names
81   bootstrap-post-job:
82     if: always()
83     name: Bootstrap post job
84     runs-on: ubuntu-latest
85     # IMPORTANT! Any job added to the workflow should be added here too
86     needs: [bootstrap]
88     steps:
89       - run: |
90           echo "jobs info: ${{ toJSON(needs) }}"
91       - if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
92         run: exit 1