Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

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 f61023a
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 79 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
65 changes: 27 additions & 38 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,36 @@ env:
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
checkout:
uses: ./.github/workflows/checkout.yml
secrets: inherit

- name: Install package manager
uses: pnpm/action-setup@v2
with:
version: 8.6.1
install-dependencies:
uses: ./.github/workflows/install-dependencies.yml
needs: checkout
secrets: inherit

- 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
setup-validator:
needs: checkout
uses: ./.github/workflows/validator-setup.yml
secrets: inherit

- name: Cache Test Validator
id: cache-test-validator
uses: actions/cache@v3
build-and-publish-to-npm:
needs:
- checkout
- install-dependencies
- setup-validator
runs-on: ubuntu-latest
steps:
- name: Download Repository
uses: actions/download-artifact@v4
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
pattern: repository-*
merge-multiple: true

- 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 +57,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
46 changes: 5 additions & 41 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 @@ -32,52 +31,17 @@ jobs:

name: Build & Test on Node ${{ matrix.node }}
steps:
- name: Checkout
uses: actions/checkout@v3

- 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/checkout.yml
- 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 f61023a

Please sign in to comment.