Skip to content

Commit

Permalink
chore(ci): make sure to only make new releases if tests pass (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 17, 2021
1 parent 01563ec commit b1d6111
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 65 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,6 @@ jobs:
configFile: './package.json'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ubuntu-latest-node-14.x-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
ubuntu-latest-node-14.x-yarn-
- uses: actions/setup-node@v2.1.4
with:
node-version: 14.x
- name: install
run: yarn
- name: regenerate docs
run: yarn tools:regenerate-docs
- name: report regenerated docs
run: |
git diff --name-only \
| xargs -I '{}' bash -c \
'echo "::error file={}::This needs to be regenerated by running \`tools:regenerate-docs\`" && false'
danger:
runs-on: ubuntu-latest
steps:
Expand Down
101 changes: 96 additions & 5 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,52 @@
name: Unit tests
name: Unit tests & Release

on:
push:
branches:
- master
- main
- next
pull_request:
branches:
- master
- main
- next

jobs:
prepare-yarn-cache:
name: Prepare yarn cache
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2.1.4
with:
node-version: 14.x

- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"

- uses: actions/cache@v2.1.4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn2-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn2-
- name: Validate cache
env:
# Use PnP and disable postinstall scripts as this just needs to
# populate the cache for the other jobs
YARN_NODE_LINKER: pnp
YARN_ENABLE_SCRIPTS: false
run: yarn --immutable

test-node:
name:
# prettier-ignore
Test on Node.js v${{ matrix.node-version }} and eslint v${{matrix.eslint-version }}
needs: prepare-yarn-cache
strategy:
fail-fast: false
matrix:
Expand All @@ -32,9 +64,9 @@ jobs:
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ubuntu-latest-node-12.x-yarn-${{ hashFiles('**/yarn.lock') }}
key: yarn2-${{ hashFiles('yarn.lock') }}
restore-keys: |
ubuntu-latest-node-12.x-yarn-
yarn2-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.1.4
with:
Expand All @@ -56,6 +88,7 @@ jobs:
if: ${{ matrix.eslint-version >= 6 }}
test-os:
name: Test on ${{ matrix.os }} using Node.js LTS
needs: prepare-yarn-cache
strategy:
fail-fast: false
matrix:
Expand All @@ -70,9 +103,9 @@ jobs:
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-node-14.x-yarn-${{ hashFiles('**/yarn.lock') }}
key: yarn2-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-14.x-yarn-
yarn2-
- uses: actions/setup-node@v2.1.4
with:
node-version: 14.x
Expand All @@ -86,3 +119,61 @@ jobs:
run: yarn test --coverage
env:
CI: true

docs:
if: ${{ github.event_name == 'pull_request' }}
needs: prepare-yarn-cache
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn2-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn2-
- uses: actions/setup-node@v2.1.4
with:
node-version: 14.x
- name: install
run: yarn
- name: regenerate docs
run: yarn tools:regenerate-docs
- name: report regenerated docs
run: |
git diff --name-only \
| xargs -I '{}' bash -c \
'echo "::error file={}::This needs to be regenerated by running \`tools:regenerate-docs\`" && false'
release:
if:
# prettier-ignore
${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
name: Release new version
needs: [test-node, test-os]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn2-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn2-
- uses: actions/setup-node@v2.1.4
with:
node-version: 14.x
- name: install
run: yarn
- run: yarn semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
33 changes: 0 additions & 33 deletions .github/workflows/release.yml

This file was deleted.

0 comments on commit b1d6111

Please sign in to comment.