Skip to content

Commit

Permalink
feat(ci): simplify cache (#3448)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Feb 13, 2022
1 parent 759d1af commit 49955ea
Show file tree
Hide file tree
Showing 11 changed files with 322 additions and 283 deletions.
57 changes: 32 additions & 25 deletions .github/workflows/artifacts-updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ on:
- 'tooling/bundler/**'
- 'examples/updater/**'

env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.

jobs:
build-artifacs:
runs-on: ${{ matrix.platform }}
Expand Down Expand Up @@ -46,49 +51,51 @@ jobs:
if: matrix.platform == 'windows-latest'
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: Cache cargo registry
uses: actions/cache@v2.1.4
with:
path: ~/.cargo/registry
# Add date to the cache to keep it up to date
key: ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
${{ matrix.platform }}-stable-cargo-registry-
- name: Cache cargo index
uses: actions/cache@v2.1.4
- name: Cache cargo state
uses: actions/cache@v2
env:
cache-name: cargo-state
with:
path: ~/.cargo/git
# Add date to the cache to keep it up to date
key: ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
restore-keys: |
${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}
${{ matrix.platform }}-stable-cargo-index-
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
${{ matrix.platform }}-stable-${{ env.cache-name }}-
${{ matrix.platform }}-stable-
${{ matrix.platform }}-
- name: Cache core cargo target
uses: actions/cache@v2
env:
cache-name: cargo-core
with:
path: target
# Add date to the cache to keep it up to date
key: ${{ matrix.platform }}-stable-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.platform }}-stable-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}
${{ matrix.platform }}-stable-cargo-core-
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
${{ matrix.platform }}-stable-${{ env.cache-name }}-
${{ matrix.platform }}-stable-
${{ matrix.platform }}-
- name: Cache CLI cargo target
uses: actions/cache@v2
env:
cache-name: cargo-cli
with:
path: tooling/cli/target
# Add date to the cache to keep it up to date
key: ${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli/Cargo.lock') }}
${{ matrix.platform }}-stable-cargo-cli-
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}
${{ matrix.platform }}-stable-${{ env.cache-name }}-
${{ matrix.platform }}-stable-
${{ matrix.platform }}-
- name: build and install cli.rs
run: cargo install --path tooling/cli
Expand Down
73 changes: 40 additions & 33 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,36 @@ on:
- next
workflow_dispatch:

env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.

jobs:
bench:
strategy:
fail-fast: false
matrix:
rust_version: [stable]
rust: [nightly]
platform:
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }

runs-on: ${{ matrix.platform.os }}

steps:
- uses: actions/checkout@v2
- name: install nightly
- name: install ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: ${{ matrix.rust }}
override: true
components: rust-src
target: ${{ matrix.platform.target }}

- name: setup python
uses: actions/setup-python@v2
with:
python-version: "3.x"
python-version: '3.x'
architecture: x64

- name: install depedencies
Expand All @@ -46,65 +51,67 @@ jobs:
- name: Get current date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

- name: Cache cargo registry
uses: actions/cache@v2.1.4
with:
path: ~/.cargo/registry
# Add date to the cache to keep it up to date
key: ${{ matrix.platform }}-nightly-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.platform }}-nightly-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
${{ matrix.platform }}-nightly-cargo-registry-
- name: Cache cargo index
uses: actions/cache@v2.1.4
- name: Cache cargo state
uses: actions/cache@v2
env:
cache-name: cargo-state
with:
path: ~/.cargo/git
# Add date to the cache to keep it up to date
key: ${{ matrix.platform }}-nightly-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
restore-keys: |
${{ matrix.platform }}-nightly-cargo-index-${{ hashFiles('**/Cargo.toml') }}
${{ matrix.platform }}-nightly-cargo-index-
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
${{ matrix.platform }}-stable-${{ env.cache-name }}-
${{ matrix.platform }}-stable-
${{ matrix.platform }}-
- name: Cache core cargo target
uses: actions/cache@v2
env:
cache-name: cargo-core
with:
path: target
# Add date to the cache to keep it up to date
key: ${{ matrix.platform }}-nightly-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
key: ${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.platform }}-nightly-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}
${{ matrix.platform }}-nightly-cargo-core-
${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-
${{ matrix.platform }}-${{ matrix.rust }}-
${{ matrix.platform }}-
- name: cache cargo `tooling/bench/tests` target
uses: actions/cache@v2
env:
cache-name: cargo-benches
with:
path: tooling/bench/tests/target
# Add date to the cache to keep it up to date
key: ${{ matrix.platform }}-nightly-cargo-benches-${{ hashFiles('tooling/bench/tests/Cargo.lock') }}-${{ env.CURRENT_DATE }}
key: ${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-${{ hashFiles('tooling/bench/tests/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.platform }}-nightly-cargo-benches-${{ hashFiles('tooling/bench/tests/Cargo.lock') }}
${{ matrix.platform }}-nightly-cargo-benches-
${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-${{ hashFiles('tooling/bench/tests/Cargo.lock') }}
${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-
${{ matrix.platform }}-${{ matrix.rust }}-
${{ matrix.platform }}-
- name: run benchmarks
run: |
cargo +nightly build --release -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target ${{ matrix.platform.target }} --manifest-path tooling/bench/tests/Cargo.toml
cargo build --release -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target ${{ matrix.platform.target }} --manifest-path tooling/bench/tests/Cargo.toml
xvfb-run --auto-servernum cargo run --manifest-path tooling/bench/Cargo.toml --bin run_benchmark
- name: clone benchmarks_results
if: github.repository == 'tauri-apps/tauri' && github.ref == 'refs/heads/dev'
if: github.repository == 'tauri-apps/tauri' && github.ref == 'refs/heads/dev'
uses: actions/checkout@v2
with:
token: ${{ secrets.BENCH_PAT }}
path: gh-pages
repository: tauri-apps/benchmark_results

- name: push new benchmarks
if: github.repository == 'tauri-apps/tauri' && github.ref == 'refs/heads/dev'
if: github.repository == 'tauri-apps/tauri' && github.ref == 'refs/heads/dev'
run: |
cargo run --manifest-path tooling/bench/Cargo.toml --bin build_benchmark_jsons
cd gh-pages
Expand Down
49 changes: 26 additions & 23 deletions .github/workflows/lint-fmt-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ on:
- '.github/workflows/lint-fmt-cli.yml'
- 'tooling/cli/**'

env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.

jobs:
fmt_check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
profile: minimal
Expand Down Expand Up @@ -49,38 +54,36 @@ jobs:
- name: Get current date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

- name: Cache cargo registry
uses: actions/cache@v2.1.4
with:
path: ~/.cargo/registry
# Add date to the cache to keep it up to date
key: ubuntu-latest-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
ubuntu-latest-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
ubuntu-latest-stable-cargo-registry-
- name: Cache cargo index
uses: actions/cache@v2.1.4
- name: Cache cargo state
uses: actions/cache@v2
env:
cache-name: cargo-state
with:
path: ~/.cargo/git
# Add date to the cache to keep it up to date
key: ubuntu-latest-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
key: ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
restore-keys: |
ubuntu-latest-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}
ubuntu-latest-stable-cargo-index-
ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
ubuntu-latest-stable-${{ env.cache-name }}-
ubuntu-latest-stable-
ubuntu-latest-
- name: Cache CLI cargo target
uses: actions/cache@v2
env:
cache-name: cargo-cli
with:
path: tooling/cli/target
# Add date to the cache to keep it up to date
key: ubuntu-latest-stable-cargo-cli-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
key: ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
ubuntu-latest-stable-cargo-cli-${{ hashFiles('tooling/cli/Cargo.lock') }}
ubuntu-latest-stable-cargo-cli-
ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}
ubuntu-latest-stable-${{ env.cache-name }}-
ubuntu-latest-stable-
ubuntu-latest-
- uses: actions-rs/clippy-check@v1
with:
Expand Down
54 changes: 30 additions & 24 deletions .github/workflows/lint-fmt-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ on:
- 'core/**'
- 'examples/**'

env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.

jobs:
fmt_check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
profile: minimal
Expand All @@ -40,7 +45,10 @@ jobs:
matrix:
clippy:
- { args: '', key: 'empty' }
- { args: '--features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray', key: 'all' }
- {
args: '--features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray',
key: 'all'
}
- { args: '--no-default-features', key: 'no-default' }
- { args: '--features custom-protocol', key: 'custom-protocol' }
- { args: '--features api-all', key: 'api-all' }
Expand All @@ -67,38 +75,36 @@ jobs:
if: matrix.platform == 'windows-latest'
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: Cache cargo registry
uses: actions/cache@v2.1.4
with:
path: ~/.cargo/registry
# Add date to the cache to keep it up to date
key: ubuntu-latest-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
ubuntu-latest-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
ubuntu-latest-stable-cargo-registry-
- name: Cache cargo index
uses: actions/cache@v2.1.4
- name: Cache cargo state
uses: actions/cache@v2
env:
cache-name: cargo-state
with:
path: ~/.cargo/git
# Add date to the cache to keep it up to date
key: ubuntu-latest-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
key: ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
restore-keys: |
ubuntu-latest-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}
ubuntu-latest-stable-cargo-index-
ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
ubuntu-latest-stable-${{ env.cache-name }}-
ubuntu-latest-stable-
ubuntu-latest-
- name: Cache core cargo target
uses: actions/cache@v2
env:
cache-name: cargo-core
with:
path: target
# Add date to the cache to keep it up to date
key: ubuntu-latest-stable-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
key: ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
ubuntu-latest-stable-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}
ubuntu-latest-stable-cargo-core-
ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
ubuntu-latest-stable-${{ env.cache-name }}-
ubuntu-latest-stable-
ubuntu-latest-
- uses: actions-rs/clippy-check@v1
with:
Expand Down

0 comments on commit 49955ea

Please sign in to comment.