3 # We use bash as default even in windows
4 # to try keep the workflow as uniform as possible
9 # See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency.
11 group: ${{ github.ref }}-${{ github.workflow }}
12 cancel-in-progress: true
24 # We choose a stable ghc version across all os's
25 # which will be used to do the next release
26 GHC_FOR_RELEASE: '9.2.7'
27 # Ideally we should use the version about to be released for hackage tests and benchmarks
28 GHC_FOR_SOLVER_BENCHMARKS: '9.2.7'
29 GHC_FOR_COMPLETE_HACKAGE_TESTS: '9.2.7'
30 COMMON_FLAGS: '-j 2 -v'
34 name: Validate ${{ matrix.os }} ghc-${{ matrix.ghc }}
35 runs-on: ${{ matrix.os }}
37 GHC_FOR_RELEASE: ${{ format('["{0}"]', env.GHC_FOR_RELEASE) }}
40 os: ["ubuntu-20.04", "macos-latest", "windows-latest"]
41 ghc: ["9.6.1", "9.4.4", "9.2.7", "9.0.2", "8.10.7", "8.8.4", "8.6.5", "8.4.4"]
43 # corrupts GHA cache or the fabric of reality itself, see https://github.com/haskell/cabal/issues/8356
44 - os: "windows-latest"
46 # lot of segfaults caused by ghc bugs
47 - os: "windows-latest"
49 # it also throws segfaults randomly
50 - os: "windows-latest"
52 # it often randomly does "C:\Users\RUNNER~1\AppData\Local\Temp\ghcFEDE.c: DeleteFile "\\\\?\\C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\ghcFEDE.c": permission denied (Access is denied.)"
53 - os: "windows-latest"
58 - uses: actions/checkout@v3
60 # See the following link for a breakdown of the following step
61 # https://github.com/haskell/actions/issues/7#issuecomment-745697160
62 - uses: actions/cache@v3
64 # validate.sh uses a special build dir
66 ${{ steps.setup-haskell.outputs.cabal-store }}
68 key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}
69 restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
71 - uses: haskell/actions/setup@v2
74 ghc-version: ${{ matrix.ghc }}
75 cabal-version: '3.10.1.0'
77 - name: Work around git problem https://bugs.launchpad.net/ubuntu/+source/git/+bug/1993586 (cabal PR #8546)
79 git config --global protocol.file.allow always
81 # The '+exe' constraint below is important, otherwise cabal-install
82 # might decide to build the library but not the executable which is
84 - name: Install cabal-plan
87 cabal install cabal-plan --allow-newer="base" --constraint='cabal-plan +exe'
88 echo "$HOME/.cabal/bin:$HOME/.local/bin" >> $GITHUB_PATH
90 # The tool is not essential to the rest of the test suite. If
91 # hackage-repo-tool is not present, any test that requires it will
93 # We want to keep this in the loop but we don't want to fail if
94 # hackage-repo-tool breaks or fails to support a newer GHC version.
95 - name: Install hackage-repo-tool
96 continue-on-error: true
99 cabal install hackage-repo-tool
101 # Needed by cabal-testsuite/PackageTests/Configure/setup.test.hs
102 - name: Install Autotools
103 if: runner.os == 'macOS'
105 brew install automake
107 - name: Set validate inputs
109 FLAGS="${{ env.COMMON_FLAGS }}"
110 if [[ "${{ matrix.cli }}" == "false" ]]; then
111 FLAGS="$FLAGS --lib-only"
113 if [[ ${{ matrix.ghc }} == ${{ env.GHC_FOR_SOLVER_BENCHMARKS }} ]]; then
114 FLAGS="$FLAGS --solver-benchmarks"
116 if [[ ${{ matrix.ghc }} == ${{ env.GHC_FOR_COMPLETE_HACKAGE_TESTS }} ]]; then
117 FLAGS="$FLAGS --complete-hackage-tests"
119 echo "FLAGS=$FLAGS" >> $GITHUB_ENV
121 - name: Allow newer dependencies when built with latest GHC
122 if: ${{ matrix.ghc }} == '9.6.1'
124 echo "allow-newer: rere:base, rere:transformers" >> cabal.project.validate
126 - name: Validate print-config
127 run: sh validate.sh $FLAGS -s print-config
129 - name: Validate print-tool-versions
130 run: sh validate.sh $FLAGS -s print-tool-versions
132 - name: Validate build
133 run: sh validate.sh $FLAGS -s build
135 - name: Tar cabal head executable
136 if: matrix.cli != 'false' && matrix.ghc == env.GHC_FOR_RELEASE
138 CABAL_EXEC=$(cabal-plan list-bin --builddir=dist-newstyle-validate-ghc-${{ matrix.ghc }} cabal-install:exe:cabal)
139 # We have to tar the executable to preserve executable permissions
140 # see https://github.com/actions/upload-artifact/issues/38
141 if [[ ${{ runner.os }} == 'Windows' ]]; then
142 # `cabal-plan` gives us a windows path but tar needs the posix one
143 CABAL_EXEC=$(cygpath $CABAL_EXEC)
145 if [[ "${{ runner.os }}" == "macOS" ]]; then
146 # Workaround to avoid bsdtar corrupts the executable
147 # so executing it after untar throws `cannot execute binary file`
148 # see https://github.com/actions/virtual-environments/issues/2619#issuecomment-788397841
151 tar -cvf cabal-head.tar -C $(dirname "$CABAL_EXEC") $(basename "$CABAL_EXEC")
152 echo "CABAL_EXEC_TAR=cabal-head.tar" >> $GITHUB_ENV
154 # We upload the cabal executable built with the ghc used in the release for:
155 # - Reuse it in the dogfooding job (although we could use the cached build dir)
156 # - Make it available in the workflow to make easier testing it locally
157 - name: Upload cabal-install executable to workflow artifacts
158 if: matrix.cli != 'false' && matrix.ghc == env.GHC_FOR_RELEASE
159 uses: actions/upload-artifact@v3
161 name: cabal-${{ runner.os }}-${{ matrix.ghc }}
162 path: ${{ env.CABAL_EXEC_TAR }}
164 - name: Validate lib-tests
166 # `rawSystemStdInOut reports text decoding errors`
167 # test does not find ghc without the full path in windows
168 GHCPATH: ${{ steps.setup-haskell.outputs.ghc-exe }}
169 run: sh validate.sh $FLAGS -s lib-tests
171 - name: Validate lib-suite
172 # Have to disable *-suite validation:
173 # - the Windows@9.6.1 problem is tracked at https://github.com/haskell/cabal/issues/8858
174 # - but curently can't run it with GHC 9.6, tracking: https://github.com/haskell/cabal/issues/8883
175 if: (runner.os != 'Windows') || (matrix.ghc != '9.6.1')
176 run: sh validate.sh $FLAGS -s lib-suite
178 - name: Validate cli-tests
179 if: matrix.cli != 'false'
180 run: sh validate.sh $FLAGS -s cli-tests
182 - name: Validate cli-suite
183 # Have to disable *-suite validation, see above the comment for lib-suite
184 if: ((runner.os != 'Windows') || (matrix.ghc != '9.6.1')) && (matrix.cli != 'false')
185 run: sh validate.sh $FLAGS -s cli-suite
188 name: Validate old ghcs ${{ matrix.extra-ghc }}
189 runs-on: ubuntu-20.04
191 # This job needs an older ubuntu (16.04) cause
192 # the required old ghcs using the `-dyn` flavour
193 # are not installable from ppa/hvr in newer ones
194 # see https://github.com/haskell/cabal/issues/8011
196 image: phadej/ghc:8.8.4-xenial
200 # Newer ghc versions than 8.8.4 have to be installed with ghcup cause
201 # they are not available in ppa/hvr. The ghcup installation
202 # needs `sudo` which is not available in the xenial container
204 extra-ghc: ["7.10.3", "7.8.4", "7.6.3", "7.4.2", "7.2.2", "7.0.4"]
208 # We can't use actions/checkout with the xenial docker container
209 # cause it does not work with the git version included in it, see:
210 # https://github.com/actions/checkout/issues/170
211 # https://github.com/actions/checkout/issues/295
212 # - uses: actions/checkout@v3
215 echo $GITHUB_REF $GITHUB_SHA
216 git clone --depth 1 https://github.com/$GITHUB_REPOSITORY.git .
217 git fetch origin $GITHUB_SHA:temporary-ci-branch
218 git checkout $GITHUB_SHA || (git fetch && git checkout $GITHUB_SHA)
220 - name: Install extra compiler
223 apt-get install -y ghc-${{ matrix.extra-ghc }}-dyn
225 - uses: haskell/actions/setup@v2
228 ghc-version: ${{ matrix.ghc }}
229 cabal-version: latest # latest is mandatory for cabal-testsuite, see https://github.com/haskell/cabal/issues/8133
231 # As we are reusing the cached build dir from the previous step
232 # the generated artifacts are available here,
233 # including the cabal executable and the test suite
234 - uses: actions/cache@v3
237 ${{ steps.setup-haskell.outputs.cabal-store }}
239 key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}
240 restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
242 - name: Install cabal-plan
245 cabal install cabal-plan --allow-newer="base" --constraint='cabal-plan +exe'
246 echo "$HOME/.cabal/bin:$HOME/.local/bin" >> $GITHUB_PATH
248 - name: Validate build
249 run: sh validate.sh ${{ env.COMMON_FLAGS }} -s build
251 - name: "Validate lib-suite-extras --extra-hc ghc-${{ matrix.extra-ghc }}"
253 EXTRA_GHC: "/opt/ghc/${{ matrix.extra-ghc }}/bin/ghc-${{ matrix.extra-ghc }}"
254 run: sh validate.sh ${{ env.COMMON_FLAGS }} --lib-only -s lib-suite-extras --extra-hc ${{ env.EXTRA_GHC }}
256 # The previous jobs use a released version of cabal to build cabal HEAD itself
257 # This one uses the cabal HEAD generated executable in the previous step
258 # to build itself again, as sanity check
260 name: Dogfooding ${{ matrix.os }} ghc-${{ matrix.ghc }}
261 runs-on: ${{ matrix.os }}
265 os: ["ubuntu-20.04", "macos-latest", "windows-latest"]
266 # We only use one ghc version the used one for the next release (defined at top of the workflow)
267 # We need to build an array dynamically to inject the appropiate env var in a previous job,
268 # see https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson
269 ghc: ${{ fromJSON (needs.validate.outputs.GHC_FOR_RELEASE) }}
272 - uses: actions/checkout@v3
274 # See https://github.com/haskell/cabal/pull/8739
275 - name: Sudo chmod to permit ghcup to update its cache
277 if [[ "${{ runner.os }}" == "Linux" ]]; then
278 sudo ls -lah /usr/local/.ghcup/cache
279 sudo mkdir -p /usr/local/.ghcup/cache
280 sudo ls -lah /usr/local/.ghcup/cache
281 sudo chown -R $USER /usr/local/.ghcup
282 sudo chmod -R 777 /usr/local/.ghcup
284 - uses: haskell/actions/setup@v2
287 ghc-version: ${{ matrix.ghc }}
288 cabal-version: latest # default, we are not using it in this job
290 - name: Install cabal-plan
293 cabal install cabal-plan --allow-newer="base" --constraint='cabal-plan +exe'
294 echo "$HOME/.cabal/bin:$HOME/.local/bin" >> $GITHUB_PATH
296 - name: Download cabal executable from workflow artifacts
297 uses: actions/download-artifact@v3
299 name: cabal-${{ runner.os }}-${{ matrix.ghc }}
302 - name: Untar the cabal executable
303 run: tar -xf ./cabal-head/cabal-head.tar -C ./cabal-head
305 - name: print-config using cabal HEAD
306 run: sh validate.sh ${{ env.COMMON_FLAGS }} --with-cabal ./cabal-head/cabal -s print-config
308 # We dont use cache to force a build with a fresh store dir and build dir
309 # This way we check cabal can build all its dependencies
310 - name: Build using cabal HEAD
311 run: sh validate.sh ${{ env.COMMON_FLAGS }} --with-cabal ./cabal-head/cabal -s build
313 # We use this job as a summary of the workflow
314 # It will fail if any of the previous jobs does it
315 # This way we can use it exclusively in branch protection rules
316 # and abstract away the concrete jobs of the workflow, including their names
319 name: Validate post job
320 runs-on: ubuntu-20.04
321 # IMPORTANT! Any job added to the workflow should be added here too
322 needs: [validate, validate-old-ghcs, dogfooding]
326 echo "jobs info: ${{ toJSON(needs) }}"
327 - if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')