From 88cba066e82c7a77726dfa3983afecb00e801fe3 Mon Sep 17 00:00:00 2001 From: Minh Ngo Date: Sun, 16 Oct 2022 17:24:22 +0700 Subject: [PATCH] refactor: support running multiple jobs github actions --- .github/actions/install-deps/action.yml | 19 ++++++++ .github/workflows/workflow-config.yml | 64 ++++++++++++++----------- .nvmrc | 1 + 3 files changed, 55 insertions(+), 29 deletions(-) create mode 100644 .github/actions/install-deps/action.yml create mode 100644 .nvmrc diff --git a/.github/actions/install-deps/action.yml b/.github/actions/install-deps/action.yml new file mode 100644 index 0000000..ecc3c41 --- /dev/null +++ b/.github/actions/install-deps/action.yml @@ -0,0 +1,19 @@ +runs: + using: "composite" + steps: + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + - name: Cache node_modules + uses: actions/cache@v3 + id: cache + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: | + **/node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- diff --git a/.github/workflows/workflow-config.yml b/.github/workflows/workflow-config.yml index 9c28412..6d3ccaf 100644 --- a/.github/workflows/workflow-config.yml +++ b/.github/workflows/workflow-config.yml @@ -3,36 +3,23 @@ name: 'ci/cd' on: [push, pull_request] jobs: - test: - # Job name - name: test - # This job runs on Linux - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [14.x] + installation: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + uses: ./.github/actions/install-deps + - name: Installing packages...🏃‍♂️ 🏃‍♂️ 🏃‍♂️ + run: npm ci + linter: + runs-on: ubuntu-20.04 + needs: [installation] + concurrency: validation-${{ github.ref }} steps: - - name: Checkout repository - uses: actions/checkout@v2 - id: checkout - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: Cache node_modules - uses: actions/cache@v2 - id: cache - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: | - **/node_modules - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- + - uses: actions/checkout@v3 + - name: Install dependencies + uses: ./.github/actions/install-deps - name: Installing packages...🏃‍♂️ 🏃‍♂️ 🏃‍♂️ - if: steps.cache.outputs.cache-hit != 'true' run: npm ci - name: Running typecheck... 🩺 🔬 🔭 run: npm run code:typecheck @@ -42,13 +29,32 @@ jobs: run: npm run css:lint - name: Running validation... 👨‍⚕️ 👩‍⚕️ 🩺 run: npm run code:validate + test: + runs-on: ubuntu-20.04 + needs: [installation] + concurrency: validation-${{ github.ref }} + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + uses: ./.github/actions/install-deps + - name: Installing packages...🏃‍♂️ 🏃‍♂️ 🏃‍♂️ + run: npm ci - name: Running unit test... 🤞 🚑 💊 run: npm run test:unit -- --runInBand --coverage - name: Trigger codecov run: bash <(curl -s https://codecov.io/bash) + build: + runs-on: ubuntu-20.04 + needs: [installation, linter, test] + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + uses: ./.github/actions/install-deps + - name: Installing packages...🏃‍♂️ 🏃‍♂️ 🏃‍♂️ + run: npm ci - name: Run build Chrome run: npm run app:chrome - name: Run build Firefox run: npm run app:firefox - name: Run build Edge - run: npm run app:edge \ No newline at end of file + run: npm run app:edge diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..2851522 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +14.20.1