Skip to content

Commit

Permalink
ci: add action for cached-install of wash
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Heywood <[email protected]>
  • Loading branch information
lachieh authored and brooksmtownsend committed Dec 31, 2024
1 parent 2ad4247 commit 53b1fff
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 55 deletions.
44 changes: 44 additions & 0 deletions .github/actions/install-cached-wash-cli/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Install Cached Wash CLI

description: |
This action will install the Wash CLI from a given repository and revision. If there are no changes that might affect the build, the action will build and install the Wash CLI from the current commit. Otherwise, it will build and install the Wash CLI from the base ref.
runs:
using: composite
steps:
- name: Check for changes that might affect the build for wash
if: ${{ github.event_name == 'pull_request' }}
# It'd be a little nicer if we calculated if wash was affected by the changes, but this will do for now
id: changed-files
uses: tj-actions/changed-files@bab30c2299617f6615ec02a68b9a40d10bd21366 # v45.0.5
with:
files_ignore: |
adr/**
brand/**
examples/**
**/*.md
- name: Set wash revision to build/cache
id: base-ref
shell: bash
run: |
# Determine the revision to build from
if [ ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha }} == null ]; then
echo "No base ref, building from the current commit"
REVISION=${{ github.sha }}
elif [ ${{ steps.changed-files.outputs.all_changed_and_modified_files_count }} -eq 0 ]; then
echo "Something changed that might affect the build, building from the current commit"
REVISION=${{ github.sha }}
else
echo "Building from the base ref"
REVISION=${{ github.event.pull_request.base.sha }}
fi
echo "target_revision=$REVISION" >> $GITHUB_OUTPUT
echo "Using $REVISION as the target revision"
- name: Build wash
uses: taiki-e/cache-cargo-install-action@caa6f48d18d42462f9c30df89e2b4f71a42b7c2c # v2.0.1
with:
tool: wash-cli
git: https://github.com/${{ github.repository }}
rev: ${{ steps.base-ref.outputs.target_revision }}
6 changes: 1 addition & 5 deletions .github/actions/wasm-lang-toolchain-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,4 @@ runs:

- name: install wash (current)
if: ${{ inputs.wash-version && inputs.wash-version == 'current' }}
uses: taiki-e/cache-cargo-install-action@caa6f48d18d42462f9c30df89e2b4f71a42b7c2c # v2.0.1
with:
tool: wash-cli
git: https://github.com/${{ github.repository }}
rev: ${{ github.sha }}
uses: ./.github/actions/install-cached-wash-cli
29 changes: 5 additions & 24 deletions .github/workflows/examples-components.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,37 +60,18 @@ env:
CARGO_TERM_COLOR: always

jobs:
build-wash-cli:
name: build wash-cli (${{ matrix.wash-version }})
# build/cache wash-cli so following steps can use the cached version
prepare-wash-cache:
runs-on: ubuntu-22.04
strategy:
matrix:
wash-version:
# NOTE(2024/10/23): we need to use the current version of wash *only*
# due to all the new WIT package retrieval goodness
#
# Once a new version of wash is out we can use prebuilt versions again (>= 35.0)
- current
steps:
- name: install wash (${{ matrix.wash-version }})
if: ${{ matrix.wash-version && matrix.wash-version != 'current' }}
uses: taiki-e/install-action@acd25891978b4cdaebd139d3efef606d26513b14 # v2.47.0
with:
tool: wash@${{ matrix.wash-version }}

- name: install wash (current)
if: ${{ matrix.wash-version && matrix.wash-version == 'current' }}
uses: taiki-e/cache-cargo-install-action@caa6f48d18d42462f9c30df89e2b4f71a42b7c2c # v2.0.1
with:
tool: wash-cli
git: https://github.com/${{ github.repository }}
rev: ${{ github.sha }}
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ./.github/actions/install-cached-wash-cli

# Ensure that `wash build` and `wash app validate` works for all example projects below
wash-build:
name: ${{ matrix.project.folder }}:${{ matrix.project.lang_version && format('{0}@{1}', matrix.project.lang, matrix.project.lang_version) || matrix.project.lang }} (wash@${{ matrix.wash-version }})
runs-on: ubuntu-22.04
needs: [build-wash-cli]
needs: [prepare-wash-cache]
strategy:
fail-fast: false
matrix:
Expand Down
32 changes: 6 additions & 26 deletions .github/workflows/examples-providers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,18 @@ env:
CARGO_TERM_COLOR: always

jobs:
build-wash-cli:
name: build wash-cli (${{ matrix.wash-version }})
# build/cache wash-cli so following steps can use the cached version
prepare-wash-cache:
runs-on: ubuntu-22.04
strategy:
matrix:
wash-version:
- 0.37.0
- current
steps:
- name: install wash (${{ matrix.wash-version }})
if: ${{ matrix.wash-version && matrix.wash-version != 'current' }}
uses: taiki-e/install-action@acd25891978b4cdaebd139d3efef606d26513b14 # v2.47.0
with:
tool: wash@${{ matrix.wash-version }}

- name: install wash (current)
if: ${{ matrix.wash-version && matrix.wash-version == 'current' }}
uses: taiki-e/cache-cargo-install-action@caa6f48d18d42462f9c30df89e2b4f71a42b7c2c # v2.0.1
with:
tool: wash-cli
git: https://github.com/${{ github.repository }}
rev: ${{ github.sha }}
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ./.github/actions/install-cached-wash-cli

# Ensure that `wash build` and `wash app validate` works for all example projects below
wash-build:
name: ${{ matrix.project.name }}:${{ matrix.project.lang_version && format('{0}@{1}', matrix.project.lang, matrix.project.lang_version) || matrix.project.lang }} (wash@${{ matrix.wash-version }})
runs-on: ubuntu-22.04
needs: [build-wash-cli]
needs: [prepare-wash-cache]
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -85,11 +69,7 @@ jobs:

- name: install wash (current)
if: ${{ matrix.wash-version && matrix.wash-version == 'current' }}
uses: taiki-e/cache-cargo-install-action@caa6f48d18d42462f9c30df89e2b4f71a42b7c2c # v2.0.1
with:
tool: wash-cli
git: https://github.com/${{ github.repository }}
rev: ${{ github.sha }}
uses: ./.github/actions/install-cached-wash-cli

# Language specific setup
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
Expand Down

0 comments on commit 53b1fff

Please sign in to comment.