Skip to content

Commit ce925f9

Browse files
committed
Migrate stackage build on GHA
1 parent 73c0273 commit ce925f9

1 file changed

Lines changed: 101 additions & 0 deletions

File tree

.github/workflows/stack.yaml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Stack builds
2+
3+
defaults:
4+
run:
5+
shell: bash
6+
7+
# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency.
8+
concurrency:
9+
group: ${{ github.head_ref }}-${{ github.workflow }}
10+
cancel-in-progress: true
11+
12+
on:
13+
pull_request:
14+
branches:
15+
- '**'
16+
17+
jobs:
18+
pre_job:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
ghcs: ${{ steps.ghcs.outputs.ghcs }}
22+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
23+
steps:
24+
# Need the repo checked out in order to read the file
25+
- uses: actions/checkout@v3
26+
- id: skip_check
27+
uses: fkirc/skip-duplicate-actions@v5.3.1
28+
with:
29+
cancel_others: false
30+
paths_ignore: '[ "**/docs/**"
31+
, "**.md"
32+
, "**/LICENSE"
33+
, "**.nix"
34+
, "flake.lock"
35+
, "**/README.md"
36+
, "FUNDING.yml"
37+
, ".circleci/**"
38+
, ".gitlab-ci.yaml"
39+
, ".gitlab/**"
40+
]'
41+
42+
stack:
43+
if: needs.pre_job.outputs.should_skip != 'true'
44+
needs: pre_job
45+
runs-on: ubuntu-latest
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
include:
50+
- stack-yaml: stack.yaml
51+
ghc: "9.8.4"
52+
- stack-yaml: stack-lts24.yaml
53+
ghc: "9.10.3"
54+
55+
name: stack / ghc-${{ matrix.ghc }}
56+
57+
steps:
58+
- uses: actions/checkout@v3
59+
60+
- name: Setup GHC and Stack
61+
uses: haskell-actions/setup@v2.10.3
62+
with:
63+
ghc-version: ${{ matrix.ghc }}
64+
enable-stack: true
65+
stack-no-global: true
66+
67+
- name: Restore ~/.stack cache
68+
id: stack-cache-restore
69+
uses: actions/cache/restore@v5
70+
with:
71+
path: ~/.stack
72+
key: stack-${{ runner.os }}-${{ matrix.stack-yaml }}-${{ hashFiles(matrix.stack-yaml) }}
73+
restore-keys: |
74+
stack-${{ runner.os }}-${{ matrix.stack-yaml }}-
75+
76+
- name: Build
77+
run: |
78+
stack -j2 \
79+
--stack-yaml=${{ matrix.stack-yaml }} \
80+
--system-ghc \
81+
--no-terminal \
82+
build --test --no-run-tests
83+
84+
- name: Save ~/.stack cache
85+
if: github.ref == 'refs/heads/master'
86+
uses: actions/cache/save@v5
87+
with:
88+
path: ~/.stack
89+
key: stack-${{ runner.os }}-${{ matrix.stack-yaml }}-${{ hashFiles(matrix.stack-yaml) }}
90+
91+
stack_post_job:
92+
if: always()
93+
runs-on: ubuntu-latest
94+
needs: [pre_job, stack]
95+
steps:
96+
- run: |
97+
echo "jobs info: ${{ toJSON(needs) }}"
98+
- if: contains(needs.*.result, 'failure')
99+
run: exit 1
100+
- if: contains(needs.*.result, 'cancelled') && needs.pre_job.outputs.should_skip != 'true'
101+
run: exit 1

0 commit comments

Comments
 (0)