-
-
Notifications
You must be signed in to change notification settings - Fork 3
251 lines (229 loc) · 8.86 KB
/
compiler.yaml
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: Compiler
on:
push:
branches: [main]
pull_request:
env:
RUST_BACKTRACE: 1
# Use LLD as the linker to increase compile times. It's installed together
# with LLVM.
RUSTFLAGS: -C link-arg=-fuse-ld=lld
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2.7.3
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v4
with:
path: ./llvm
key: llvm-15.0
- uses: KyleMayes/install-llvm-action@v2.0.1
with:
version: "15.0"
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
# Compiler
- name: "Compiler: clippy"
run: cargo clippy -- --deny warnings
- name: "Compiler: test"
run: cargo test --workspace
- name: "Compiler: fmt"
run: cargo fmt --check
# Core
- name: "Core: run"
run: cargo run --release -- check ./packages/Core/_.candy
# fuzzing:
# name: Fuzzing
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: dsherret/rust-toolchain-file@v1
# - uses: Swatinem/rust-cache@v2.7.3
# - name: Cache LLVM and Clang
# id: cache-llvm
# uses: actions/cache@v4
# with:
# path: ./llvm
# key: llvm-15.0
# - uses: KyleMayes/install-llvm-action@v2.0.1
# with:
# version: "15.0"
# cached: ${{ steps.cache-llvm.outputs.cache-hit }}
# - run: cargo run --release -- fuzz ./packages/Benchmark.candy
check-goldens:
name: Check Golden IR Files
runs-on: ubuntu-latest
env:
# Counter-intuitively, `github.sha` for a PR event does _not_ refer to the
# PR's head SHA, but to a merge commit that GitHub creates behind the
# scenes.
#
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
# https://fluffyandflakey.blog/2022/12/21/what-is-a-github-pull-request-merge-branch/
HEAD_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
steps:
- uses: actions/checkout@v4
with:
path: candy/
# dsherret/rust-toolchain-file doesn't have an input to specify the
# toolchain file's path.
- run: cp candy/rust-toolchain.toml ./
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2.7.3
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v4
with:
path: ./llvm
key: llvm-15.0
- uses: KyleMayes/install-llvm-action@v2.0.1
with:
version: "15.0"
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Generate Goldens
working-directory: candy/
run: cargo run --release --features inkwell -- debug gold generate ./packages/Examples/
- name: Checkout Golden IRs
uses: actions/checkout@v4
with:
token: ${{ secrets.GOLDEN_IR_PUSH_TOKEN }}
repository: candy-lang/golden-irs
ref: ${{ github.event_name == 'pull_request' && format('{0}_', github.event.pull_request.base.sha) || 'main' }}
fetch-depth: 1
path: golden-irs/
lfs: true
- name: Create new branch in golden-irs/
working-directory: golden-irs/
run: |
git checkout --orphan ${{ env.HEAD_SHA }}_
git rm -r --force .
- run: mv candy/packages/Examples/.goldens/* golden-irs/
# GitHub's maximum file size is 100 MB, so we store files larger than that
# in Git LFS. We explicitly specify the files to store there so that we
# can preview/diff most files normally.
- name: Store files larger than 100 MB in LFS
working-directory: golden-irs/
run: |
large_files=$(find . -type f -size +100M -not -path "./.git/*")
if [ -n "$large_files" ]; then
while IFS= read -r path; do
echo "${path/ /[[:space:]]} filter=lfs diff=lfs merge=lfs -text" >> .gitattributes
done <<< "$large_files"
fi
- uses: EndBug/add-and-commit@v9.1.4
with:
cwd: golden-irs/
add: .
default_author: user_info
message: Generate golden IRs
push: --force origin ${{ env.HEAD_SHA }}_
- id: diff
if: github.event_name == 'pull_request'
continue-on-error: true
working-directory: golden-irs/
run: git diff --quiet ${{ github.event.pull_request.base.sha }}_ ${{ env.HEAD_SHA }}_
- name: Shorten commit SHAs
id: short-shas
if: steps.diff.outcome == 'failure'
run: |
base_sha=${{ github.event.pull_request.base.sha }}
echo "base_sha=${base_sha::7}" >> "$GITHUB_OUTPUT"
head_sha=${{ env.HEAD_SHA }}
echo "head_sha=${head_sha::7}" >> "$GITHUB_OUTPUT"
- if: steps.diff.outcome == 'failure'
uses: peter-evans/create-or-update-comment@v4.0.0
with:
issue-number: ${{ github.event.pull_request.number }}
token: ${{ secrets.GOLDEN_IR_COMMENT_TOKEN }}
body: |
The golden IRs have changed: [${{ steps.short-shas.outputs.base_sha }}..${{ steps.short-shas.outputs.head_sha }}](https://github.com/candy-lang/golden-irs/compare/${{ github.event.pull_request.base.sha }}_..${{ env.HEAD_SHA }}_)
benchmark:
name: Benchmark
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2.7.3
- name: Cache cargo plugins
uses: actions/cache@v4
with:
path: ~/.cargo/bin/
key: ${{ runner.os }}-benchmark-cargo-plugins
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v4
with:
path: ./llvm
key: llvm-15.0
- uses: KyleMayes/install-llvm-action@v2.0.1
with:
version: "15.0"
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Install Valgrind
run: sudo apt update && sudo apt install -y valgrind
- name: Install benchmark runner
run: |
version=$(cargo metadata --format-version=1 | \
jq '.packages[] | select(.name == "iai-callgrind").version' | \
tr -d '"'
)
# TODO(JonasWanke): Can we avoid the `--force`? Cargo should support
# installing it without the flag [0], but it currently fails [1].
# Maybe the cache is missing some files? [2]
# [0]: https://github.com/rust-lang/cargo/issues/6727
# [1]: https://github.com/candy-lang/candy/actions/runs/8103066154/job/22146912428?pr=929#step:9:59
# [2]: https://users.rust-lang.org/t/get-cargo-install-to-fail-silently-if-the-binary-already-exists/99507/2
cargo install iai-callgrind-runner --version $version --force
- name: Install Bencher CLI
uses: bencherdev/bencher@v0.4.2
- name: Run benchmarks and store results
working-directory: compiler/vm/
# TODO: Support PRs from forks: https://bencher.dev/docs/how-to/github-actions/#pull-requests-from-forks
env:
IAI_CALLGRIND_COLOR: never
run: |
# https://unix.stackexchange.com/a/724034
exec 3>&1
output=$(cargo bench 3>&- | tee /dev/fd/3)
exec 3>&-
renamed_output=$(echo "$output" | sed -E 's/^benchmark::main::(\S+) .*?:[cv]\("(.*?)"(, & \[("(.*?)"|)\]|)\)$/\1: \2.candy \5/g')
bencher run \
--project candy \
--token ${{ secrets.BENCHER_TOKEN }} \
--if-branch ${{ github.head_ref || github.ref_name }} \
--else-if-branch ${{ github.base_ref || 'main' }} \
--else-if-branch main \
--hash ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} \
--testbed github-actions-ubuntu-22-04 \
--adapter rust_iai_callgrind \
--err \
--github-actions ${{ secrets.BENCHMARK_RESULTS_COMMENT_TOKEN }} \
echo "$renamed_output"
vscode-extension-check:
name: Check VS Code Extension
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
defaults:
run:
working-directory: vscode_extension/
steps:
- uses: actions/checkout@v4
- run: npm install
- run: npm install @microsoft/eslint-formatter-sarif@3.0.0
- name: Run ESLint
run: |
npx eslint . \
--ext .ts \
--format @microsoft/eslint-formatter-sarif \
--output-file eslint-results.sarif
continue-on-error: true
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: vscode_extension/eslint-results.sarif
wait-for-processing: true