-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workflow caching with nix & faster pre-commit hook (#1929)
* workflow: caching using mk-cache-key.nix and github cache This allows testing same code only once. - composite action: .github/actions/setup-workflow-base/action.yml - caching enalbed workflows: - ethereum-contracts - sdk-core - solidity-semantic-money - spec-haskell - hot-fuzz - automations - subgraph * new pre-commit hook - remove pre-commit script from all workflows, - instead, putting workflow filtering in the pre-commit hook.
- Loading branch information
Showing
50 changed files
with
700 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Setup Workflow Base | ||
description: > | ||
This sets up the base for a workflow, where: | ||
- nix is installed, | ||
- cache is looked up, | ||
- and nix dev shell is setup if cache is missed. | ||
inputs: | ||
package-name: | ||
description: Name of the package where input files are from | ||
required: true | ||
cache-key-prefix: | ||
description: Cache key prefix to attach to the calculated input files hash | ||
required: true | ||
dev-shell-name: | ||
description: Default shell to be used | ||
|
||
outputs: | ||
cache-hit: | ||
value: ${{ steps.cache.outputs.cache-hit }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: DeterminateSystems/nix-installer-action@v13 | ||
|
||
- name: Load the half-board nix module | ||
id: hb | ||
run: | | ||
./tasks/mk-cache-key.sh ./packages/${{ inputs.package-name }} > cache.json | ||
jq . cache.json | ||
key_prefix="${{ inputs.cache-key-prefix }}" | ||
path=$(jq '.outputs | join("\n")' cache.json) | ||
hash=$(jq -r .hash cache.json) | ||
echo "path=$path" >> "$GITHUB_OUTPUT" | ||
echo "key=${key_prefix}${hash}" >> "$GITHUB_OUTPUT" | ||
shell: nix develop .#mk-cache-key -c bash -xe {0} | ||
|
||
- name: Lookup cache | ||
id: cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ fromJSON(steps.hb.outputs.path) }} | ||
key: ${{ steps.hb.outputs.key }} | ||
|
||
- name: Initialize nix dev shell | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: | | ||
node --version | ||
yarn --version | ||
shell: nix develop .#${{ inputs.dev-shell-name }} -c bash -xe {0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.