-
Notifications
You must be signed in to change notification settings - Fork 483
203 lines (176 loc) · 7.75 KB
/
coverage.yml
File metadata and controls
203 lines (176 loc) · 7.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: Coverage
on:
push:
branches: [master]
pull_request:
branches: [master]
concurrency:
group: coverage-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
OCAMLRUNPARAM: b
# When changing the setup-ocaml version, also adjust it in the setup step
# further below.
SETUP_OCAML_VERSION: 3.6.0 # OPAM <2.6.0
jobs:
coverage:
runs-on: ubuntu-24.04-arm
env:
OS: ubuntu-24.04-arm
OCAML_COMPILER: 5.3.0
RUST_TARGET: aarch64-unknown-linux-gnu
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
cache: yarn
node-version-file: .nvmrc
- name: Install npm packages
run: yarn install
- name: Install system dependencies
uses: awalsh128/cache-apt-pkgs-action@v1.4.3
with:
packages: bubblewrap darcs g++-multilib gcc-multilib mercurial musl-tools rsync cmake
version: v4
# --- rewatch build cache ---------------------------------------------
# `make coverage` shells out to `make` which builds rewatch; cache the
# cargo target dir so subsequent runs skip the Rust toolchain install
# and the cargo build when the rewatch sources haven't changed.
- name: Restore rewatch build cache
id: rewatch-build-cache
uses: actions/cache@v5
with:
path: rewatch/target
key: rewatch-build-v3-${{ env.RUST_TARGET }}-${{ hashFiles('rewatch/src/**', 'rewatch/Cargo.lock') }}
- name: Determine Rust toolchain version
id: rust-version
run: |
version="$(awk -F '"' '/^rust-version[[:space:]]*=/ { print $2; exit }' rewatch/Cargo.toml)"
echo "version=${version}" >> "$GITHUB_OUTPUT"
- name: Install Rust toolchain
if: steps.rewatch-build-cache.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.rust-version.outputs.version }}
components: clippy, rustfmt
- name: Build rewatch
if: steps.rewatch-build-cache.outputs.cache-hit != 'true'
run: cargo build --manifest-path rewatch/Cargo.toml --release
- name: Copy rewatch binary
run: |
cp rewatch/target/release/rescript rescript
./scripts/copyExes.js --rewatch
# --- OPAM environment cache ------------------------------------------
# The OPAM install step is the dominant cost on a cold run (often >10
# min). Cache the whole opam tree, keyed on the OS, setup-ocaml
# version, compiler, and the `.opam` files. The cache also includes
# the dev-setup dependencies (e.g. bisect_ppx) so the key is distinct
# from the main CI workflow's cache.
- name: Get OPAM cache key
run: echo "opam_cache_key=opam-coverage-v1-${{ env.OS }}-${{ env.SETUP_OCAML_VERSION }}-${{ env.OCAML_COMPILER }}-${{ hashFiles('*.opam') }}" >> $GITHUB_ENV
- name: Restore OPAM environment
id: cache-opam-env
uses: actions/cache/restore@v5
with:
path: |
${{ runner.tool_cache }}/opam
~/.opam
_opam
.opam-path
key: ${{ env.opam_cache_key }}
- name: Use OCaml ${{ env.OCAML_COMPILER }}
if: steps.cache-opam-env.outputs.cache-hit != 'true'
uses: ocaml/setup-ocaml@v3.6.0
with:
ocaml-compiler: ${{ env.OCAML_COMPILER }}
opam-pin: false
- name: Get OPAM executable path
if: steps.cache-opam-env.outputs.cache-hit != 'true'
uses: actions/github-script@v9
with:
script: |
const opamPath = await io.which('opam', true);
console.log('opam executable found: %s', opamPath);
const fs = require('fs/promises');
await fs.writeFile('.opam-path', opamPath, 'utf-8');
console.log('stored path to .opam-path');
- name: Install OPAM dependencies (incl. bisect_ppx)
if: steps.cache-opam-env.outputs.cache-hit != 'true'
run: opam install . --deps-only --with-test --with-dev-setup
# Only save on master pushes. PR-scoped caches are tied to
# refs/pull/<n>/merge and can't be restored by master or other PRs,
# so they'd just consume storage and evict the shared entry. PRs
# still get full restore from the latest master-saved cache.
- name: Save OPAM environment
if: steps.cache-opam-env.outputs.cache-hit != 'true' && github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: actions/cache/save@v5
with:
path: |
${{ runner.tool_cache }}/opam
~/.opam
_opam
.opam-path
key: ${{ env.opam_cache_key }}
- name: Use cached OPAM environment
if: steps.cache-opam-env.outputs.cache-hit == 'true'
run: |
# https://github.com/ocaml/setup-ocaml/blob/v3.6.0/packages/setup-ocaml/src/installer.ts
echo "OPAMCOLOR=always" >> "$GITHUB_ENV"
echo "OPAMCONFIRMLEVEL=unsafe-yes" >> "$GITHUB_ENV"
echo "OPAMDOWNLOADJOBS=4" >> "$GITHUB_ENV"
echo "OPAMERRLOGLEN=0" >> "$GITHUB_ENV"
echo "OPAMEXTERNALSOLVER=builtin-0install" >> "$GITHUB_ENV"
echo "OPAMPRECISETRACKING=1" >> "$GITHUB_ENV"
echo "OPAMRETRIES=10" >> "$GITHUB_ENV"
echo "OPAMSOLVERTIMEOUT=600" >> "$GITHUB_ENV"
echo "OPAMYES=1" >> "$GITHUB_ENV"
echo "CLICOLOR_FORCE=1" >> "$GITHUB_ENV"
echo "OPAMROOT=$HOME/.opam" >> "$GITHUB_ENV"
OPAM_PATH="$(cat .opam-path)"
chmod +x "$OPAM_PATH"
dirname "$OPAM_PATH" >> "$GITHUB_PATH"
# --- Coverage build cache --------------------------------------------
# The bisect_ppx-instrumented dune build is a separate artifact from
# the main CI build, so it gets its own key. Only restore/save on
# master pushes — PRs share the master cache to stay fast but won't
# poison it.
- name: Coverage build state key
id: coverage-build-state-key
run: echo "value=coverage-build-state-v1-${{ env.OS }}-${{ env.SETUP_OCAML_VERSION }}-${{ env.OCAML_COMPILER }}-${{ hashFiles('*.opam', 'compiler/**', 'dune-project') }}" >> $GITHUB_OUTPUT
- name: Restore coverage build state
if: github.base_ref == 'master' || github.ref == 'refs/heads/master'
id: coverage-build-state
uses: actions/cache/restore@v5
with:
path: |
~/.cache/dune
_build
key: ${{ steps.coverage-build-state-key.outputs.value }}
- name: Run coverage
run: opam exec -- make coverage
- name: Delete stale coverage build state
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ steps.coverage-build-state-key.outputs.value }} \
-R ${{ github.repository }} \
-B "$GITHUB_REF" \
--confirm || echo "not exist"
env:
GH_TOKEN: ${{ github.token }}
- name: Save coverage build state
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: actions/cache/save@v5
with:
path: |
~/.cache/dune
_build
key: ${{ steps.coverage-build-state-key.outputs.value }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: _coverage/coverage.json
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}