-
Notifications
You must be signed in to change notification settings - Fork 11
193 lines (169 loc) · 6.23 KB
/
ci.yml
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
name: Test
on:
pull_request: {}
push:
branches:
- master
- ci/*
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: '1'
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
cargo_test:
name: Cargo Test
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: install rust nightly-2021-10-07
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-10-07
override: true
- uses: Swatinem/rust-cache@v1
- run: cargo test --lib
- run: cargo test --doc
- run: cargo test -p citeproc-io --test integration
regressions:
name: CSL Test Suite Regressions
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Extract branch name
id: branch
shell: bash
env:
GITHUB_HEAD: ${{ github.head_ref }}
GITHUB_BASE: ${{ github.base_ref }}
run: |
IS_CI_TEST=${{ github.event_name == 'push' && github.ref != 'refs/heads/master' && 'true' || 'false '}}
if test -z "$GITHUB_HEAD"; then
GITHUB_HEAD="$GITHUB_REF"
fi
if test -z "$GITHUB_BASE"; then
GITHUB_BASE="$GITHUB_REF"
fi
# transforms refs/pulls/123/merge into pulls-123-merge
GITHUB_HEAD=${GITHUB_HEAD#refs/heads/}
GITHUB_HEAD=$(echo "${GITHUB_HEAD#refs/}" | tr '/' '-')
echo "GITHUB_HEAD = ${GITHUB_HEAD}"
echo "::set-output name=head::${GITHUB_HEAD}"
if $IS_CI_TEST; then
echo "::set-output name=base::master"
else
GITHUB_BASE=${GITHUB_BASE#refs/heads/}
GITHUB_BASE=$(echo "${GITHUB_BASE#refs/}" | tr '/' '-')
echo "GITHUB_BASE = ${GITHUB_BASE}"
echo "::set-output name=base::${GITHUB_BASE}"
fi
- name: >
Plan: compare ${{ steps.branch.outputs.head }} to ${{ steps.branch.outputs.base }}
run: echo
- name: Download base output
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ap-southeast-2
GITHUB_BASE: ${{ steps.branch.outputs.base }}
GITHUB_HEAD: ${{ steps.branch.outputs.head }}
run: |
mkdir -p .snapshots/branches
mkdir -p test-results
S3_PREFIX='https://citeproc-rs-test-results.cormacrelf.net'
curl -sL "$S3_PREFIX/.snapshots/branches/$GITHUB_BASE" -o ".snapshots/branches/$GITHUB_BASE"
- name: install rust nightly-2021-10-07
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-10-07
override: true
- uses: Swatinem/rust-cache@v1
- name: "Build tools package"
run: cargo build --package tools
- name: "Pull locales"
run: cargo pull-locales
- name: "Log test suite results"
run: cargo test-suite store
- name: "Compare test suite results for regressions"
env:
GITHUB_BASE: ${{ steps.branch.outputs.base }}
GITHUB_HEAD: ${{ steps.branch.outputs.head }}
shell: bash
run: |
cp .snapshots/current ".snapshots/branches/$GITHUB_HEAD"
cargo test-suite diff "$GITHUB_BASE..$GITHUB_HEAD" | tee test-results/diff
# need the first command in the pipe, $? would give us tee's status
echo "${PIPESTATUS[0]}" > test-results/diff-status
- name: "Write the test-results artifact files"
if: always()
env:
PR_NUM: ${{ github.event.number }}
GITHUB_HEAD: ${{ steps.branch.outputs.head }}
run: |
mkdir -p test-results
test -f .snapshots/current && cp .snapshots/current test-results/snapshot || echo "" > test-results/snapshot
if ${{ github.event_name == 'pull_request' && 'true' || 'false'}}; then
echo "$PR_NUM" > test-results/pr-number
echo "pulls/$PR_NUM" > test-results/name
fi
if ${{github.event_name == 'push' && 'true' || 'false'}}; then
echo "branches/$GITHUB_HEAD" > test-results/name
# DEBUGGING ONLY: write to an old PR
# echo "1" > test-results/pr-number
fi
- name: "Upload test result artifacts (GitHub Actions)"
if: always()
uses: actions/upload-artifact@v2
with:
name: test-results
path: |
test-results/*
# i.e.
# test-results/pr-number
# test-results/name
# test-results/diff
# test-results/diff-status
# test-results/snapshot
wasm_tests:
name: "Test the WASM package"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup-rust-wasm
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Restore yarn cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Yarn install
working-directory: crates/wasm/js-tests
run: yarn install
- name: Build WASM
working-directory: crates/wasm/js-tests
run: yarn build
- name: Download Firefox ESR from zotero-standalone-build
working-directory: crates/wasm/js-tests
run: ./install_firefox.sh
- name: Run tests, including in Firefox ESR
working-directory: crates/wasm/js-tests
run: MUST_RUN_FIREFOX_TESTS=1 yarn test
# not necessary because we install @citeproc-rs/wasm without yarn knowing now
# # otherwise, the yarn cache will contain a different @citeproc-rs/wasm
# # entry every time.
# - name: Clean yarn cache dir of wasm output
# run: |
# cd "$(yarn cache dir)"
# ls | grep citeproc-rs-wasm | xargs rm -rf