Skip to content

Commit

Permalink
fix github actions rust caching
Browse files Browse the repository at this point in the history
  • Loading branch information
ForsakenHarmony committed Jan 4, 2023
1 parent 1fde122 commit d14034f
Show file tree
Hide file tree
Showing 15 changed files with 292 additions and 310 deletions.
28 changes: 16 additions & 12 deletions .github/actions/build-debug-turborepo/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,36 @@ runs:
steps:
- name: "Setup Node"
uses: ./.github/actions/setup-node

- name: "Setup Go"
uses: ./.github/actions/setup-go
with:
github-token: ${{ inputs.github-token }}
- name: "Setup Rust toolchain"
uses: actions-rs/toolchain@v1
if: ${{ inputs.target != 'windows' }}

- name: "Setup Rust"
uses: ./.github/actions/setup-rust
with:
shared-cache-key: turborepo-debug-build
save-cache: true

- name: "Set Windows default host to MingW"
if: ${{ inputs.target == 'windows' }}
shell: bash
run: rustup set default-host x86_64-pc-windows-gnu && rustup show
- name: "Setup Rust Cache"
uses: Swatinem/rust-cache@v2
with:
key: debug-${{ inputs.target }}
run: |
rustup set default-host x86_64-pc-windows-gnu && rustup show
- name: Build Turborepo
working-directory: ./cli
shell: bash
run: |
cd cli
make turbo
cd ..
- name: Strip Turborepo binary
if: ${{ inputs.target == 'windows' }}
shell: bash
run: strip target/debug/turbo.exe
if: ${{ inputs.target == 'windows' }}

- name: Strip Turborepo binary
if: ${{ inputs.target != 'windows' }}
shell: bash
run: strip target/debug/turbo
if: ${{ inputs.target != 'windows' }}
1 change: 1 addition & 0 deletions .github/actions/setup-go/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ inputs:
github-token:
description: "GitHub token. You can pass secrets.GITHUB_TOKEN"
required: true

runs:
using: "composite"
steps:
Expand Down
14 changes: 5 additions & 9 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ inputs:
enable-corepack:
description: "Control turning on corepack."
required: false
default: true
default: "true"
extra-flags:
description: "Extra flags to pass to the pnpm install."
required: false
default: ""
package-install:
description: "Don't run the install step."
required: false
default: true
default: "true"

runs:
using: "composite"
steps:
Expand All @@ -28,21 +29,16 @@ runs:
cache: pnpm

- name: Configure corepack
if: ${{ inputs.enable-corepack == 'true' }}
shell: bash
# Forcibly upgrade our available version of corepack.
# The bundled version in node 16 has known issues.
# Prepends the npm bin dir so that it is always first.
shell: bash
run: |
npm install --force --global corepack@latest
npm config get prefix >> $GITHUB_PATH
corepack enable
- name: Enable corepack
if: ${{ inputs.enable-corepack == 'true' }}
shell: bash
run: |
corepack enable
- name: pnpm install
id: install
if: ${{ inputs.package-install == 'true' }}
Expand Down
55 changes: 55 additions & 0 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: "Turbo Rust Setup"
description: "Sets up the Rust toolchain for CI"
inputs:
target:
description: "Compilation target"
required: true

targets:
description: "Comma-separated list of target triples to install for this toolchain"
required: false
components:
description: "Comma-separated list of components to be additionally installed"
required: false

shared-cache-key:
description: "A cache key that is used instead of the automatic `job`-based key, and is stable over multiple jobs."
required: false
cache-key:
description: "An additional cache key that is added alongside the automatic `job`-based cache key and can be used to further differentiate jobs."
required: false
save-cache:
description: "Determiners whether the cache should be saved. If `false`, the cache is only restored."
required: false
default: "false"

runs:
using: "composite"
steps:
- name: "Get toolchain version from file"
id: file
shell: bash
run: echo "toolchain=$(cat ./rust-toolchain)" >> $GITHUB_OUTPUT

- name: "Setup Rust toolchain"
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.file.outputs.toolchain }}
targets: ${{ inputs.targets }}
components: ${{ inputs.components }}

- name: "Set Windows default host to MingW"
if: ${{ inputs.target == 'windows' }}
shell: bash
run: rustup set default-host x86_64-pc-windows-gnu && rustup show

- name: "Setup Rust Cache"
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ inputs.shared-cache-key }}
key: ${{ inputs.cache-key }}
save-if: ${{ github.ref == 'refs/heads/main' && inputs.save-cache || "false" }}

- name: "Add problem matcher"
shell: bash
run: echo "::add-matcher::.github/actions/setup-rust/matchers.json"
44 changes: 44 additions & 0 deletions .github/actions/setup-rust/matchers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"problemMatcher": [
{
"owner": "cargo-common",
"pattern": [
{
"regexp": "^(warning|warn|error)(:?\\[(\\S*)\\])?: (.*)$",
"severity": 1,
"code": 2,
"message": 3
},
{
"regexp": "^\\s+-->\\s(\\S+):(\\d+):(\\d+)$",
"file": 1,
"line": 2,
"column": 3
}
]
},
{
"owner": "cargo-test",
"pattern": [
{
"regexp": "^.*panicked\\s+at\\s+'(.*)',\\s+(.*):(\\d+):(\\d+)$",
"message": 1,
"file": 2,
"line": 3,
"column": 4
}
]
},
{
"owner": "cargo-fmt",
"pattern": [
{
"regexp": "^(Diff in (\\S+)) at line (\\d+):",
"message": 1,
"file": 2,
"line": 3
}
]
}
]
}
55 changes: 30 additions & 25 deletions .github/workflows/bench-turbopack-scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,48 @@ jobs:
# This measures Next.js 13
- name: next 13
cache_key: next-dev
args: -p next-dev -- "(Turbopack SSR/1000|Next.js 13)"
cargo_args: -p next-dev
run_args: '"(Turbopack SSR/1000|Next.js 13)"'
TURBOPACK_BENCH_COUNTS: 100,500,1000
TURBOPACK_BENCH_BUNDLERS: all

# This measures Next.js 12
- name: next 12
cache_key: next-dev
args: -p next-dev -- "(Turbopack SSR/1000|Next.js 12)"
cargo_args: -p next-dev
run_args: '"(Turbopack SSR/1000|Next.js 12)"'
TURBOPACK_BENCH_COUNTS: 100,500,1000
TURBOPACK_BENCH_BUNDLERS: all

# This measures Next.js 11
- name: next 11
cache_key: next-dev
args: -p next-dev -- "(Turbopack SSR/1000|Next.js 11)"
cargo_args: -p next-dev
run_args: '"(Turbopack SSR/1000|Next.js 11)"'
TURBOPACK_BENCH_COUNTS: 100,500,1000
TURBOPACK_BENCH_BUNDLERS: all

# This measures Vite
- name: vite
cache_key: next-dev
args: -p next-dev -- "(Turbopack CSR/1000|Vite)"
cargo_args: -p next-dev
run_args: '"(Turbopack CSR/1000|Vite)"'
TURBOPACK_BENCH_COUNTS: 100,500,1000
TURBOPACK_BENCH_BUNDLERS: all

# This measures Parcel
- name: parcel
cache_key: next-dev
args: -p next-dev -- "(Turbopack CSR/1000|Parcel)"
cargo_args: -p next-dev
run_args: '"(Turbopack CSR/1000|Parcel)"'
TURBOPACK_BENCH_COUNTS: 100,500,1000
TURBOPACK_BENCH_BUNDLERS: all

# This measures Webpack
- name: webpack
cache_key: next-dev
args: -p next-dev -- "(Turbopack CSR/1000|Webpack)"
cargo_args: -p next-dev
run_args: '"(Turbopack CSR/1000|Webpack)"'
TURBOPACK_BENCH_COUNTS: 100,500,1000
TURBOPACK_BENCH_BUNDLERS: all

Expand All @@ -71,29 +77,28 @@ jobs:

- uses: ./.github/actions/setup-node

- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
with:
key: benchmark-${{ matrix.bench.cache_key }}
shared-key: benchmark-${{ matrix.bench.cache_key }}

- name: Clear benchmarks
- name: Clear potentially cached benchmarks
run: rm -rf target/criterion

- name: Build benchmarks
timeout-minutes: 120
run: cargo bench --no-run ${{ matrix.bench.cargo_args }}

- name: Run cargo bench
uses: actions-rs/cargo@v1
timeout-minutes: 180
env:
TURBOPACK_BENCH_BUNDLERS: ${{ matrix.bench.TURBOPACK_BENCH_BUNDLERS }}
TURBOPACK_BENCH_COUNTS: ${{ matrix.bench.TURBOPACK_BENCH_COUNTS }}
with:
command: bench
args: ${{ matrix.bench.args }}
run: cargo bench ${{ matrix.bench.cargo_args }} -- ${{ matrix.bench.run_args }}

- name: Install critcmp
if: always()
uses: actions-rs/cargo@v1
uses: baptiste0928/cargo-install@v1
with:
command: install
args: critcmp
crate: critcmp

- name: Compare results
if: always()
Expand All @@ -110,10 +115,6 @@ jobs:
name: ${{ matrix.bench.name }}
path: raw.json

# This avoids putting this data into the rust-cache
- name: Clear benchmarks
run: rm -rf target/criterion

commit_results:
name: Commit benchmark-data
needs: bench
Expand All @@ -122,20 +123,24 @@ jobs:
- name: Get current date
id: date
run: |
echo "::set-output name=year::$(date +'%Y')"
echo "::set-output name=month::$(date +'%m')"
echo "::set-output name=date::$(date +'%s')"
echo "::set-output name=pretty::$(date +'%Y-%m-%d %H:%M')"
echo "year=$(date +'%Y')" >> $GITHUB_OUTPUT
echo "month=$(date +'%m')" >> $GITHUB_OUTPUT
echo "date=$(date +'%s')" >> $GITHUB_OUTPUT
echo "pretty=$(date +'%Y-%m-%d %H:%M')" >> $GITHUB_OUTPUT
- name: Checkout benchmark-data
uses: actions/checkout@v3
with:
ref: benchmark-data

- name: Download benchmark data
uses: actions/download-artifact@v3
with:
path: data/${{ steps.date.outputs.year }}/${{ steps.date.outputs.month }}/ubuntu-latest-8-core/${{ steps.date.outputs.date }}-${{ github.sha }}

- name: Git pull
run: git pull --depth=1 --no-tags origin benchmark-data

- name: Push data to branch
uses: stefanzweifel/git-auto-commit-action@v4
with:
Expand Down
36 changes: 18 additions & 18 deletions .github/workflows/bench-turbotrace-against-node-nft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,37 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
with:
key: bench_nft

- uses: ./.github/actions/setup-node
with:
package-install: false

- name: Install dependencies
working-directory: crates/turbopack/tests/node-file-trace
run: |
echo 'node-linker = "hoisted"' > .npmrc
pnpm install -r --side-effects-cache false
- uses: ./.github/actions/setup-rust

- uses: ./.github/actions/setup-go
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Install hoisted npm dependencies
working-directory: crates/turbopack/tests/node-file-trace
run: |
echo 'node-linker = "hoisted"' > .npmrc
pnpm install -r --side-effects-cache false
- name: Install nextest
run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
shell: bash
uses: taiki-e/install-action@nextest

- name: Build benchmark
timeout-minutes: 60
run: |
cargo nextest run --no-run --release \
-p turbopack --features bench_against_node_nft bench_against_node_nft
- name: Run benchmark
uses: actions-rs/cargo@v1
timeout-minutes: 60
with:
command: nextest
args: run -j 1 --no-fail-fast -r -p turbopack --features bench_against_node_nft bench_against_node_nft
run: |
cargo nextest run --test-threads 1 --no-fail-fast --release \
-p turbopack --features bench_against_node_nft bench_against_node_nft
- name: Show benchmark result
uses: actions-rs/cargo@v1
with:
command: xtask
args: nft-bench-result
run: cargo xtask nft-bench-result

0 comments on commit d14034f

Please sign in to comment.