Skip to content

Commit

Permalink
🪚 Composite actions (LayerZero-Labs#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista authored Jan 5, 2024
1 parent 1885df4 commit 597a7b4
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 84 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/actions/install-dependencies/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Install project dependencies
description: Install everything we need to build this repo
inputs:
NPM_TOKEN:
description: "NPM_TOKEN that grants permissions to private @layerzerolabs packages"
required: true
runs:
using: "composite"
steps:
# Fetch the dependencies without running the post-install scripts
- name: Fetch Dependencies
shell: bash
run: pnpm fetch --frozen-lockfile --prefer-offline --ignore-scripts
env:
NPM_TOKEN: ${{ inputs.NPM_TOKEN }}

# Install the dependencies and run the post-install scripts
- name: Install Dependencies
shell: bash
run: pnpm install --frozen-lockfile --offline
27 changes: 27 additions & 0 deletions .github/workflows/actions/setup-build-cache/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Setup build cache
description: Setup cache for turbo builds & hardhat compilers
runs:
using: "composite"
steps:
# Cache build artifacts from turbo
#
# This step will speed up workflow runs that don't touch the whole codebase
# (or the ones that don't touch the codebase at all)
- name: Cache turbo build setup
uses: actions/cache@v3
with:
path: node_modules/.cache/turbo
key: ${{ runner.os }}-turbo-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-turbo-
# Cache hardhat compilers
#
# This step will speed up workflow runs that use hardhat compilation
- name: Cache hardhat compilers
uses: actions/cache@v3
with:
path: .cache/hardhat
key: ${{ runner.os }}-hardhat-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-hardhat-
16 changes: 16 additions & 0 deletions .github/workflows/actions/setup-environment/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Setup environment
description: Setup node & package manager, checkout code
runs:
using: "composite"
steps:
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "pnpm"
49 changes: 8 additions & 41 deletions .github/workflows/reusable-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,19 @@ jobs:
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout repo
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: Setup environment
uses: ./.github/workflows/actions/setup-environment

- name: Setup Node.js
uses: actions/setup-node@v3
- name: Install dependencies
uses: ./.github/workflows/actions/install-dependencies
with:
node-version-file: ".nvmrc"
cache: "pnpm"

# Fetch the dependencies without running the post-install scripts
- name: Fetch Dependencies
run: pnpm fetch --frozen-lockfile --prefer-offline --ignore-scripts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# Install the dependencies and run the post-install scripts
- name: Install Dependencies
run: pnpm install --frozen-lockfile --offline

# Cache build artifacts from turbo
#
# This step will speed up workflow runs that don't touch the whole codebase
# (or the ones that don't touch the codebase at all)
- name: Cache turbo build setup
uses: actions/cache@v3
with:
path: node_modules/.cache/turbo
key: ${{ runner.os }}-turbo-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-turbo-
# Cache hardhat compilers
#
# This step will speed up workflow runs that use hardhat compilation
- name: Cache hardhat compilers
uses: actions/cache@v3
with:
path: .cache/hardhat
key: ${{ runner.os }}-hardhat-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-hardhat-
- name: Setup build cache
uses: ./.github/workflows/actions/setup-build-cache

- name: Build
run: pnpm build
Expand Down
53 changes: 10 additions & 43 deletions .github/workflows/reusable-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,56 +18,23 @@ env:
NPM_TOKEN: ""

jobs:
build-and-test:
name: Build, Lint & Test
build:
name: Build & Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout repo
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: Setup environment
uses: ./.github/workflows/actions/setup-environment

- name: Setup Node.js
uses: actions/setup-node@v3
- name: Install dependencies
uses: ./.github/workflows/actions/install-dependencies
with:
node-version-file: ".nvmrc"
cache: "pnpm"

# Fetch the dependencies without running the post-install scripts
- name: Fetch Dependencies
run: pnpm fetch --frozen-lockfile --prefer-offline --ignore-scripts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# Install the dependencies and run the post-install scripts
- name: Install Dependencies
run: pnpm install --frozen-lockfile --offline

# Cache build artifacts from turbo
#
# This step will speed up workflow runs that don't touch the whole codebase
# (or the ones that don't touch the codebase at all)
- name: Cache turbo build setup
uses: actions/cache@v3
with:
path: node_modules/.cache/turbo
key: ${{ runner.os }}-turbo-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-turbo-
# Cache hardhat compilers
#
# This step will speed up workflow runs that use hardhat compilation
- name: Cache hardhat compilers
uses: actions/cache@v3
with:
path: .cache/hardhat
key: ${{ runner.os }}-hardhat-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-hardhat-
- name: Setup build cache
uses: ./.github/workflows/actions/setup-build-cache

- name: Lint
run: pnpm lint
Expand Down

0 comments on commit 597a7b4

Please sign in to comment.