Merge pull request #10525 from 9999years/field-stanza-names
[cabal.git] / .github / workflows / check-sdist.yml
blob9813d3931e0a7e1ffc205d038e8095a2e9b1be09
1 name: Check sdist
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 on:
9   push:
10     paths-ignore:
11       - "doc/**"
12       - "**/README.md"
13       - "CONTRIBUTING.md"
14       - "changelog.d/**"
15       # only top level for these, because various test packages have them too
16       - "*/ChangeLog.md"
17       - "*/changelog.md"
18       - "release-notes/**"
19     branches:
20       - master
21   pull_request:
22     paths-ignore:
23       - "doc/**"
24       - "**/README.md"
25       - "CONTRIBUTING.md"
26       - "changelog.d/**"
27       - "*/ChangeLog.md"
28       - "*/changelog.md"
29       - "release-notes/**"
30   release:
31     types:
32       - created
34 jobs:
36   # Dogfood the generated sdist, to avoid bugs like https://github.com/haskell/cabal/issues/9833
37   # No caching, since the point is to verify they can be installed "from scratch"
38   # Don't run on master or a PR targeting master, because there's never an installable Cabal
39   dogfood-sdists:
40     name: Dogfood sdist on ghc-${{ matrix.ghc }}
41     if: github.ref != 'refs/heads/master' && github.base_ref != 'master'
42     runs-on: ubuntu-latest
43     strategy:
44       matrix:
45         # this should be kept up to date with the list in validate.yml, but should be the
46         # *first* compiler release so we validate against what is hopefully the first
47         # release of a corresponding Cabal and friends. it can also be short since it's
48         # highly unlikely that we are releasing really old branches.
49         ghc:
50           ["9.10.1", "9.8.1", "9.6.1"]
52     steps:
54       - uses: haskell-actions/setup@v2
55         id: setup-haskell
56         with:
57           ghc-version: ${{ matrix.ghc }}
58           cabal-version: latest
60       - uses: actions/checkout@v4
62       - name: Make sdist
63         run: cabal sdist cabal-install
65       - name: Install from sdist
66         run: |
67           # skip if a suitable Cabal isn't in this ghc's bootlibs, since that's the case
68           # that causes failures for users (otherwise cabal-install will install a matching
69           # version itself)
70           # we only want to test cabal-install, to ensure that it works with existing Cabals
71           # (don't look at this too closely)
72           sdist="$(ls dist-newstyle/sdist/cabal-install-*.tar.gz | sed -n '\,^dist-newstyle/sdist/cabal-install-[0-9.]*\.tar\.gz$,{;p;q;}')"
73           # extract the cabal-install major version
74           ver="$(echo "$sdist" | sed -n 's,^dist-newstyle/sdist/cabal-install-\([0-9][0-9]*\.[0-9][0-9]*\)\.[0-9.]*$,\1,p')"
75           # dunno if this will ever be extended to freebsd, but grep -q is a gnu-ism
76           if ghc-pkg --global --simple-output list Cabal | grep "^Cabal-$cbl\\." >/dev/null; then
77             # sigh, someone broke installing from tarballs
78             rm -rf cabal*.project Cabal Cabal-syntax cabal-install-solver cabal-install
79             tar xfz "$sdist"
80             cd "cabal-install-$cbl"*
81             cabal install
82           else
83             echo No matching bootlib Cabal version to test against.
84             exit 0
85           fi
87   check-sdist-post-job:
88     if: always()
89     name: Check sdist post job
90     runs-on: ubuntu-latest
91     # IMPORTANT! Any job added to the workflow should be added here too
92     needs: [dogfood-sdists]
94     steps:
95       - run: |
96           echo "jobs info: ${{ toJSON(needs) }}"
97       - if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
98         run: exit 1