Skip to content

Commit

Permalink
ci: Rework Cargo and Yarn caching. (#87)
Browse files Browse the repository at this point in the history
* Add caching.

* Move around.

* Log dir.

* Add restore keys.

* Fix keys.

* More.

* More.

* Polish.
  • Loading branch information
milesj authored Apr 16, 2022
1 parent 01b80e1 commit fcb70d0
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 31 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,30 @@ jobs:
with:
fetch-depth: 0
- uses: actions/cache@v3
name: Cache cargo
with:
path: |
~/.cargo/bin
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- uses: actions/cache@v3
name: Cache node modules
with:
path: |
~/.yarn/cache
./.yarn/install-state.gz
~/.yarn
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- uses: actions/cache@v3
name: Cache moon toolchain
with:
path: ~/.moon/tools
key: ${{ runner.os }}-moon
key:
${{ runner.os }}-moon-node@${{ matrix.node-version }}-${{
hashFiles('.moon/workspace.yml') }}
restore-keys: ${{ runner.os }}-moon-node@${{ matrix.node-version }}-
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.60.0
Expand All @@ -40,3 +49,5 @@ jobs:
with:
command: run
args: -- --logLevel trace ci
env:
MOON_NODE_VERSION: ${{ matrix.node-version }}
16 changes: 14 additions & 2 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/cache@v3
name: Cache node modules
with:
cache: yarn
path: |
~/.yarn
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- run: yarn install --immutable
- run: yarn run build
version:
Expand All @@ -20,6 +26,12 @@ jobs:
with:
fetch-depth: 0
- uses: actions/setup-node@v3
- uses: actions/cache@v3
name: Cache node modules
with:
cache: yarn
path: |
~/.yarn
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- run: yarn version check
9 changes: 8 additions & 1 deletion .github/workflows/release-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: yarn
check-latest: true
node-version: 16
- uses: actions/cache@v3
name: Cache node modules
with:
path: |
~/.yarn
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install
- name: Build packages
Expand Down
71 changes: 46 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,27 @@ jobs:
- uses: actions/setup-node@v3
with:
architecture: ${{ matrix.arch }}
cache: yarn
check-latest: true
node-version: 16
- uses: actions/cache@v3
name: Cache cargo
with:
path: |
~/.cargo/bin
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
target: ${{ matrix.target }}
toolchain: stable
- name: Generate lockfile
uses: actions-rs/cargo@v1
- uses: actions-rs/cargo@v1
name: Generate lockfile
with:
command: generate-lockfile
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ matrix.target }}-node@16-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ matrix.target }}-node@16-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Setup toolchain
if: ${{ matrix.setup }}
run: ${{ matrix.setup }}
Expand All @@ -85,8 +83,8 @@ jobs:
BINARY: ${{ matrix.binary }}
TARGET: ${{ matrix.target }}
RUSTFLAGS: '-C strip=symbols'
- name: Upload artifact
uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v2
name: Upload artifact
with:
name: binary-${{ matrix.target }}
path: ${{ matrix.binary }}
Expand Down Expand Up @@ -116,18 +114,34 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: yarn
check-latest: true
node-version: 16
- name: Download artifacts
uses: actions/download-artifact@v2
- uses: actions/cache@v3
name: Cache cargo
with:
path: |
~/.cargo/bin
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- uses: actions/cache@v3
name: Cache node modules
with:
path: |
~/.yarn
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- uses: actions/download-artifact@v2
name: Download artifacts
with:
path: artifacts
- name: Sync artifact binaries
run: node ./scripts/release/syncArtifacts.mjs
shell: bash
- name: Install dependencies
run: yarn install
run: yarn install --immutable
- name: List packages
run: ls -R ./packages/core-linux-* ./packages/core-macos-* ./packages/core-windows-*
shell: bash
Expand All @@ -149,13 +163,20 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: yarn
check-latest: true
node-version: 16
- uses: actions/cache@v3
name: Cache node modules
with:
path: |
~/.yarn
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install
- name: Download artifacts
uses: actions/download-artifact@v2
run: yarn install --immutable
- uses: actions/download-artifact@v2
name: Download artifacts
with:
path: artifacts
- name: Sync artifact binaries
Expand All @@ -171,8 +192,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# TODO changelog
- name: Create GitHub release
uses: softprops/action-gh-release@v1
- uses: softprops/action-gh-release@v1
name: Create GitHub release
with:
fail_on_unmatched_files: true
files: artifacts/release/*
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
name: Cache cargo
with:
path: |
~/.cargo/bin
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.60.0
Expand All @@ -35,11 +38,14 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
name: Cache cargo
with:
path: |
~/.cargo/bin
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.60.0
Expand All @@ -59,11 +65,14 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
name: Cache cargo
with:
path: |
~/.cargo/bin
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.60.0
Expand Down

0 comments on commit fcb70d0

Please sign in to comment.