Skip to content

Commit

Permalink
Merge pull request #1067 from candy-lang/update-ci
Browse files Browse the repository at this point in the history
Update CI for new compiler
  • Loading branch information
jwbot authored Nov 28, 2024
2 parents 8a79b5f + 671a70d commit 1cde164
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 279 deletions.
60 changes: 18 additions & 42 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,35 @@ updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
interval: weekly
labels:
- 'T: Build'

- package-ecosystem: cargo
directory: /compiler/cli
schedule:
interval: daily
labels:
- 'T: Build'
- package-ecosystem: cargo
directory: /compiler/formatter
schedule:
interval: daily
labels:
- 'T: Build'
- package-ecosystem: cargo
directory: /compiler/frontend
schedule:
interval: daily
labels:
- 'T: Build'
- package-ecosystem: cargo
directory: /compiler/fuzzer
schedule:
interval: daily
labels:
- 'T: Build'
- package-ecosystem: cargo
directory: /compiler/language_server
schedule:
interval: daily
labels:
- 'T: Build'
- package-ecosystem: cargo
directory: /compiler/vm
directories:
- compiler_v4
- compiler/backend_inkwell
- compiler/cli
- compiler/formatter
- compiler/formatter/fuzz
- compiler/frontend
- compiler/fuzzer
- compiler/language_server
- compiler/vm
- compiler/vm/fuzz
schedule:
interval: daily
labels:
- 'T: Build'
- package-ecosystem: cargo
directory: /compiler/vm/fuzz
schedule:
interval: daily
interval: weekly
labels:
- 'T: Build'

- package-ecosystem: npm
directory: /vscode_extension
directories:
- /vscode_extension
- /vscode_extension_v4
schedule:
interval: weekly
labels:
- 'T: Build'
groups:
glob:
patterns:
Expand All @@ -70,5 +48,3 @@ updates:
typescript-eslint:
patterns:
- '@typescript-eslint/*'
labels:
- 'T: Build'
12 changes: 12 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
- changed-files:
- any-glob-to-any-file:
- packages/Builtins/**/*
'P: Compiler v4':
- changed-files:
- any-glob-to-any-file:
- compiler_v4/**/*
'P: Compiler: CLI':
- changed-files:
- any-glob-to-any-file:
Expand Down Expand Up @@ -51,6 +55,10 @@
- changed-files:
- any-glob-to-any-file:
- vscode_extension/**/*
'P: Compiler: VS Code Extension v4':
- changed-files:
- any-glob-to-any-file:
- vscode_extension_v4/**/*
'P: ComplexNumber':
- changed-files:
- any-glob-to-any-file:
Expand All @@ -75,6 +83,10 @@
- changed-files:
- any-glob-to-any-file:
- packages/Http/**/*
'P: Packages v5':
- changed-files:
- any-glob-to-any-file:
- packages_v5/**/*
'P: Parser':
- changed-files:
- any-glob-to-any-file:
Expand Down
202 changes: 2 additions & 200 deletions .github/workflows/compiler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:

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:
Expand All @@ -19,209 +16,14 @@ jobs:
- uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/[email protected]
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v4
with:
path: ./llvm
key: llvm-15.0
- uses: KyleMayes/[email protected]
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/[email protected]
# - name: Cache LLVM and Clang
# id: cache-llvm
# uses: actions/cache@v4
# with:
# path: ./llvm
# key: llvm-15.0
# - uses: KyleMayes/[email protected]
# 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/[email protected]
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v4
with:
path: ./llvm
key: llvm-15.0
- uses: KyleMayes/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
- 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/[email protected]
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/[email protected]
- 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
Expand All @@ -230,7 +32,7 @@ jobs:
security-events: write
defaults:
run:
working-directory: vscode_extension/
working-directory: vscode_extension_v4/
steps:
- uses: actions/checkout@v4

Expand All @@ -247,5 +49,5 @@ jobs:

- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: vscode_extension/eslint-results.sarif
sarif_file: vscode_extension_v4/eslint-results.sarif
wait-for-processing: true
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[workspace]
resolver = "2"
members = [
"compiler_v4",
"compiler/backend_inkwell",
"compiler/cli",
"compiler/frontend",
"compiler/fuzzer",
"compiler/formatter",
"compiler/formatter/fuzz",
"compiler/frontend",
"compiler/fuzzer",
"compiler/language_server",
"compiler/vm",
"compiler/vm/fuzz",
"compiler_v4",
]

[workspace.package]
Expand Down
Loading

0 comments on commit 1cde164

Please sign in to comment.