Skip to content

Commit

Permalink
chore: divide workflows into reusable pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
steveluscher committed Mar 7, 2024
1 parent c732fad commit 71ac4c1
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 77 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/checkout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Checkout
description: Clones the repository at ${{ github.sha }}

runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v4
47 changes: 9 additions & 38 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,18 @@ env:
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

jobs:
build:
build-and-publish-to-npm:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install package manager
uses: pnpm/action-setup@v2
with:
version: 8.6.1

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Get Test Validator Latest Release
id: get-test-validator-version
run: |
echo "version=$(./scripts/get-latest-validator-release-version.sh)" >> $GITHUB_OUTPUT
shell: bash

- name: Cache Test Validator
id: cache-test-validator
uses: actions/cache@v3
with:
path: .solana
key: ${{ runner.os }}-test-validator-${{ steps.get-test-validator-version.outputs.version }}

- name: Install Test Validator
if: steps.cache-test-validator.outputs.cache-hit != 'true'
run: scripts/setup-test-validator.sh
- uses: ./.github/workflows/install-dependencies.yml
- uses: ./.github/workflows/validator-setup.yml

- name: Start Test Validator
id: test-validator
run: |
./scripts/start-shared-test-validator.sh &
echo "TEST_VALIDATOR_PID=$!" >> "$GITHUB_OUTPUT"
run: ./scripts/start-shared-test-validator.sh &

- name: Publish NPM
run: |
Expand All @@ -69,9 +39,10 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Stop Test Validator
run: kill ${{ steps.test-validator.outputs.TEST_VALIDATOR_PID}}

deploy-docs:
needs: build-and-publish-to-npm
runs-on: ubuntu-latest
steps:
- name: Deploy Github Page
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/install-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Install Dependencies
description: Sets up Node and its package manager, then installs all dependencies

runs:
using: composite
steps:
- name: Install package manager
uses: pnpm/action-setup@v2
with:
version: 8.6.1

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'

- name: Install dependencies
run: pnpm install
44 changes: 5 additions & 39 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
# Needed for grouping check-web3 strategies into one check for mergify
all-web3-checks:
runs-on: ubuntu-latest
needs:
- build-and-test
needs: build-and-test
steps:
- run: echo "Done"

Expand All @@ -33,51 +32,18 @@ jobs:
name: Build & Test on Node ${{ matrix.node }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install package manager
uses: pnpm/action-setup@v2
with:
version: 8.6.1

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Get Test Validator Latest Release
id: get-test-validator-version
run: |
echo "version=$(./scripts/get-latest-validator-release-version.sh)" >> $GITHUB_OUTPUT
shell: bash

- name: Cache Test Validator
id: cache-test-validator
uses: actions/cache@v3
with:
path: .solana
key: ${{ runner.os }}-test-validator-${{ steps.get-test-validator-version.outputs.version }}

- name: Install Test Validator
if: steps.cache-test-validator.outputs.cache-hit != 'true'
run: scripts/setup-test-validator.sh
- uses: ./.github/workflows/install-dependencies.yml
- uses: ./.github/workflows/validator-setup.yml

- name: Start Test Validator
id: test-validator
run: |
./scripts/start-shared-test-validator.sh &
echo "TEST_VALIDATOR_PID=$!" >> "$GITHUB_OUTPUT"
run: ./scripts/start-shared-test-validator.sh &

- name: Build & Test
run: pnpm build --concurrency=100%

- name: Stop Test Validator
run: kill ${{ steps.test-validator.outputs.TEST_VALIDATOR_PID}}

- name: Upload Experimental library build artifacts
if: matrix.node == 'current'
uses: actions/upload-artifact@v3
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/validator-setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Install Solana Test Validator
description: Downloads and caches an install of the latest Solana Test Validator

runs:
using: composite
steps:
- name: Get Test Validator Latest Release
id: get-test-validator-version
run: echo "version=$(./scripts/get-latest-validator-release-version.sh)" >> $GITHUB_OUTPUT
shell: bash

- name: Cache Test Validator
id: cache-test-validator
uses: actions/cache@v3
with:
path: .solana
key: ${{ runner.os }}-test-validator-${{ steps.get-test-validator-version.outputs.version }}

- name: Install Test Validator
if: steps.cache-test-validator.outputs.cache-hit != 'true'
run: scripts/setup-test-validator.sh

0 comments on commit 71ac4c1

Please sign in to comment.