forked from ianstormtaylor/superstruct
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update CI and related files to match module template (#6)
Co-authored-by: Elliot Winkler <[email protected]>
- Loading branch information
Showing
41 changed files
with
581 additions
and
1,646 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Lines starting with '#' are comments. | ||
# Each line is a file pattern followed by one or more owners. | ||
|
||
* @MetaMask/engineering |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: npm | ||
- package-ecosystem: 'npm' | ||
directory: '/' | ||
open-pull-requests-limit: 20 | ||
schedule: | ||
interval: monthly | ||
interval: 'daily' | ||
time: '06:00' | ||
allow: | ||
- dependency-name: '@metamask/*' | ||
target-branch: 'main' | ||
versioning-strategy: 'increase-if-necessary' | ||
open-pull-requests-limit: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- | ||
Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: | ||
* What is the current state of things and why does it need to change? | ||
* What is the solution your changes offer and how does it work? | ||
Are there any issues or other links reviewers should consult to understand this pull request better? For instance: | ||
* Fixes #12345 | ||
* See: #67890 | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
name: Build, Lint, and Test | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
prepare: | ||
name: Prepare | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'yarn' | ||
- name: Install Yarn dependencies | ||
run: yarn --immutable | ||
|
||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
needs: | ||
- prepare | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'yarn' | ||
- run: yarn --immutable --immutable-cache | ||
- run: yarn build | ||
- 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 | ||
runs-on: ubuntu-latest | ||
needs: | ||
- prepare | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'yarn' | ||
- run: yarn --immutable --immutable-cache | ||
- 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 | ||
runs-on: ubuntu-latest | ||
needs: | ||
- prepare | ||
strategy: | ||
matrix: | ||
node-version: [18.x, 20.x] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'yarn' | ||
- run: yarn --immutable --immutable-cache | ||
- run: 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 | ||
runs-on: ubuntu-latest | ||
needs: | ||
- prepare | ||
strategy: | ||
matrix: | ||
node-version: [18.x, 20.x] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'yarn' | ||
- run: rm yarn.lock && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn | ||
- run: yarn test | ||
- name: Require clean working directory | ||
shell: bash | ||
run: | | ||
git restore yarn.lock | ||
if ! git diff --exit-code; then | ||
echo "Working tree dirty at end of job" | ||
exit 1 | ||
fi |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Create Release Pull Request | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
base-branch: | ||
description: 'The base branch for git operations and the pull request.' | ||
default: 'main' | ||
required: true | ||
release-type: | ||
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".' | ||
required: false | ||
|
||
jobs: | ||
create-release-pr: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- 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@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
- uses: MetaMask/action-create-release-pr@v3 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
release-type: ${{ github.event.inputs.release-type }} | ||
release-version: ${{ github.event.inputs.release-version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Main | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
|
||
jobs: | ||
check-workflows: | ||
name: Check workflows | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- 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 | ||
is-release: | ||
# Filtering by `push` events ensures that we only release from the `main` branch, which is a | ||
# requirement for our npm publishing environment. | ||
# The commit author should always be 'github-actions' for releases created by the | ||
# 'create-release-pr' workflow, so we filter by that as well to prevent accidentally | ||
# triggering a release. | ||
if: github.event_name == 'push' && startsWith(github.event.head_commit.author.name, 'github-actions') | ||
needs: all-jobs-pass | ||
outputs: | ||
IS_RELEASE: ${{ steps.is-release.outputs.IS_RELEASE }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: MetaMask/action-is-release@v1 | ||
id: is-release | ||
|
||
publish-release: | ||
needs: is-release | ||
if: needs.is-release.outputs.IS_RELEASE == 'true' | ||
name: Publish release | ||
permissions: | ||
contents: write | ||
uses: ./.github/workflows/publish-release.yml | ||
secrets: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }} | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Publish docs to GitHub Pages | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
destination_dir: | ||
required: true | ||
type: string | ||
secrets: | ||
PUBLISH_DOCS_TOKEN: | ||
required: true | ||
|
||
jobs: | ||
publish-docs-to-gh-pages: | ||
name: Publish docs to GitHub Pages | ||
runs-on: ubuntu-latest | ||
environment: github-pages | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Ensure `destination_dir` is not empty | ||
if: ${{ inputs.destination_dir == '' }} | ||
run: exit 1 | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'yarn' | ||
- name: Install npm dependencies | ||
run: yarn --immutable | ||
- name: Run build script | ||
run: yarn build:docs | ||
- name: Deploy to `${{ inputs.destination_dir }}` directory of `gh-pages` branch | ||
uses: peaceiris/actions-gh-pages@de7ea6f8efb354206b205ef54722213d99067935 | ||
with: | ||
# This `PUBLISH_DOCS_TOKEN` needs to be manually set per-repository. | ||
# Look in the repository settings under "Environments", and set this token in the `github-pages` environment. | ||
personal_token: ${{ secrets.PUBLISH_DOCS_TOKEN }} | ||
publish_dir: ./docs | ||
destination_dir: ${{ inputs.destination_dir }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Publish main branch docs to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: main | ||
|
||
jobs: | ||
publish-to-gh-pages: | ||
name: Publish docs to `staging` directory of `gh-pages` branch | ||
permissions: | ||
contents: write | ||
uses: ./.github/workflows/publish-docs.yml | ||
with: | ||
destination_dir: staging | ||
secrets: | ||
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Publish release candidate docs to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: 'release/**' | ||
|
||
jobs: | ||
get-release-version: | ||
name: Get release version | ||
runs-on: ubuntu-latest | ||
outputs: | ||
release-version: ${{ steps.release-name.outputs.RELEASE_VERSION }} | ||
steps: | ||
- name: Extract release version from branch name | ||
id: release-name | ||
run: | | ||
BRANCH_NAME='${{ github.ref_name }}' | ||
echo "RELEASE_VERSION=v${BRANCH_NAME#release/}" >> "$GITHUB_OUTPUT" | ||
publish-to-gh-pages: | ||
name: Publish docs to `rc-${{ needs.get-release-version.outputs.release-version }}` directory of `gh-pages` branch | ||
permissions: | ||
contents: write | ||
uses: ./.github/workflows/publish-docs.yml | ||
needs: get-release-version | ||
with: | ||
destination_dir: rc-${{ needs.get-release-version.outputs.release-version }} | ||
secrets: | ||
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }} |
Oops, something went wrong.