forked from ethjs/ethjs-filter
-
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.
ci: move from TravisCI to GitHub Actions (ethjs#4)
* devDeps: [email protected] -> ganache-cli@^6.12.2 Necessary to make tests pass
- Loading branch information
Showing
10 changed files
with
1,100 additions
and
3,768 deletions.
There are no files selected for viewing
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,67 @@ | ||
name: Build, Lint, and Test | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [8.x, 10.x, 12.x] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
- run: npm i | ||
- run: npm run build | ||
- name: Require clean working directory | ||
shell: bash | ||
run: | | ||
if ! git diff --exit-code -- . ':!dist/*.map'; then | ||
echo "Working tree dirty at end of job" | ||
exit 1 | ||
fi | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [12.x] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
- run: npm i | ||
- run: npm run lint | ||
|
||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [8.x, 10.x, 12.x, 14.x, 16.x, 20.x, 18.x] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
- run: npm i | ||
- run: npm run test | ||
- name: Require clean working directory | ||
shell: bash | ||
run: | | ||
if ! git diff --exit-code -- . ':!dist/*.map' ':!package-lock.json' ; then | ||
echo "Working tree dirty at end of job" | ||
exit 1 | ||
fi |
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, patch, prerelease etc. 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@v3 | ||
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 | ||
with: | ||
node-version-file: '.nvmrc' | ||
- uses: MetaMask/action-create-release-pr@2d124c5b0bf1fb10111589cd95b6b22734ac66d3 | ||
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,75 @@ | ||
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.22 | ||
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 }} |
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: Publish Release | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
NPM_TOKEN: | ||
required: true | ||
|
||
jobs: | ||
publish-release: | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.sha }} | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: '.nvmrc' | ||
- uses: MetaMask/action-publish-release@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Install and build | ||
run: | | ||
npm i | ||
npm run build | ||
- name: Dry Run Publish | ||
# omit npm-token token to perform dry run publish | ||
uses: MetaMask/action-npm-publish@v2 | ||
env: | ||
SKIP_PREPACK: true | ||
- name: Publish | ||
uses: MetaMask/action-npm-publish@v2 | ||
with: | ||
# This `NPM_TOKEN` needs to be manually set per-repository. | ||
# Look in the repository settings under "Environments", and set this token in the `npm-publish` environment. | ||
npm-token: ${{ secrets.NPM_TOKEN }} | ||
env: | ||
SKIP_PREPACK: true |
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
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
Oops, something went wrong.