Skip to content

Commit

Permalink
chore(ci): use sccache
Browse files Browse the repository at this point in the history
Signed-off-by: Chawye Hsu <[email protected]>
  • Loading branch information
chawyehsu committed Jul 26, 2023
1 parent 8e558c3 commit 4f96c2e
Showing 1 changed file with 31 additions and 49 deletions.
80 changes: 31 additions & 49 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,36 @@ permissions:
contents: write
pull-requests: write
jobs:
# Check code style and tests
check_cargo_base:
name: Check Code Style
# format and lint check
style_check:
name: Code Style Check
runs-on: windows-latest
env:
SCCACHE_GHA_ENABLED: true
RUSTC_WRAPPER: sccache
steps:
- name: Checkout Source
uses: actions/checkout@v3

- name: Setup Rust
- name: Rust Setup
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
components: clippy, rustfmt

- name: Setup Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Setup
uses: mozilla-actions/[email protected]

- name: Format Check
run: cargo fmt -- --check

- name: Clippy Check
run: cargo clippy

- name: Tests Check
run: cargo test --workspace

# Check build
check_cargo_build:
name: Check Dev Build
needs: check_cargo_base
# tests and build
test_build:
name: Test Build
needs: style_check
strategy:
fail-fast: false
matrix:
Expand All @@ -56,35 +47,32 @@ jobs:
- target: i686-pc-windows-msvc
- target: aarch64-pc-windows-msvc
runs-on: windows-latest
env:
SCCACHE_GHA_ENABLED: true
RUSTC_WRAPPER: sccache
steps:
- name: Checkout Source
uses: actions/checkout@v3

- name: Setup Rust
- name: Rust Setup
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}

- name: Setup Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Setup
uses: mozilla-actions/[email protected]

- name: Tests Check
run: cargo test --workspace

- name: Build Check
run: cargo build --locked --target ${{ matrix.target }}

# Create/Update release PR
release_please:
name: Release Please
needs: check_cargo_build
needs: test_build
runs-on: ubuntu-latest
if: github.repository == 'chawyehsu/hok' && github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
Expand Down Expand Up @@ -121,27 +109,21 @@ jobs:

runs-on: ${{ matrix.os }}
continue-on-error: true
env:
SCCACHE_GHA_ENABLED: true
RUSTC_WRAPPER: sccache
steps:
- name: Checkout Source
uses: actions/checkout@v3

- name: Setup Rust
- name: Rust Setup
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}

- name: Setup Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Setup
uses: mozilla-actions/[email protected]

- name: Build
uses: actions-rs/[email protected]
Expand Down Expand Up @@ -186,7 +168,7 @@ jobs:

# Create GitHub release with Rust build targets and release notes
upload_artifacts:
name: Add Build Artifacts to Release
name: Create Release
needs: [release_please, github_build]
runs-on: ubuntu-latest
steps:
Expand All @@ -201,7 +183,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Add Artifacts to Release
- name: Attach Artifacts
uses: softprops/action-gh-release@v1
with:
files: hok-*/hok-*
Expand Down

0 comments on commit 4f96c2e

Please sign in to comment.