Skip to content

Commit

Permalink
ci: enable caching for npm install and split jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
marabesi committed Oct 21, 2023
1 parent 95c2b12 commit 2958f4d
Showing 1 changed file with 53 additions and 11 deletions.
64 changes: 53 additions & 11 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
CI: true

jobs:
build:
install:
runs-on: ubuntu-latest

steps:
Expand All @@ -25,28 +25,70 @@ jobs:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'

- name: export display
run: |
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
echo ">>> Started xvfb"
- name: Restore node modules
uses: actions/cache/restore@v3
id: cache
with:
path: |
./node_modules
key: ${{ hashFiles('package-lock.json') }}

- name: install
if: steps.cache.outputs.cache-hit != 'true'
run: npm install --legacy-peer-deps

- name: Save the cache
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: |
./node_modules
key: ${{ hashFiles('package-lock.json') }}

build:
needs: [install]
runs-on: ubuntu-latest
env:
NODE_OPTIONS: --openssl-legacy-provider
steps:
- name: Restore node modules
uses: actions/cache/restore@v3
id: cache
with:
path: |
./node_modules
key: ${{ hashFiles('package-lock.json') }}
- name: build
env:
NODE_OPTIONS: --openssl-legacy-provider
run: npm run build

- name: test
test:
needs: [install]
runs-on: ubuntu-latest
steps:
- name: Restore node modules
uses: actions/cache/restore@v3
id: cache
with:
path: |
./node_modules
key: ${{ hashFiles('package-lock.json') }}
- name: tests
run: npm run test
env:
CI: true
DISPLAY: ':99.0'

acceptance:
needs: [install]
runs-on: ubuntu-latest
steps:
- name: export display
run: |
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
echo ">>> Started xvfb"
- name: Run cypress (acceptance tests)
uses: cypress-io/github-action@v4
env:
CI: true
DISPLAY: ':99.0'
CYPRESS_BASE_URL: 'http://localhost:3000'
with:
wait-on: 'http://localhost:3000'
Expand Down

0 comments on commit 2958f4d

Please sign in to comment.