Skip to content

Use sccache in Github action #113

Use sccache in Github action

Use sccache in Github action #113

Workflow file for this run

name: Rust
on:
push:
branches: [ master, dev ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Cargo test (${{ matrix.rust }}) (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
rust: [stable, 1.72]
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/sccache-action@v0.0.3
- 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@v3
continue-on-error: false
with:
path: |
~/.cargo/registry
key: rust-${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-${{ steps.get-date.outputs.date }}-build
restore-keys: |
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
- name: Install rustfmt
run: |
rustup component add rustfmt
which rustfmt && rustfmt --version
- name: Build
run: |
cargo build --verbose
- name: Run tests
run: |
cargo test --verbose
- name: Install
run: |
cargo install --path .
- name: Package
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/sccache-action@v0.0.3
- 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@v3
continue-on-error: false
with:
path: |
~/.cargo/registry
key: rust-${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-${{ steps.get-date.outputs.date }}-build
restore-keys: |
rust-${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-
rust-${{ runner.os }}
- name: Build And Coverage
run: ./coverage.sh
- uses: actions/upload-artifact@v2
with:
name: coverage
path: ./coverage/
release:
needs: build
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/sccache-action@v0.0.3
- 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@v3
continue-on-error: false
with:
path: |
~/.cargo/registry
key: rust-${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-${{ steps.get-date.outputs.date }}-build
restore-keys: |
rust-${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-
rust-${{ runner.os }}
# End of rust template
# - name: Install toolkit
# run: cargo install cargo-bump
- name: Bump version
run: |
git config --global user.name 'Endle'
git config --global user.email 'Endle@users.noreply.github.com'
git branch --show-current
python3 --version
python3 bump_version.py
# - name: Push to Github and crates
# env:
# CRATES_SECRET: ${{ secrets.CRATES_ENDLE }}
# run: |
# if [[ -f "created_new_commit.success" ]]; then
# cat created_new_commit.success
# rm created_new_commit.success
# echo "Following https://stackoverflow.com/a/58393457/1166518"
# git push origin master
# cargo login "$CRATES_SECRET"
# cargo publish -v
# fi