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 CI to match module template #78

Merged
merged 5 commits into from
Oct 31, 2023
Merged
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
84 changes: 56 additions & 28 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
name: Build, Lint, and Test

on:
push:
branches: [main]
pull_request:
workflow_call:

jobs:
build-lint-test:
name: Build, Lint, and Test
prepare:
name: Prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install --immutable
- name: Install Yarn dependencies
run: yarn --immutable

build:
name: Build
runs-on: ubuntu-latest
needs:
- prepare
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- run: yarn build
- run: yarn lint
- run: yarn test
- name: Cache snap build
if: ${{ matrix.node-version == '18.x' }}
uses: actions/cache@v3
with:
path: ./packages/snap/dist
Expand All @@ -33,18 +40,41 @@ jobs:
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty after building"
echo "Working tree dirty at end of job"
exit 1
fi

lint:
name: Lint
runs-on: ubuntu-latest
needs:
- prepare
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- run: yarn lint
- 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

e2e:
name: End-to-end Tests
e2e-test:
name: End-to-end Test
runs-on: ubuntu-latest
needs:
- build-lint-test
- prepare
- build
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
Expand All @@ -59,12 +89,10 @@ jobs:
run: yarn install-chrome
- name: Run e2e tests
run: yarn workspace snap run test

all-jobs-pass:
name: All jobs pass
runs-on: ubuntu-latest
needs:
- build-lint-test
- e2e
steps:
- run: echo "Great success!"
- 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
50 changes: 0 additions & 50 deletions .github/workflows/create-release-pr.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Main

on:
push:
branches: [main]
pull_request:

jobs:
check-workflows:
name: Check workflows
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download actionlint
id: download-actionlint
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.6.23
shell: bash
- name: Check workflow files
run: ${{ steps.download-actionlint.outputs.executable }} -color
shell: bash

build-lint-test:
name: Build, lint, and test
uses: ./.github/workflows/build-lint-test.yml

all-jobs-completed:
name: All jobs completed
runs-on: ubuntu-latest
needs:
- check-workflows
- build-lint-test
outputs:
PASSED: ${{ steps.set-output.outputs.PASSED }}
steps:
- name: Set PASSED output
id: set-output
run: echo "PASSED=true" >> "$GITHUB_OUTPUT"

all-jobs-pass:
name: All jobs pass
if: ${{ always() }}
runs-on: ubuntu-latest
needs: all-jobs-completed
steps:
- name: Check that all jobs have passed
run: |
passed="${{ needs.all-jobs-completed.outputs.PASSED }}"
if [[ $passed != "true" ]]; then
exit 1
fi
48 changes: 0 additions & 48 deletions .github/workflows/publish-release.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.6
lts/*
FrederikBolding marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
"lint:misc": "prettier '**/*.json' '**/*.md' '!**/CHANGELOG.md' '**/*.yml' --ignore-path .gitignore",
"start": "yarn workspaces foreach --parallel --interlaced --verbose run start",
"test": "echo \"TODO\""
"test": "yarn workspace snap run test"
},
"devDependencies": {
"@metamask/eslint-config": "^10.0.0",
Expand Down
2 changes: 0 additions & 2 deletions scripts/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ set -u
set -o pipefail

rm .github/CODEOWNERS
rm .github/workflows/create-release-pr.yml
rm .github/workflows/publish-release.yml
rm -f scripts/cleanup.sh
git commit -am "Clean up undesired MetaMask GitHub files"