Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update actions to match module template #154

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
220 changes: 220 additions & 0 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
name: Build, Lint, and Test

on:
workflow_call:

jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v4
- name: Install Corepack via Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
# TODO: Remove --ignore-engines once devdeps compatible with node v20
- name: Install dependencies via Yarn (ignoring engines)
run: yarn --frozen-lockfile --ignore-engines
if: "startsWith(matrix.node-version, '2')"
- name: Install dependencies via Yarn
run: yarn --frozen-lockfile
if: "!startsWith(matrix.node-version, '2')"

build:
name: Build
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- uses: actions/checkout@v4
- name: Install Corepack via Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
# TODO: Remove --ignore-engines once devdeps compatible with node v20
- name: Install dependencies via Yarn (ignoring engines)
run: yarn --frozen-lockfile --ignore-engines
if: "startsWith(matrix.node-version, '2')"
- name: Install dependencies via Yarn
run: yarn --frozen-lockfile
if: "!startsWith(matrix.node-version, '2')"
- run: yarn allow-scripts
- run: yarn build
- name: Cache build files
uses: actions/cache@v4
with:
key: build
path: |
./dist
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi

lint:
name: Lint
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- uses: actions/checkout@v4
- name: Install Corepack via Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
# TODO: Remove --ignore-engines once devdeps compatible with node v20
- name: Install dependencies via Yarn (ignoring engines)
run: yarn --frozen-lockfile --ignore-engines
if: "startsWith(matrix.node-version, '2')"
- name: Install dependencies via Yarn
run: yarn --frozen-lockfile
if: "!startsWith(matrix.node-version, '2')"
- run: yarn allow-scripts
- run: yarn lint
- name: Validate RC changelog
if: ${{ startsWith(github.head_ref, 'release/') }}
run: yarn lint:changelog --rc
- name: Validate changelog
if: ${{ !startsWith(github.head_ref, 'release/') }}
run: yarn lint:changelog
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi

test:
name: Test
needs:
- prepare
- build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v4
- name: Install Corepack via Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
# TODO: Remove --ignore-engines once devdeps compatible with node v20
- name: Install dependencies via Yarn (ignoring engines)
run: yarn --frozen-lockfile --ignore-engines
if: "startsWith(matrix.node-version, '2')"
- name: Install dependencies via Yarn
run: yarn --frozen-lockfile
if: "!startsWith(matrix.node-version, '2')"
- run: yarn allow-scripts
- name: Restore build files
uses: actions/cache@v4
with:
key: build
fail-on-cache-miss: true
path: |
./dist
# We have to use xvfb due to electron
# Ref: https://github.com/facebook-atom/jest-electron-runner/issues/47#issuecomment-508556407
- name: Test
run: xvfb-run -e /dev/stdout yarn test
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi

compatibility-test:
name: Compatibility test
needs:
- prepare
- build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v4
- name: Install Corepack via Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Remove yarn.lock
run: rm yarn.lock
# TODO: Remove --ignore-engines once devdeps compatible with node v20
- name: Install dependencies via Yarn (ignoring engines)
run: yarn --ignore-engines
if: "startsWith(matrix.node-version, '2')"
- name: Install dependencies via Yarn
run: yarn
if: "!startsWith(matrix.node-version, '2')"
- run: yarn allow-scripts
- name: Restore build files
uses: actions/cache@v4
with:
key: build
fail-on-cache-miss: true
path: |
./dist
# We have to use xvfb due to electron
# Ref: https://github.com/facebook-atom/jest-electron-runner/issues/47#issuecomment-508556407
- name: Test
run: xvfb-run -e /dev/stdout yarn test
- name: Restore lockfile
run: git restore yarn.lock
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
65 changes: 0 additions & 65 deletions .github/workflows/build-test.yml

This file was deleted.

21 changes: 7 additions & 14 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
default: 'main'
required: true
release-type:
description: 'A SemVer version diff, i.e. major, minor, patch, prerelease etc. Mutually exclusive with "release-version".'
description: 'A SemVer version diff, i.e. major, minor, or patch. Mutually exclusive with "release-version".'
required: false
release-version:
description: 'A specific version to bump to. Mutually exclusive with "release-type".'
Expand All @@ -21,28 +21,21 @@ jobs:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# This is to guarantee that the most recent tag is fetched.
# This can be configured to a more reasonable value by consumers.
fetch-depth: 0
# We check out the specified branch, which will be used as the base
# branch for all git operations and the release PR.
ref: ${{ github.event.inputs.base-branch }}
- name: Setup Node.js
uses: actions/setup-node@v3
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- uses: MetaMask/action-create-release-pr@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: MetaMask/action-create-release-pr@v4
with:
release-type: ${{ github.event.inputs.release-type }}
release-version: ${{ github.event.inputs.release-version }}
artifacts-path: gh-action__release-authors
# Upload the release author artifact for use in subsequent workflows
- uses: actions/upload-artifact@v2
with:
name: release-authors
path: gh-action__release-authors
if-no-files-found: error
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading
Loading