CI #1708
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
schedule: | |
- cron: "0 */3 * * *" # Every 3 hours. | |
pull_request: | |
types: [opened, synchronize] | |
paths-ignore: | |
- '**/*.md' | |
push: | |
branches: | |
- main | |
- "renovate/**" | |
paths-ignore: | |
- '**/*.md' | |
workflow_dispatch: | |
inputs: | |
issue-number: | |
required: false | |
type: string | |
comment-id: | |
required: false | |
type: string | |
ref: | |
required: false | |
type: string | |
default: 'main' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | |
cancel-in-progress: ${{ github.ref_name != 'main' }} | |
jobs: | |
build: | |
name: Build | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
outputs: | |
size: ${{ steps.size.outputs.BINARY_SIZE }} | |
steps: | |
- uses: taiki-e/checkout-action@v1 | |
- name: Checkout oxc (${{ inputs.ref }}) | |
uses: actions/checkout@v4 | |
with: | |
repository: oxc-project/oxc | |
ref: ${{ inputs.ref }} | |
path: oxc | |
- run: mv oxc ../oxc | |
- uses: Boshen/setup-rust@main | |
with: | |
save-cache: ${{ github.ref_name == 'main' }} | |
- run: cargo build --release | |
env: | |
RUSTFLAGS: "-C debug-assertions=true" | |
- name: export BINARY_SIZE | |
id: size | |
run: | | |
BINARY_SIZE=$(ls -l ./target/release/monitor-oxc | awk '{print $5}') | |
echo $BINARY_SIZE | |
echo "BINARY_SIZE=$BINARY_SIZE" >> $GITHUB_OUTPUT | |
- name: Upload Binary | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: monitor-oxc | |
path: ./target/release/monitor-oxc | |
# populate pnpm cache | |
- run: corepack enable | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: .node-version | |
cache: pnpm | |
- run: pnpm install | |
test: | |
name: Test | |
needs: build | |
timeout-minutes: 30 | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- command: codegen | |
- command: compressor | |
- command: transformer | |
- command: mangler | |
- command: whitespace | |
steps: | |
- uses: taiki-e/checkout-action@v1 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: monitor-oxc | |
- run: chmod +x ./monitor-oxc | |
- uses: pnpm/[email protected] | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: .node-version | |
cache: pnpm | |
- run: pnpm install | |
- run: ./monitor-oxc ${{ matrix.command }} | |
env: | |
RUST_BACKTRACE: "1" | |
compile-time: | |
name: Compile Time | |
runs-on: ubuntu-latest | |
if: ${{ github.ref_name == 'main' }} | |
outputs: | |
time: ${{ steps.run.outputs.COMPILE_TIME }} | |
steps: | |
- uses: taiki-e/checkout-action@v1 | |
- name: Checkout oxc | |
uses: actions/checkout@v4 | |
with: | |
repository: oxc-project/oxc | |
ref: main | |
path: oxc | |
- run: mv oxc ../oxc | |
- uses: Boshen/setup-rust@main | |
- run: cargo clean # build from scatch using local system cache to avoid download from crates.io | |
- id: run | |
run: | | |
/usr/bin/time -f "%e" -o output cargo build --release | |
cat output | |
COMPILE_TIME=$(cat output) | |
echo $COMPILE_TIME | |
echo "COMPILE_TIME=$COMPILE_TIME" >> $GITHUB_OUTPUT | |
monitor: | |
name: Monitor Metrics | |
needs: [build, compile-time] | |
if: ${{ github.ref_name == 'main' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: taiki-e/checkout-action@v1 | |
- name: Create Data | |
run: | | |
echo $(jq ".[0].value = ${{ needs.compile-time.outputs.time }}" metrics.json) > data.json | |
echo $(jq ".[1].value = ${{ needs.build.outputs.size }}" data.json) > data.json | |
cat data.json | |
- uses: benchmark-action/github-action-benchmark@v1 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
name: Oxc Metrics | |
tool: customSmallerIsBetter | |
output-file-path: data.json | |
gh-pages-branch: gh-pages | |
benchmark-data-dir-path: metrics | |
auto-push: true | |
save-data-file: true | |
isolated_declarations: | |
needs: build | |
name: Test Isolated Declarations | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: vuejs/core | |
ref: main | |
- uses: pnpm/[email protected] | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: .node-version | |
cache: pnpm | |
- run: pnpm install | |
- run: ./node_modules/.bin/tsc -p tsconfig.build.json --noCheck | |
- uses: actions/download-artifact@v4 | |
with: | |
name: monitor-oxc | |
- run: chmod +x ./monitor-oxc | |
- run: ./monitor-oxc id . | |
rolldown: | |
name: Rolldown | |
runs-on: ubuntu-latest | |
steps: | |
- uses: taiki-e/checkout-action@v1 | |
- uses: pnpm/[email protected] | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: .node-version | |
cache: pnpm | |
- run: pnpm install | |
- run: ./node_modules/.bin/rolldown --version | |
- run: node --run rolldown | |
test262: | |
name: Test262 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout oxc (${{ inputs.ref }}) | |
uses: actions/checkout@v4 | |
with: | |
repository: oxc-project/oxc | |
ref: ${{ inputs.ref }} | |
- uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
repository: tc39/test262 | |
path: tasks/coverage/test262 | |
ref: 0645461999632a17426e45d044ee519a0f07d022 | |
- uses: Boshen/setup-rust@main | |
with: | |
save-cache: ${{ github.ref_name == 'main' }} | |
cache-key: test262 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
- run: cargo coverage runtime | |
- run: git diff --exit-code | |
comment: | |
needs: [test, isolated_declarations] | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
name: Reply Comment | |
permissions: | |
pull-requests: write | |
contents: write | |
steps: | |
- uses: actions/github-script@v7 | |
id: script | |
if: ${{ inputs.issue-number }} | |
with: | |
github-token: ${{ secrets.OXC_BOT_PAT }} | |
result-encoding: string | |
script: | | |
const { | |
data: { jobs }, | |
} = await github.rest.actions.listJobsForWorkflowRun({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.runId, | |
per_page: 100, | |
}); | |
let result = jobs | |
.filter((job) => job.name.startsWith("Test ")) | |
.map((job) => { | |
const suite = job.name.slice(5); | |
return { suite, conclusion: job.conclusion, link: job.html_url }; | |
}); | |
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
const urlLink = `[Open](${url})`; | |
const conclusionEmoji = { | |
success: ":white_check_mark:", | |
failure: ":x:", | |
cancelled: ":stop_button:", | |
}; | |
const body = ` | |
## [Monitor Oxc](${urlLink}) | |
| suite | result | | |
|-------|--------| | |
${result.map((r) => `| [${r.suite}](${r.link}) | ${conclusionEmoji[r.conclusion]} |`).join("\n")} | |
`; | |
return body; | |
- uses: peter-evans/create-or-update-comment@v4 | |
if: ${{ inputs.issue-number && inputs.comment-id }} | |
with: | |
token: ${{ secrets.OXC_BOT_PAT }} | |
repository: oxc-project/oxc | |
issue-number: ${{ inputs.issue-number }} | |
comment-id: ${{ inputs.comment-id }} | |
body: ${{ steps.script.outputs.result }} | |
edit-mode: replace |