Skip to content

Commit

Permalink
chore(ci): use composite actions
Browse files Browse the repository at this point in the history
way nicer this way! see actions/runner#646 (comment)
  • Loading branch information
marcelgerber committed Nov 14, 2021
1 parent 252881a commit 8838675
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 84 deletions.
12 changes: 12 additions & 0 deletions .github/actions/build-tsc/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Build TypeScript
description: Compiles our TypeScript code
runs:
using: composite
steps:
- name: Register Problem Matcher
run: echo "##[add-matcher].github/problemMatchers/tsc.json"
shell: bash

- name: Run tsc
run: yarn buildTsc
shell: bash
28 changes: 28 additions & 0 deletions .github/actions/setup-node-yarn-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Set up node and dependencies
description: Runs all the setup steps required to have the proper Node version and all dependencies installed
runs:
using: composite
steps:
# Use Node version specified in .nvmrc
# https://github.com/actions/setup-node/issues/32#issuecomment-525791142
- name: Read .nvmrc
id: nvm
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
shell: bash

- name: Use Node.js (.nvmrc)
uses: actions/setup-node@v2
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: "yarn"

- name: List versions
run: |
echo "Versions:"
echo "Node `node --version`"
echo "yarn `yarn --version`"
shell: bash

- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1
shell: bash
25 changes: 5 additions & 20 deletions .github/workflows/auto-deploy-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,18 @@ jobs:
build-deploy-storybook-coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
- name: Clone repository
uses: actions/checkout@v2
with:
persist-credentials: false
ref: ${{ github.head_ref }}

# Use Node version specified in .nvmrc
# https://github.com/actions/setup-node/issues/32#issuecomment-525791142
- name: Read .nvmrc
id: nvm
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"

- name: Use Node.js (.nvmrc)
uses: actions/setup-node@v2
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: "yarn"

- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1
- uses: ./.github/actions/setup-node-yarn-deps
- uses: ./.github/actions/build-tsc

# Note: running these two build steps subsequently means that if either `buildStorybook` or `coverage` fails,
# neither of them is deployed :(
# Let's hope this doesn't happen too often

- name: Build JS
run: yarn buildTsc

- name: Build Storybook 🔧
run: yarn buildStorybook

Expand Down
44 changes: 13 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,22 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v2

# Use Node version specified in .nvmrc
# https://github.com/actions/setup-node/issues/32#issuecomment-525791142
- name: Read .nvmrc
id: nvm
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"

- name: Use Node.js (.nvmrc)
uses: actions/setup-node@v2
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: "yarn"
ref: ${{ github.head_ref }}

- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1
- uses: ./.github/actions/setup-node-yarn-deps

- name: Register Problem Matcher
run: echo "##[add-matcher].github/problemMatchers/tsc.json"

- name: Run tests & checks
run: yarn testPrettierAll && yarn buildTsc && yarn testJest
- name: Run prettier
run: yarn testPrettierAll

- name: Run tsc build
run: yarn buildTsc

- name: Run jest
run: yarn testJest

# Runs `bundlewatch` on the code to see if our Webpack build assets exceed a given file size.
bundlewatch:
Expand All @@ -38,24 +33,11 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v2

# Use Node version specified in .nvmrc
# https://github.com/actions/setup-node/issues/32#issuecomment-525791142
- name: Read .nvmrc
id: nvm
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"

- name: Use Node.js (.nvmrc)
uses: actions/setup-node@v2
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: "yarn"
ref: ${{ github.head_ref }}

- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1

- name: Run tsc
run: yarn buildTsc
- uses: ./.github/actions/setup-node-yarn-deps
- uses: ./.github/actions/build-tsc

- name: Run bundlewatch
run: yarn testBundlewatch
Expand Down
15 changes: 1 addition & 14 deletions .github/workflows/prettify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,7 @@ jobs:
with:
ref: ${{ github.head_ref }}

# Use Node version specified in .nvmrc
# https://github.com/actions/setup-node/issues/32#issuecomment-525791142
- name: Read .nvmrc
id: nvm
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"

- name: Use Node.js (.nvmrc)
uses: actions/setup-node@v2
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: "yarn"

- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1
- uses: ./.github/actions/setup-node-yarn-deps

- name: Run prettier
run: yarn fixPrettierAll
Expand Down
22 changes: 3 additions & 19 deletions .github/workflows/svg-compare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,11 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v2

# Use Node version specified in .nvmrc
# https://github.com/actions/setup-node/issues/32#issuecomment-525791142
- name: Read .nvmrc
id: nvm
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"

- name: Use Node.js (.nvmrc)
uses: actions/setup-node@v2
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: "yarn"

- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1
ref: ${{ github.head_ref }}

- name: Register Problem Matcher
run: echo "##[add-matcher].github/problemMatchers/tsc.json"

- name: Run tests & checks
run: yarn buildTsc
- uses: ./.github/actions/setup-node-yarn-deps
- uses: ./.github/actions/build-tsc

- name: Extract branch name
shell: bash
Expand Down

0 comments on commit 8838675

Please sign in to comment.