Skip to content

Commit

Permalink
ci: use sccache
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Apr 7, 2023
1 parent 024f1a1 commit aa2a183
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 37 deletions.
22 changes: 22 additions & 0 deletions .github/actions/rustup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ inputs:
default: false
required: false
type: boolean
cache:
default: true
required: false
type: boolean
shared-key:
default: ''
required: false
type: string
sccache:
default: true
required: false
type: boolean

runs:
using: composite
Expand Down Expand Up @@ -52,3 +64,13 @@ runs:
- name: Install
shell: bash
run: rustup show

- name: sccache-cache
if: ${{ inputs.sccache == 'true' }}
uses: mozilla-actions/sccache-action@v0.0.3

- name: Swatinem/rust-cache
if: ${{ inputs.cache == 'true' }}
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ inputs.shared_key }}
30 changes: 16 additions & 14 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@ name: Benchmark
on:
workflow_dispatch:
pull_request:
paths:
- './github/workflow/benchmark.yml'
- 'crates/oxc_parser/**'
- 'crates/oxc_ast/**'
- 'crates/oxc_semantic/**'
- 'tasks/benchmark/**'
- 'rust-toolchain.toml'
- '!**/*.md'
# paths:
# - './github/workflow/benchmark.yml'
# - 'crates/oxc_parser/**'
# - 'crates/oxc_ast/**'
# - 'crates/oxc_semantic/**'
# - 'tasks/benchmark/**'
# - 'rust-toolchain.toml'
# - '!**/*.md'

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

env:
CARGO_TERM_QUIET: true
# CARGO_TERM_QUIET: true
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"

jobs:
benchmark:
Expand All @@ -32,11 +34,8 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install Rust Toolchain
- name: Install Rust on PR
uses: ./.github/actions/rustup

- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: benchmark

Expand All @@ -58,8 +57,11 @@ jobs:
clean: false
ref: main

- name: Install Rust Toolchain
- name: Install Rust on Main
uses: ./.github/actions/rustup
with:
cache: false
sccache: false

- name: Compile
run: cargo build --release -p oxc_benchmark
Expand Down
49 changes: 26 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,24 @@ on:
push:
branches:
- main
paths:
- 'crates/**'
- 'tasks/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'rust-toolchain.toml'
- '!**/*.md'
- sccache
# paths:
# - 'crates/**'
# - 'tasks/**'
# - 'Cargo.toml'
# - 'Cargo.lock'
# - 'rust-toolchain.toml'
# - '!**/*.md'

# cancel previous job runs for the same workflow + pr
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_QUIET: true
# CARGO_TERM_QUIET: true
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"

jobs:
format:
Expand All @@ -37,10 +40,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Install Rust Toolchain
- name: Install Rust
uses: ./.github/actions/rustup
with:
fmt: true
shared-key: ci

- name: Run rustfmt
run: cargo fmt --all -- --check
Expand All @@ -52,15 +56,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Install Rust Toolchain
- name: Install Rust
uses: ./.github/actions/rustup
with:
clippy: true

- name: Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: check
shared-key: ci

- name: Run cargo check
run: cargo check --workspace --all-targets --all-features --release --locked
Expand All @@ -78,14 +78,20 @@ jobs:
files: .

check-dependencies:
name: Check Dependencies
name: Check Unused Dependencies
runs-on: ubuntu-latest
env:
SCCACHE_GHA_ENABLED: ""
RUSTC_WRAPPER: ""
steps:
- name: Checkout PR Branch
uses: actions/checkout@v3

- name: Install Rust Toolchain
- name: Install Rust
uses: ./.github/actions/rustup
with:
shared-key: ci
sccache: false

- name: Install cargo-udeps
uses: taiki-e/install-action@v2
Expand All @@ -109,19 +115,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Install Rust Toolchain
- name: Install Rust
uses: ./.github/actions/rustup
with:
shared-key: ci

- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest

- name: Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: check

- name: Build tests
run: cargo nextest run --no-run --locked

Expand Down

0 comments on commit aa2a183

Please sign in to comment.