Skip to content

Commit 001fe79

Browse files
committed
CI: add flags workflow
1 parent 712244a commit 001fe79

File tree

1 file changed

+165
-0
lines changed

1 file changed

+165
-0
lines changed

.github/workflows/flags.yml

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: Flags
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+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
22+
should_skip_ghcide: ${{ steps.skip_ghcide_check.outputs.should_skip }}
23+
steps:
24+
- id: skip_check
25+
uses: fkirc/[email protected]
26+
with:
27+
cancel_others: false
28+
paths_ignore: '[ "**/docs/**"
29+
, "**.md"
30+
, "**/LICENSE"
31+
, "install/**"
32+
, "**.nix"
33+
, "flake.lock"
34+
, "**/README.md"
35+
, "FUNDING.yml"
36+
, ".circleci/**"
37+
, "**/stack*.yaml"
38+
]'
39+
# If we only change ghcide downstream packages we have not test ghcide itself
40+
- id: skip_ghcide_check
41+
uses: fkirc/[email protected]
42+
with:
43+
cancel_others: false
44+
paths_ignore: '[ "hls-test-utils/**"
45+
, "plugins/**"
46+
, "src/**"
47+
, "exe/**"
48+
, "test/**"
49+
, "shake-bench/**"
50+
]'
51+
52+
flags:
53+
if: needs.pre_job.outputs.should_skip != 'true'
54+
needs: pre_job
55+
runs-on: ${{ matrix.os }}
56+
strategy:
57+
fail-fast: true
58+
matrix:
59+
ghc: [ "8.10.7"
60+
]
61+
os: [ "ubuntu-latest"
62+
]
63+
cabal: ['3.6']
64+
65+
steps:
66+
- uses: actions/checkout@v2
67+
68+
- uses: haskell/actions/setup@v1
69+
id: HaskEnvSetup
70+
with:
71+
ghc-version : ${{ matrix.ghc }}
72+
cabal-version: ${{ matrix.cabal }}
73+
enable-stack: false
74+
75+
- if: runner.os == 'Windows'
76+
name: (Windows) Platform config
77+
run: |
78+
echo "CABAL_PKGS_DIR=C:\\cabal\\packages" >> $GITHUB_ENV
79+
- if: ( runner.os == 'Linux' ) || ( runner.os == 'macOS' )
80+
name: (Linux,macOS) Platform config
81+
run: |
82+
echo "CABAL_PKGS_DIR=~/.cabal/packages" >> $GITHUB_ENV
83+
84+
# All workflows which distinquishes cache on `cabal.project` needs this.
85+
- name: Workaround shorten binary names
86+
run: |
87+
sed -i.bak -e 's/haskell-language-server/hls/g' \
88+
-e 's/haskell_language_server/hls/g' \
89+
haskell-language-server.cabal cabal.project
90+
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
91+
src/**/*.hs exe/*.hs
92+
93+
- name: Retrieving `cabal.project` Hackage timestamp
94+
run: |
95+
# Form: index-state: 2021-11-29T08:11:08Z
96+
INDEX_STATE_ENTRY=$(grep index-state cabal.project)
97+
# Form: 2021-11-29T08-11-08Z
98+
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
99+
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
100+
101+
- name: Form the package list ('cabal.project.freeze')
102+
continue-on-error: true
103+
run: |
104+
cabal v2-freeze && \
105+
echo '' && \
106+
echo 'Output:' && \
107+
echo '' && \
108+
cat 'cabal.project.freeze' && \
109+
echo '' || \
110+
echo 'WARNING: Could not produce the `freeze`.
111+
112+
- name: Hackage sources cache
113+
uses: actions/cache@v2
114+
env:
115+
cache-name: hackage-sources
116+
with:
117+
path: ${{ env.CABAL_PKGS_DIR }}
118+
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
119+
restore-keys: ${{ env.cache-name }}-
120+
121+
- name: Compiled deps cache
122+
id: compiled-deps
123+
uses: actions/cache@v2
124+
env:
125+
cache-name: compiled-deps
126+
with:
127+
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
128+
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }}
129+
restore-keys: |
130+
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
131+
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
132+
${{ env.cache-name }}-${{ runner.os }}-
133+
134+
- if: needs.pre_job.outputs.should_skip != 'true'
135+
name: Build `hls-graph` with flags
136+
run: cabal v2-build hls-graph --flags="pedantic embed-files stm-stats"
137+
138+
- if: needs.pre_job.outputs.should_skip != 'true'
139+
name: Build `hie-compat` with flags
140+
run: cabal v2-build hie-compat --flags="ghc-lib"
141+
142+
- if: needs.pre_job.outputs.should_skip != 'true'
143+
name: Build `hls-plugin-api` with flags
144+
run: cabal v2-build hls-plugin-api --flags="pedantic"
145+
146+
- if: needs.pre_job.outputs.should_skip != 'true'
147+
name: Build `hls-test-utils` with flags
148+
run: cabal v2-build hls-test-utils --flags="pedantic"
149+
150+
# repeating builds to workaround segfaults in windows and ghc-8.8.4
151+
- if: needs.pre_job.outputs.should_skip_ghcide != 'true'
152+
name: Build
153+
run: cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe" || cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe" || cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe"
154+
155+
flags_post_job:
156+
if: always()
157+
runs-on: ubuntu-latest
158+
needs: [pre_job, flags]
159+
steps:
160+
- run: |
161+
echo "jobs info: ${{ toJSON(needs) }}"
162+
- if: contains(needs.*.result, 'failure')
163+
run: exit 1
164+
- if: contains(needs.*.result, 'cancelled') && needs.pre_job.outputs.should_skip != 'true'
165+
run: exit 1

0 commit comments

Comments
 (0)