Skip to content

Commit

Permalink
Use sccache in Github action
Browse files Browse the repository at this point in the history
  • Loading branch information
Endle committed Sep 26, 2023
1 parent 8f7a46b commit 05f751f
Showing 1 changed file with 59 additions and 31 deletions.
90 changes: 59 additions & 31 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Rust

# Template Reference: https://www.infinyon.com/blog/2021/04/github-actions-best-practices/

on:
push:
branches: [ master, codeforce, dev ]
branches: [ master, dev ]
pull_request:
branches: [ master, codeforce ]
branches: [ master ]

env:
CARGO_TERM_COLOR: always
Expand All @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
rust: [stable, 1.56, 1.61]
rust: [stable, 1.72]
steps:
- uses: actions/checkout@v2
- name: Install Rust ${{ matrix.rust }}
Expand All @@ -27,19 +27,23 @@ jobs:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash
- name: Cache cargo registry
uses: actions/cache@v2
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-build
key: rust-${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-${{ steps.get-date.outputs.date }}-build
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-
${{ runner.os }}-cargo-${{ matrix.rust }}-
${{ runner.os }}-cargo-
rust-${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-
rust-${{ runner.os }}
# Real tests starts here
- name: Check version
run: rustup --version && rustc --version && cargo --version
Expand All @@ -48,36 +52,56 @@ jobs:
rustup component add rustfmt
which rustfmt && rustfmt --version
- name: Build
run: cargo build --verbose
run: |
cargo build --verbose
- name: Run tests
run: cargo test --verbose
run: |
cargo test --verbose
- name: Install
run: cargo install --path .
run: |
cargo install --path .
- name: Package
run: cargo package --verbose
run: |
cargo package --verbose
- name: clippy
if: matrix.os == 'ubuntu-latest'
run: |
rustup component add clippy
cargo clippy
- name: Run sccache stat for check
shell: bash
run: ${SCCACHE_PATH} --show-stats




coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash
- name: Cache cargo registry
uses: actions/cache@v2
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-coverage
key: rust-${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-${{ steps.get-date.outputs.date }}-build
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-
${{ runner.os }}-cargo-${{ matrix.rust }}-
${{ runner.os }}-cargo-
- uses: actions/checkout@v2
rust-${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-
rust-${{ runner.os }}
- name: Build And Coverage
run: ./coverage.sh
- uses: actions/upload-artifact@v2
Expand All @@ -90,25 +114,29 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust stable
- name: Install Rust ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash
- name: Cache cargo registry
uses: actions/cache@v2
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-stable-${{ hashFiles('**/Cargo.toml') }}-release
key: rust-${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-${{ steps.get-date.outputs.date }}-build
restore-keys: |
${{ runner.os }}-cargo-stable-${{ hashFiles('**/Cargo.toml') }}-
${{ runner.os }}-cargo-stable-
${{ runner.os }}-cargo-
rust-${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-
rust-${{ runner.os }}
# End of rust template
# - name: Install toolkit
# run: cargo install cargo-bump
Expand Down

0 comments on commit 05f751f

Please sign in to comment.