Skip to content

Commit 501bde6

Browse files
committed
attempt to use local actions
Extremely experimental, and with all the limitations and restrictions I keep finding in GitHub Actions it'll probably fail in the messiest way it can. At present this is incomplete but sufficient to see if this has any chance of working to begin with. If it somehow does, I'll look into abstracting out the other sub-jobs, then making an overnight validate for Tier 2 platforms and probably a prerelease job (which would fix the recently revealed problem where if there is no need to rebase on merge, no prerelease is made).
1 parent 9e2b2db commit 501bde6

File tree

4 files changed

+427
-268
lines changed

4 files changed

+427
-268
lines changed
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: Cabal setup
2+
description: Set up a workflow for Cabal
3+
4+
inputs:
5+
ghc:
6+
description: ghc version to use
7+
required: true
8+
extra-ghc:
9+
description: additional ghc for tests
10+
required: false
11+
default: ''
12+
allow-newer:
13+
description: allow-newer line
14+
required: false
15+
default: ''
16+
constraints:
17+
description: constraints line
18+
required: false
19+
default: ''
20+
static:
21+
description: whether to build statically
22+
required: false
23+
default: 'false'
24+
shell:
25+
description: shell to use
26+
required: false
27+
default: 'bash'
28+
with_cache:
29+
description: whether to instantiate cache
30+
required: false
31+
default: 'true'
32+
33+
outputs:
34+
ghc-exe:
35+
description: Path to ghc installed by setup-haskell
36+
value: ${{ steps.setup-haskell.outputs.ghc-exe }}
37+
38+
runs:
39+
using: composite
40+
steps:
41+
- name: Make sure ghc is specified
42+
if: inputs.ghc == ''
43+
shell: ${{ inputs.shell }}
44+
run: exit 1
45+
46+
- name: Work around existence of XDG directories (haskell-actions/setup#62)
47+
if: runner.os == 'macOS'
48+
shell: ${{ inputs.shell }}
49+
run: |
50+
rm -rf ~/.config/cabal
51+
rm -rf ~/.cache/cabal
52+
53+
- name: "WIN: Setup TMP environment variable"
54+
if: runner.os == 'Windows'
55+
shell: ${{ inputs.shell }}
56+
run: |
57+
echo "TMP=${{ runner.temp }}" >> "$GITHUB_ENV"
58+
59+
# See https://github.com/haskell/cabal/blob/master/CONTRIBUTING.md#hackage-revisions
60+
- name: Add manually supplied allow-newer
61+
if: inputs.allow-newer != ''
62+
shell: ${{ inputs.shell }}
63+
run: |
64+
echo "allow-newer: ${{ inputs.allow-newer }}" >> cabal.validate.project
65+
66+
- name: Add manually supplied constraints
67+
if: inputs.constraints != ''
68+
shell: ${{ inputs.shell }}
69+
run: |
70+
echo "constraints: ${{ inputs.constraints }}" >> cabal.validate.project
71+
72+
- name: Enable statically linked executables
73+
if: inputs.static == 'true'
74+
shell: ${{ inputs.shell }}
75+
run: |
76+
echo 'executable-static: true' >> cabal.validate.project
77+
78+
# must happen before the main setup so the correct ghc is default
79+
# hm, but what if setup-haskell needs to install ghcup?
80+
- name: Install extra ghc for tests
81+
if: inputs.extra_ghc != ''
82+
shell: ${{ inputs.shell }}
83+
run: |
84+
ghcup install ghc ${{ inputs.extra_ghc }}
85+
86+
- uses: haskell-actions/setup@v2
87+
id: setup-haskell
88+
with:
89+
ghc-version: ${{ inputs.ghc }}
90+
cabal-version: 3.12.1.0 # see https://github.com/haskell/cabal/pull/10251
91+
ghcup-release-channel: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml
92+
93+
# See the following link for a breakdown of the following step
94+
# https://github.com/haskell/actions/issues/7#issuecomment-745697160
95+
- uses: actions/cache@v4
96+
if: inputs.with_cache != 'false'
97+
with:
98+
# validate.sh uses a special build dir
99+
path: |
100+
${{ steps.setup-haskell.outputs.cabal-store }}
101+
dist-*
102+
key: ${{ runner.os }}-${{ inputs.ghc }}-${{ github.sha }}
103+
restore-keys: ${{ runner.os }}-${{ inputs.ghc }}-
104+
105+
# The tool is not essential to the rest of the test suite. If
106+
# hackage-repo-tool is not present, any test that requires it will
107+
# be skipped.
108+
# We want to keep this in the loop but we don't want to fail if
109+
# hackage-repo-tool breaks or fails to support a newer GHC version.
110+
- name: Install hackage-repo-tool
111+
continue-on-error: true
112+
shell: ${{ inputs.shell }}
113+
run: |
114+
cabal install --ignore-project hackage-repo-tool
115+
116+
# Needed by cabal-testsuite/PackageTests/Configure/setup.test.hs
117+
- name: "MAC: Install Autotools"
118+
if: runner.os == 'macOS'
119+
shell: ${{ inputs.shell }}
120+
run: |
121+
brew install automake
122+
123+
# Needed by cabal-testsuite/PackageTests/Configure/setup.test.hs
124+
- name: "WIN: Install Autotools"
125+
if: runner.os == 'Windows'
126+
shell: ${{ inputs.shell }}
127+
run: |
128+
/usr/bin/pacman --noconfirm -S autotools
129+
130+
- name: Set validate inputs
131+
shell: ${{ inputs.shell }}
132+
run: |
133+
FLAGS="$COMMON_FLAGS"
134+
if [[ "${{ inputs.ghc }}" == "$GHC_FOR_SOLVER_BENCHMARKS" ]]; then
135+
FLAGS="$FLAGS --solver-benchmarks"
136+
fi
137+
if [[ "${{ matrix.ghc }}" == "$GHC_FOR_COMPLETE_HACKAGE_TESTS" ]]; then
138+
FLAGS="$FLAGS --complete-hackage-tests"
139+
fi
140+
echo "FLAGS=$FLAGS" >> "$GITHUB_ENV"
141+
142+
- name: Validate print-config
143+
shell: ${{ inputs.shell }}
144+
run: |
145+
sh validate.sh $FLAGS -s print-config
146+
147+
- name: Validate print-tool-versions
148+
shell: ${{ inputs.shell }}
149+
run: |
150+
sh validate.sh $FLAGS -s print-tool-versions
151+
152+
- name: Canonicalize architecture
153+
shell: ${{ inputs.shell }}
154+
run: |
155+
case ${{ runner.arch }} in
156+
X86) arch=i386 ;;
157+
X64) arch=x86_64 ;;
158+
ARM64) arch=aarch64 ;;
159+
*) echo "Unsupported architecture, please fix validate.yaml" 2>/dev/null; exit 1 ;;
160+
esac
161+
echo "CABAL_ARCH=$arch" >> "$GITHUB_ENV"
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Validate full
2+
description: Run a full validate on a ghc version
3+
inputs:
4+
ghc:
5+
description: ghc version to use
6+
required: true
7+
allow-newer:
8+
description: allow-newer line
9+
required: false
10+
constraints:
11+
description: constraints line
12+
required: false
13+
static:
14+
description: whether to build statically
15+
required: false
16+
default: 'false'
17+
shell:
18+
description: shell to use
19+
required: false
20+
default: 'bash'
21+
with_cache:
22+
description: whether to instantiate cache
23+
required: false
24+
default: 'true'
25+
26+
runs:
27+
using: composite
28+
steps:
29+
- uses: ./.github/actions/cabal-setup
30+
id: cabal-setup
31+
with:
32+
shell: ${{ inputs.shell }}
33+
ghc: ${{ inputs.ghc }}
34+
allow-newer: ${{ inputs.allow-newer }}
35+
constraints: ${{ inputs.constraints }}
36+
static: ${{ inputs.static }}
37+
with_cache: ${{ inputs.with_cache }}
38+
39+
- name: Validate build
40+
shell: ${{ inputs.shell }}
41+
run: |
42+
echo ::group::Build
43+
sh validate.sh $FLAGS -s build
44+
45+
- name: Tar cabal head executable
46+
if: matrix.ghc == env.GHC_FOR_RELEASE
47+
shell: ${{ inputs.shell }}
48+
run: |
49+
echo ::group::Tar
50+
CABAL_EXEC=$(cabal list-bin --builddir=dist-newstyle-validate-ghc-${{ matrix.ghc }} --project-file=cabal.validate.project cabal-install:exe:cabal)
51+
# We have to tar the executable to preserve executable permissions
52+
# see https://github.com/actions/upload-artifact/issues/38
53+
if [[ "${{ runner.os }}" == "Windows" ]]; then
54+
# `cabal list-bin` gives us a windows path but tar needs the posix one
55+
CABAL_EXEC=$(cygpath "$CABAL_EXEC")
56+
fi
57+
if [[ "${{ runner.os }}" == "macOS" ]]; then
58+
# Workaround to avoid bsdtar corrupting the executable
59+
# such that executing it after untar throws `cannot execute binary file`
60+
# see https://github.com/actions/virtual-environments/issues/2619#issuecomment-788397841
61+
sudo /usr/sbin/purge
62+
fi
63+
DIR=$(dirname "$CABAL_EXEC")
64+
FILE=$(basename "$CABAL_EXEC")
65+
CABAL_EXEC_TAR="cabal-head-${{ runner.os }}-$CABAL_ARCH.tar.gz"
66+
tar -czvf "$CABAL_EXEC_TAR" -C "$DIR" "$FILE"
67+
echo "CABAL_EXEC_TAR=$CABAL_EXEC_TAR" >> "$GITHUB_ENV"
68+
69+
# We upload the cabal executable built with the ghc used in the release for:
70+
# - Reuse it in the dogfooding job (although we could use the cached build dir)
71+
# - Make it available in the workflow to make easier testing it locally
72+
- name: Upload cabal-install executable to workflow artifacts
73+
if: inputs.ghc == env.GHC_FOR_RELEASE
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: cabal-${{ runner.os }}-${{ env.CABAL_ARCH }}
77+
path: ${{ env.CABAL_EXEC_TAR }}
78+
79+
# We want all the tests to be run even if one fails, but we want to fail the validate
80+
# if any of them fail. It turns out that there is a way to get at the outcome of a step
81+
# before `continue-on-error`` is applied, so the last step uses that.
82+
#
83+
# Note that we can't use filter syntax to look for any such failure, because the
84+
# hackage-repo-tool install is also `continue-on-error` and its failure is legitimate
85+
# (see the comment there). So the final step must list all of the tests, not that I expect
86+
# any new ones to be added.
87+
88+
- name: Validate lib-tests
89+
id: lib-tests
90+
continue-on-error: true
91+
env:
92+
# `rawSystemStdInOut reports text decoding errors`
93+
# test does not find ghc without the full path in windows
94+
GHCPATH: ${{ steps.setup-haskell.outputs.ghc-exe }}
95+
shell: ${{ inputs.shell }}
96+
run: |
97+
echo ::group::Validate lib-tests
98+
sh validate.sh $FLAGS -s lib-tests
99+
100+
- name: Validate lib-suite
101+
id: lib-suite
102+
continue-on-error: true
103+
shell: ${{ inputs.shell }}
104+
run: |
105+
echo ::group::Validate lib-suite
106+
sh validate.sh $FLAGS -s lib-suite
107+
108+
- name: Validate cli-tests
109+
id: cli-tests
110+
continue-on-error: true
111+
shell: ${{ inputs.shell }}
112+
run: |
113+
echo ::group::Validate cli-tests
114+
sh validate.sh $FLAGS -s cli-tests
115+
116+
- name: Validate cli-suite
117+
id: cli-suite
118+
continue-on-error: true
119+
shell: ${{ inputs.shell }}
120+
run: |
121+
echo ::group::Validate cli-suite
122+
sh validate.sh $FLAGS -s cli-suite
123+
124+
- name: Validate solver-benchmarks-tests
125+
id: solver-benchmarks-tests
126+
continue-on-error: true
127+
if: "inputs.ghc == env.GHC_FOR_SOLVER_BENCHMARKS"
128+
shell: ${{ inputs.shell }}
129+
run: |
130+
echo ::group::Validate solver-benchmarks-tests
131+
sh validate.sh $FLAGS -s solver-benchmarks-tests
132+
133+
- name: Validate solver-benchmarks-run
134+
id: solver-benchmarks-run
135+
continue-on-error: true
136+
if: "inputs.ghc == env.GHC_FOR_SOLVER_BENCHMARKS"
137+
shell: ${{ inputs.shell }}
138+
run: |
139+
echo ::group::Validate solver-benchmarks-run
140+
sh validate.sh $FLAGS -s solver-benchmarks-run
141+
142+
- name: Collect test results
143+
if: steps.lib-tests.outcome == 'failure' || steps.lib-suite.outcome == 'failure' || steps.cli-tests.outcome == 'failure' || steps.cli-suite.outcome == 'failure' || steps.solver-benchmarks-tests.outcome == 'failure' || steps.solver-benchmarks-run.outcome == 'failure'
144+
shell: ${{ inputs.shell }}
145+
run: exit 1

.github/config.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# all of these will get "GHC_" prepended
2+
# note: FOR_RELEASE must be an element of both FOR_VALIDATE and FOR_BOOTSTRAP!
3+
FOR_RELEASE: "9.4.8"
4+
FOR_SOLVER_BENCHMARKS: ${GHC_FOR_RELEASE}
5+
FOR_COMPLETE_HACKAGE_TESTS: ${GHC_FOR_RELEASE}
6+
# these will be decoded with fromJSON
7+
# If you remove something from here, then add it to the old-ghcs job.
8+
# Also a removed GHC from here means that we are actually dropping
9+
# support, so the PR *must* have a changelog entry.
10+
FOR_VALIDATE: ["9.10.1", "9.8.2", "9.6.6", "9.4.8", "9.2.8", "9.0.2", "8.10.7", "8.8.4"]
11+
## GHC 7.10.3 does not install on ubuntu-22.04 with ghcup.
12+
## Older GHCs are not supported by ghcup in the first place.
13+
FOR_VALIDATE_OLD: ["8.4.4", "8.2.2", "8.0.2"]
14+
FOR_BOOTSTRAP: ["9.8.2", "9.6.6", "9.4.8", "9.2.8", "9.0.2"]
15+
COMMON_FLAGS: -j 2 -v

0 commit comments

Comments
 (0)