From 8838675b28f92901e63a319c0c3ee025e2a2e2e5 Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Sun, 14 Nov 2021 18:57:51 +0100 Subject: [PATCH] chore(ci): use composite actions way nicer this way! see https://github.com/actions/runner/issues/646#issuecomment-901336347 --- .github/actions/build-tsc/action.yml | 12 +++++ .../actions/setup-node-yarn-deps/action.yml | 28 ++++++++++++ .github/workflows/auto-deploy-gh-pages.yml | 25 +++-------- .github/workflows/ci.yml | 44 ++++++------------- .github/workflows/prettify.yml | 15 +------ .github/workflows/svg-compare.yml | 22 ++-------- 6 files changed, 62 insertions(+), 84 deletions(-) create mode 100644 .github/actions/build-tsc/action.yml create mode 100644 .github/actions/setup-node-yarn-deps/action.yml diff --git a/.github/actions/build-tsc/action.yml b/.github/actions/build-tsc/action.yml new file mode 100644 index 00000000000..07fd4400945 --- /dev/null +++ b/.github/actions/build-tsc/action.yml @@ -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 diff --git a/.github/actions/setup-node-yarn-deps/action.yml b/.github/actions/setup-node-yarn-deps/action.yml new file mode 100644 index 00000000000..fe377ce1292 --- /dev/null +++ b/.github/actions/setup-node-yarn-deps/action.yml @@ -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 diff --git a/.github/workflows/auto-deploy-gh-pages.yml b/.github/workflows/auto-deploy-gh-pages.yml index e26b736ce49..245d35e9d30 100644 --- a/.github/workflows/auto-deploy-gh-pages.yml +++ b/.github/workflows/auto-deploy-gh-pages.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c589a17d5fd..22ca457945e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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 diff --git a/.github/workflows/prettify.yml b/.github/workflows/prettify.yml index 528183b6cb2..9cf1a6538fa 100644 --- a/.github/workflows/prettify.yml +++ b/.github/workflows/prettify.yml @@ -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 diff --git a/.github/workflows/svg-compare.yml b/.github/workflows/svg-compare.yml index df341eb6e80..b81b44f5041 100644 --- a/.github/workflows/svg-compare.yml +++ b/.github/workflows/svg-compare.yml @@ -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