CI: GitHub MacOS runners lost ghcup since 2024-04-27, so use haskell-action/setup...
[cabal.git] / .github / workflows / quick-jobs.yml
blob0759f91163134c7660988a2dc8a6107fa97fdb9f
1 name: Quick jobs
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     branches:
11       - master
12   pull_request:
13   release:
14     types:
15       - created
17 jobs:
18   meta:
19     name: Meta checks
20     runs-on: ubuntu-latest
21     env:
22       cabal_build: >-
23         cabal build --builddir=dist-newstyle-meta --project-file=cabal.project.meta
24         gen-cabal-macros
25         gen-paths-module
26         gen-spdx
27         gen-spdx-exc
28     # This job is not run in a container, any recent GHC should be fine
29     steps:
30       # SKIP installation of ghc and cabal and use the preinstalled versions.
31       # - name: ghcup
32       #   run: |
33       #     ghcup --version
34       #     ghcup config set cache true
35       #     ghcup install ghc recommended
36       #     ghcup set ghc recommended
37       - name: Haskell versions
38         run: |
39           ghc --version
40           cabal --version
41       - name: Update Hackage index
42         run: cabal v2-update
43       - uses: actions/checkout@v4
44       - name: Generate build plan for correct cache key
45         run: ${{ env.cabal_build }} --dry-run
46       - name: Restore cached dependencies
47         uses: actions/cache/restore@v4
48         id: cache
49         with:
50           path: ~/.local/state/cabal
51           key: linux-store-meta-${{ hashfiles('dist-newstyle-meta/cache/plan.json') }}
52           restore-keys: linux-store-meta-
53       - name: Build tools
54         run: ${{ env.cabal_build }}
55       - name: Regenerate files
56         run: |
57           make -B spdx
58           make -B templates
59       - name: Check that diff is clean
60         run: |
61           git status > /dev/null
62           git diff-files -p --exit-code
63       - name: Cache dependencies
64         uses: actions/cache/save@v4
65         if: always() && steps.cache.outputs.cache-hit != 'true'
66         with:
67           path: ~/.local/state/cabal
68           key: ${{ steps.cache.outputs.cache-primary-key }}
70   doctest:
71     name: Doctest Cabal
72     runs-on: ubuntu-latest
73     steps:
74       # It is complicated to get a proper cache key for the dependencies of a package
75       # (here: doctest) that we just `cabal install`.
76       # So, as a heuristics we update the cache once per day.
77       # Updating it with each run would be an alternative, but we a short of cache space,
78       # and this would generate too many new caches.
79       - name: Use date as cache key
80         run: |
81           echo "DATE=$(date +'%Y-%m-%d')" >> "${GITHUB_ENV}"
82       - name: Restore cached dependencies
83         uses: actions/cache/restore@v4
84         id: cache
85         with:
86           path: ~/.local/state/cabal
87           key: linux-store-doctest-${{ env.DATE }}
88           restore-keys: linux-store-doctest
89       - name: Update Hackage index
90         run: cabal v2-update
91       - uses: actions/checkout@v4
92       - name: Install doctest
93         run: make doctest-install
94       - name: Doctest
95         run: make doctest
96       - name: Cache dependencies
97         if: always() && steps.cache.outputs.cache-hit != 'true'
98         uses: actions/cache/save@v4
99         with:
100           path: ~/.local/state/cabal
101           key: ${{ steps.cache.outputs.cache-primary-key }}
103   buildinfo:
104     name: Check Field Syntax Reference
105     runs-on: ubuntu-latest
106     env:
107       cabal_build: cabal build buildinfo-reference-generator
108     steps:
109       - name: Update Hackage index
110         run: cabal v2-update
111       - uses: actions/checkout@v4
112       - name: Generate build plan for correct cache key
113         run: ${{ env.cabal_build }} --dry-run
114       - name: Restore cached dependencies
115         uses: actions/cache/restore@v4
116         id: cache
117         with:
118           path: ~/.local/state/cabal
119           key: linux-store-buildinfo-doc-diff-${{ hashfiles('dist-newstyle/cache/plan.json') }}
120           restore-keys: linux-store-buildinfo-doc-diff
121       - name: Build buildinfo-reference-generator
122         run: ${{ env.cabal_build }}
123       - name: Are buildinfo docs up to date?
124         run: make doc/buildinfo-fields-reference.rst
125       - name: Cache dependencies
126         uses: actions/cache/save@v4
127         if: always() && steps.cache.outputs.cache-hit != 'true'
128         with:
129           path: ~/.local/state/cabal
130           key: ${{ steps.cache.outputs.cache-primary-key }}
132   release-project:
133     name: Check Release Project
134     runs-on: ubuntu-latest
135     steps:
136       - name: Update Hackage Index
137         run: cabal v2-update
138       - uses: actions/checkout@v4
139       - name: Check Release with Pinned Hackage
140         run: cabal build all --dry-run --project-file=cabal.project.release
141       - name: Check Release with Latest Hackage
142         run: cabal build all --dry-run --project-file=cabal.project.release --index-state="hackage.haskell.org HEAD"