From 00e53f76eefbfe64654fe335e353bccc421b9181 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Thu, 31 Oct 2019 17:28:12 +0000 Subject: [PATCH] Update GitHub action workflows (#728) * Deploy on published release * Run build and test on merge to master * Update release drafter template * Update title of releases * Testing cypress fix * Pass group to --group flag --- .github/release-drafter.yml | 4 +- .github/workflows/build-and-test.yml | 46 +++++++++++++++++++ .github/workflows/bundlesize.yml | 6 +-- .../workflows/{publish.yml => deployment.yml} | 9 ++-- .../workflows/{cypress.yml => e2e-tests.yml} | 7 +-- .github/workflows/lint.yml | 2 +- .github/workflows/release-management.yml | 3 +- .github/workflows/unit-tests.yml | 2 +- package.json | 2 +- 9 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/build-and-test.yml rename .github/workflows/{publish.yml => deployment.yml} (96%) rename .github/workflows/{cypress.yml => e2e-tests.yml} (87%) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index eb276f2..8f5284e 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,5 +1,6 @@ -name-template: 'v$NEXT_PATCH_VERSION 🌈' +name-template: 'Draft (next release)' tag-template: 'v$NEXT_PATCH_VERSION' +sort-direction: descending categories: - title: '🚨 Breaking changes' labels: @@ -19,3 +20,4 @@ categories: change-template: '- $TITLE @$AUTHOR (#$NUMBER)' template: | $CHANGES + $CONTRIBUTORS diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..0791084 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,46 @@ +name: Build and test + +on: + push: + branches: + - master + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 1 + - uses: actions/setup-node@v1 + with: + node-version: 10 + # run all tests + - run: | + npm ci + npm run build + npx bundlesize + npm run test:unit:coverage + npm run test:e2e + env: + CI: true + CI_REPO_NAME: ${{ github.event.repository.name }} + CI_REPO_OWNER: ${{ github.event.organization.login }} + CI_COMMIT_SHA: ${{ github.sha }} + GIT_COMMIT: ${{ github.sha }} + CI_BRANCH: ${{ github.head_ref }} + BUNDLESIZE_GITHUB_TOKEN: ${{secrets.BUNDLESIZE_GITHUB_TOKEN}} + FORCE_COLOR: 2 + HUSKY_SKIP_INSTALL: true + + - name: Upload coverage to Codecov + run: bash <(curl -s https://codecov.io/bash) + -f ./coverage/lcov.info + -B ${{ github.head_ref }} + -C ${{ github.sha }} + -Z || echo 'Codecov upload failed' + env: + CI: true + GITLAB_CI: true # pretend we are GitLab CI, while Codecov adding support for Github Actions + CODECOV_ENV: github-action + CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} diff --git a/.github/workflows/bundlesize.yml b/.github/workflows/bundlesize.yml index 30fd049..168d34f 100644 --- a/.github/workflows/bundlesize.yml +++ b/.github/workflows/bundlesize.yml @@ -1,4 +1,4 @@ -name: BundleSize +name: Bundle size checks on: pull_request: @@ -22,8 +22,8 @@ jobs: - name: Install dependencies and build run: | - npm ci - npm run build + npm ci + npm run build env: CYPRESS_INSTALL_BINARY: 0 HUSKY_SKIP_INSTALL: true diff --git a/.github/workflows/publish.yml b/.github/workflows/deployment.yml similarity index 96% rename from .github/workflows/publish.yml rename to .github/workflows/deployment.yml index 7175ac7..0d45e76 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/deployment.yml @@ -1,12 +1,11 @@ -name: Publish Package +name: Publish and deploy on: - push: - branches: - - master + release: + types: [published] jobs: - build: + build-and-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 diff --git a/.github/workflows/cypress.yml b/.github/workflows/e2e-tests.yml similarity index 87% rename from .github/workflows/cypress.yml rename to .github/workflows/e2e-tests.yml index 50d19cf..16132f3 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/e2e-tests.yml @@ -1,4 +1,4 @@ -name: Cypress +name: End-to-end tests on: pull_request: @@ -14,7 +14,6 @@ on: jobs: test-e2e: - name: integration tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 @@ -35,8 +34,10 @@ jobs: env: CI: true TERM: xterm-256color + NODE_ENV: production # prevent watching CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} DEBUG: commit-info,cypress:server:record # https://docs.cypress.io/guides/guides/continuous-integration.html#Environment-variables COMMIT_INFO_BRANCH: ${{ github.head_ref }} - NODE_ENV: production # prevent watching + COMMIT_INFO_AUTHOR: ${{ github.event.sender.login }} + COMMIT_INFO_SHA: ${{ github.event.after }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0588e96..5071399 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: Lint +name: Code linting on: pull_request: diff --git a/.github/workflows/release-management.yml b/.github/workflows/release-management.yml index cba3b53..f264373 100644 --- a/.github/workflows/release-management.yml +++ b/.github/workflows/release-management.yml @@ -1,8 +1,7 @@ -name: Release Management +name: Release management on: push: - # branches to consider in the event; optional, defaults to all branches: - master diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index e0136ca..e67e330 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -1,4 +1,4 @@ -name: Unit Tests +name: Unit tests on: pull_request: diff --git a/package.json b/package.json index 2154319..b1abf12 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "bundlesize": "bundlesize", "cypress:run": "$(npm bin)/cypress run", "cypress:open": "$(npm bin)/cypress open", - "cypress:ci": "cypress run --record --group --ci-build-id $GITHUB_SHA", + "cypress:ci": "cypress run --record --group $GITHUB_REF --ci-build-id $GITHUB_SHA", "test": "run-s test:unit test:e2e", "test:unit": "NODE_ENV=test mocha", "test:unit:watch": "NODE_ENV=test mocha --watch --inspect=5556",