Skip to content

Commit

Permalink
ci(nodejs.yml): refactor with single cache step (#8221)
Browse files Browse the repository at this point in the history
  • Loading branch information
drakulavich authored Oct 11, 2022
1 parent 278dc05 commit 0a7b3d6
Showing 1 changed file with 31 additions and 32 deletions.
63 changes: 31 additions & 32 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,37 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Use Node.js 16.x
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 16
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Cache Cypress binary
id: cache-cypress-binary
uses: actions/cache@v2

- name: Cache Node Modules and Cypress binary
uses: actions/cache@v3
id: cache-primes
with:
path: cypress/cache
key: cypress-binary-${{ hashFiles('package-lock.json') }}
path: |
node_modules
${{ env.CYPRESS_CACHE_FOLDER }}
key: ${{ runner.os }}-node-and-cypress-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: |
steps.cache-node-modules.outputs.cache-hit != 'true' ||
steps.cache-cypress-binary.outputs.cache-hit != 'true'
if: steps.cache-primes.outputs.cache-hit != 'true'
run: npm ci

- name: Lint code for errors only
run: npm run lint-errors

- name: Run all tests
run: npm run just-test-in-node && npm run test:unit-jest
env:
CI: true

- name: Build SwaggerUI
run: npm run build

- name: Test build artifacts
run: npm run test:artifact

Expand All @@ -58,27 +59,25 @@ jobs:
containers: ['+(a11y|security|bugs)/**/*.js', 'features/**/+(o|d)*.js', 'features/**/m*.js', 'features/**/!(o|d|m)*.js']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Use Node.js 16.x
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 16
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Cache Cypress binary
id: cache-cypress-binary
uses: actions/cache@v2

- name: Cache Node Modules and Cypress binary
uses: actions/cache@v3
id: cache-primes
with:
path: cypress/cache
key: cypress-binary-${{ hashFiles('package-lock.json') }}
path: |
node_modules
${{ env.CYPRESS_CACHE_FOLDER }}
key: ${{ runner.os }}-node-and-cypress-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: |
steps.cache-node-modules.outputs.cache-hit != 'true' ||
steps.cache-cypress-binary.outputs.cache-hit != 'true'
if: steps.cache-primes.outputs.cache-hit != 'true'
run: npm ci

- name: Cypress Test
run: npx start-server-and-test cy:start http://localhost:3204 'npm run cy:run -- --spec "test/e2e-cypress/tests/${{ matrix.containers }}"'

0 comments on commit 0a7b3d6

Please sign in to comment.