Skip to content

Add Range package #1876

Add Range package

Add Range package #1876

Workflow file for this run

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/[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-latest
# Benchmarks on pushes to main should run sequentially.
concurrency: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && format('{0}-{1}-{2}', github.workflow, github.job, github.ref) || github.run_id }}
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 }}
- name: Run benchmark
working-directory: compiler/vm/
# TODO(JonasWanke): Fix output format error
# Explicitly specify Bash since it also includes `-o pipefail`. Without
# it, this step succeeds even if the benchmark execution itself fails.
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
# shell: bash
run: cargo bench -- --output-format bencher | tee benchmark_output.txt
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: Compiler
tool: cargo
output-file-path: compiler/vm/benchmark_output.txt
gh-pages-branch: gh-pages
gh-repository: github.com/candy-lang/benchmark-results
benchmark-data-dir-path: ./
# Only push results to the benchmark repository if we ran on a commit
# to the main branch.
auto-push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
github-token: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && secrets.BENCHMARK_RESULTS_TOKEN || secrets.BENCHMARK_RESULTS_COMMENT_TOKEN }}
# Forks don't have access to secrets, so we can't create a commit
# comment. This step can still fail to notify us and the output shows
# results.
comment-always: ${{ github.secret_source == 'Actions' || github.secret_source == 'Dependabot' }}
comment-on-alert: ${{ github.secret_source == 'Actions' || github.secret_source == 'Dependabot' }}
alert-threshold: 200%
# Benchmarks running on GitHub Actions have a very high variance.
fail-on-alert: true
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/[email protected]
- 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