[WIP] github actions rust cache (#131)

* add cache ext

* shorten artifact name

* cache rust cargo home

see https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci

* star artifact, relative rust cache

* forgot to relative prod rust cache

* seriously need one step per cache dir?

* forgot to fix artifact name

* likely need different key for each cache

* globs don't yet work, hardcode for now

* add releaseFolder option

MacOS has deeper folder structure than the others

* missed closing quote

* fix ubuntu artifact path

* use cargo home for cache dir

* set cargo home env

* try relative path?

* scrap env, use matrix

* wish it wasn't so verbose

* tilde

* cache rust based on hashed cargo.lock
This commit is contained in:
Jacob Bolda 2019-12-04 13:24:27 -06:00 committed by nothingismagick
parent 6d6179ff67
commit ca614e87ea
1 changed files with 52 additions and 5 deletions

View File

@ -12,15 +12,37 @@ jobs:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
example: [gatsby/themed-site, vue/quasar-app]
include:
- platform: ubuntu-latest
CARGO_HOME: ~/.cargo
- platform: macos-latest
CARGO_HOME: ~/.cargo
- platform: windows-latest
CARGO_HOME: ~/.cargo
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 3
- name: install stable
- name: install rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: cache rust bin
uses: actions/cache@v1
with:
path: ${{ format('{0}/bin/', matrix.CARGO_HOME) }}
key: ${{ runner.OS }}-build-bin-${{ hashFiles('**/Cargo.lock') }}-
- name: cache rust registry/index
uses: actions/cache@v1
with:
path: ${{ format('{0}/registry/index/', matrix.CARGO_HOME) }}
key: ${{ runner.OS }}-build-reg-index-${{ hashFiles('**/Cargo.lock') }}-
- name: cache rust registry/cache
uses: actions/cache@v1
with:
path: ${{ format('{0}/registry/cache/', matrix.CARGO_HOME) }}
key: ${{ runner.OS }}-build-reg-cache-${{ hashFiles('**/Cargo.lock') }}-
- run: cargo install tauri-cli
- name: cache node modules
uses: actions/cache@v1
@ -59,14 +81,24 @@ jobs:
folder: vue/quasar-app
executable: app
include:
- platform: ubuntu-latest
CARGO_HOME: ~/.cargo
releaseFolder: target/release/bundle/deb
ext: _0.1.0_amd64.deb
- platform: macos-latest
CARGO_HOME: ~/.cargo
releaseFolder: target/release/bundle/osx
ext: .app
- platform: windows-latest
ext: .exe
CARGO_HOME: ~/.cargo
releaseFolder: target/release
ext: .x86.msi
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 3
- name: install stable
- name: install rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
@ -75,6 +107,21 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.0
- name: cache rust bin
uses: actions/cache@v1
with:
path: ${{ format('{0}/bin/', matrix.CARGO_HOME) }}
key: ${{ runner.OS }}-build-bin-${{ hashFiles('**/Cargo.lock') }}-
- name: cache rust registry/index
uses: actions/cache@v1
with:
path: ${{ format('{0}/registry/index/', matrix.CARGO_HOME) }}
key: ${{ runner.OS }}-build-reg-index-${{ hashFiles('**/Cargo.lock') }}-
- name: cache rust registry/cache
uses: actions/cache@v1
with:
path: ${{ format('{0}/registry/cache/', matrix.CARGO_HOME) }}
key: ${{ runner.OS }}-build-reg-cache-${{ hashFiles('**/Cargo.lock') }}-
- name: build rust
run: cargo build
env:
@ -108,5 +155,5 @@ jobs:
- uses: actions/upload-artifact@v1
if: success()
with:
name: tauri built ${{ matrix.example.name }} on ${{ matrix.platform }}
path: ./examples/${{ matrix.example.folder }}/src-tauri/target/release/${{ matrix.example.executable }}${{ matrix.ext }}
name: ${{ matrix.example.name }}(${{ matrix.platform }})
path: ${{ format('./examples/{0}/src-tauri/{1}/{2}{3}', matrix.example.folder, matrix.releaseFolder, matrix.example.executable, matrix.ext ) }}