From be76228c2c030260f8d07e2e3aca1ad376915f8e Mon Sep 17 00:00:00 2001 From: Marcin Kuthan Date: Tue, 22 Nov 2022 13:14:47 +0100 Subject: [PATCH] GH actions refactored into single CI workflow (#945) --- .github/actions/setup/action.yml | 29 +++++++++ .github/workflows/build.yml | 50 --------------- .github/workflows/ci.yml | 61 +++++++++++++++++++ .../{lighthouse.yml => lighthouse-report.yml} | 33 ++-------- .github/workflows/release-beta.yml | 34 ++--------- .github/workflows/release-final.yml | 36 ++--------- .github/workflows/size-limit.yml | 35 ----------- .github/workflows/size-report.yml | 20 ++++++ 8 files changed, 127 insertions(+), 171 deletions(-) create mode 100644 .github/actions/setup/action.yml delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/ci.yml rename .github/workflows/{lighthouse.yml => lighthouse-report.yml} (67%) delete mode 100644 .github/workflows/size-limit.yml create mode 100644 .github/workflows/size-report.yml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 000000000..f9e8619ee --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,29 @@ +name: Setup +description: Setup build + +inputs: + node-version: + required: true + default: "16.15.0" + description: Node version + +runs: + using: composite + steps: + - name: Use Node.js ${{ inputs.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ inputs.node-version }} + + - name: Cache Node.js modules + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-node- + ${{ runner.OS }}- + + - name: Install dependencies + shell: bash + run: npm ci diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 0e474c187..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Build - -on: - workflow_dispatch: ~ - push: - branches: - - master - pull_request: - -jobs: - build: - - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [ 14.20.0, 16.15.0 ] - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Cache Node.js modules - uses: actions/cache@v2 - with: - path: ~/.npm - key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.OS }}-node- - ${{ runner.OS }}- - - - name: Install dependencies - run: npm ci - - - name: Lint - run: npm run lint - - - name: Build - run: npm run build - - - name: Unit Test - run: npm run test - - - name: E2E Test - run: npm run e2e diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..df3e84af2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,61 @@ +name: CI + +on: + workflow_dispatch: ~ + push: + branches: + - master + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup + - run: npm run lint + + unit-test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.20.0, 16.15.0] + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup + with: + node-version: ${{ matrix.node-version }} + - run: npm run build + - run: npm run test + + e2e-test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.20.0, 16.15.0] + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup + with: + node-version: ${{ matrix.node-version }} + - run: npm run build + - run: npm run e2e + + lighthouse-report: + needs: [lint, unit-test, e2e-test] + uses: ./.github/workflows/lighthouse-report.yml + secrets: inherit + + size-report: + needs: [lint, unit-test, e2e-test] + uses: ./.github/workflows/size-report.yml + secrets: inherit diff --git a/.github/workflows/lighthouse.yml b/.github/workflows/lighthouse-report.yml similarity index 67% rename from .github/workflows/lighthouse.yml rename to .github/workflows/lighthouse-report.yml index 1634cb1ac..2d0b671f0 100644 --- a/.github/workflows/lighthouse.yml +++ b/.github/workflows/lighthouse-report.yml @@ -1,13 +1,11 @@ -name: Lighthouse CI +name: Lighthouse Report on: - pull_request: - branches: - - master + workflow_call: ~ workflow_dispatch: ~ jobs: - build: + lighthouse-report: runs-on: ubuntu-latest @@ -17,28 +15,9 @@ jobs: pull-requests: write steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: 16.15.0 - - - name: Cache Node.js modules - uses: actions/cache@v2 - with: - path: ~/.npm - key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.OS }}-node- - ${{ runner.OS }}- - - - name: Install dependencies - run: npm ci - - - name: Build - run: npm run build + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup + - run: npm run build - name: Run Lighthouse CI run: | diff --git a/.github/workflows/release-beta.yml b/.github/workflows/release-beta.yml index 6197a5faf..ec1b1d5e4 100644 --- a/.github/workflows/release-beta.yml +++ b/.github/workflows/release-beta.yml @@ -9,7 +9,6 @@ on: jobs: build: - runs-on: ubuntu-latest steps: @@ -21,34 +20,11 @@ jobs: # release must bypass branch protection rules, built-in GITHUB_TOKEN doesn't work token: ${{ secrets.RELEASE_GH_TOKEN }} - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: '16.15.0' - - - name: Cache Node.js modules - uses: actions/cache@v2 - with: - path: ~/.npm - key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.OS }}-node- - ${{ runner.OS }}- - - - name: Install dependencies - run: npm ci - - - name: Lint - run: npm run lint - - - name: Build - run: npm run build - - - name: Unit Test - run: npm run test - - - name: E2E Test - run: npm run e2e + - uses: ./.github/actions/setup + - run: npm run lint + - run: npm run build + - run: npm run test + - run: npm run e2e - name: Configure GIT run: | diff --git a/.github/workflows/release-final.yml b/.github/workflows/release-final.yml index acd9bef05..eb0ddb697 100644 --- a/.github/workflows/release-final.yml +++ b/.github/workflows/release-final.yml @@ -5,12 +5,11 @@ on: inputs: increment: description: 'Defines which part of a SemVer should be increased during the release process, e.g "major", "minor" or "patch"' - default: 'minor' + default: "minor" required: true jobs: build: - runs-on: ubuntu-latest steps: @@ -26,34 +25,11 @@ jobs: if: github.ref != 'refs/heads/master' run: exit 1 - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: '16.15.0' - - - name: Cache Node.js modules - uses: actions/cache@v2 - with: - path: ~/.npm - key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.OS }}-node- - ${{ runner.OS }}- - - - name: Install dependencies - run: npm ci - - - name: Lint - run: npm run lint - - - name: Build - run: npm run build - - - name: Unit Test - run: npm run test - - - name: E2E Test - run: npm run e2e + - uses: ./.github/actions/setup + - run: npm run lint + - run: npm run build + - run: npm run test + - run: npm run e2e - name: Configure GIT run: | diff --git a/.github/workflows/size-limit.yml b/.github/workflows/size-limit.yml deleted file mode 100644 index 1847cfce3..000000000 --- a/.github/workflows/size-limit.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: "Size" -on: - pull_request: - branches: - - master -jobs: - size: - runs-on: ubuntu-latest - env: - CI_JOB_NUMBER: 1 - steps: - - uses: actions/checkout@v2 - - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: 16.15.0 - - - name: Cache Node.js modules - uses: actions/cache@v2 - with: - path: ~/.npm - key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.OS }}-node- - ${{ runner.OS }}- - - - name: Install dependencies - run: npm ci - - - uses: andresz1/size-limit-action@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - build_script: build:client - skip_step: install diff --git a/.github/workflows/size-report.yml b/.github/workflows/size-report.yml new file mode 100644 index 000000000..cfe8ce057 --- /dev/null +++ b/.github/workflows/size-report.yml @@ -0,0 +1,20 @@ +name: Size report + +on: + workflow_call: ~ + workflow_dispatch: ~ + +jobs: + size-report: + runs-on: ubuntu-latest + env: + CI_JOB_NUMBER: 1 + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup + + - uses: andresz1/size-limit-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + build_script: build:client + skip_step: install