Skip to content

Commit

Permalink
ci(github): split npm jobs and add dependency caching
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia authored and skamril committed Aug 9, 2024
1 parent a8eeef1 commit 16e9997
Showing 1 changed file with 72 additions and 12 deletions.
84 changes: 72 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,34 +65,94 @@ jobs:
name: python-code-coverage-report
path: coverage.xml

npm-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
npm-setup:
runs-on: ubuntu-latest
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18.16.1
- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: webapp/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('webapp/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
save-always: true
- name: Install dependencies
run: npm install
working-directory: webapp
- name: Build
run: npm run build
working-directory: webapp
env:
NODE_OPTIONS: --max-old-space-size=8192
DISABLE_ESLINT_PLUGIN: true

npm-lint:
needs: npm-setup
runs-on: ubuntu-latest
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18.16.1
- name: Restore node modules
uses: actions/cache@v4
with:
path: webapp/node_modules
key: ${{ runner.os }}-build-cache-node-modules-${{ hashFiles('webapp/package-lock.json') }}
save-always: true
- name: Lint
run: npm run lint
working-directory: webapp

npm-test:
needs: npm-setup
runs-on: ubuntu-latest
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18.16.1
- name: Restore node modules
uses: actions/cache@v4
with:
path: webapp/node_modules
key: ${{ runner.os }}-build-cache-node-modules-${{ hashFiles('webapp/package-lock.json') }}
save-always: true
- name: Test
run: npm run test
working-directory: webapp

npm-build:
needs: npm-setup
runs-on: ubuntu-latest
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18.16.1
- name: Restore node modules
uses: actions/cache@v4
with:
path: webapp/node_modules
key: ${{ runner.os }}-build-cache-node-modules-${{ hashFiles('webapp/package-lock.json') }}
save-always: true
- name: Build
run: npm run build
working-directory: webapp
env:
NODE_OPTIONS: --max-old-space-size=8192
DISABLE_ESLINT_PLUGIN: true

sonarcloud:
runs-on: ubuntu-20.04
needs: [python-test, npm-test]
Expand Down

0 comments on commit 16e9997

Please sign in to comment.