Skip to content

Commit

Permalink
ci(github): split npm jobs and add dependency caching (#2118)
Browse files Browse the repository at this point in the history
* refactor main.yml workflow to separate lint, test, and build jobs
* implement caching for npm dependencies to speed up CI
  • Loading branch information
hdinia authored Aug 14, 2024
1 parent a8eeef1 commit 0318e85
Showing 1 changed file with 69 additions and 12 deletions.
81 changes: 69 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,34 +65,91 @@ 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-20.04
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
with:
path: webapp/node_modules
key: ${{ runner.os }}-webapp-node-modules-${{ hashFiles('webapp/package-lock.json') }}
restore-keys: |
${{ runner.os }}-webapp-node-modules-
${{ 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-20.04
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 }}-webapp-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-20.04
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 }}-webapp-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-20.04
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 }}-webapp-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 0318e85

Please sign in to comment.