ci(nodejs.yml): refactor with single cache step (#8221)

This commit is contained in:
Anton Yakutovich
2022-10-11 15:04:50 +04:00
committed by GitHub
parent 278dc05c88
commit 0a7b3d6b2f

View File

@@ -17,36 +17,37 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Use Node.js 16.x - name: Use Node.js 16.x
uses: actions/setup-node@v2 uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 16
- name: Cache Node Modules
id: cache-node-modules - name: Cache Node Modules and Cypress binary
uses: actions/cache@v2 uses: actions/cache@v3
id: cache-primes
with: with:
path: node_modules path: |
key: node-modules-${{ hashFiles('package-lock.json') }} node_modules
- name: Cache Cypress binary ${{ env.CYPRESS_CACHE_FOLDER }}
id: cache-cypress-binary key: ${{ runner.os }}-node-and-cypress-${{ hashFiles('package-lock.json') }}
uses: actions/cache@v2
with:
path: cypress/cache
key: cypress-binary-${{ hashFiles('package-lock.json') }}
- name: Install dependencies - name: Install dependencies
if: | if: steps.cache-primes.outputs.cache-hit != 'true'
steps.cache-node-modules.outputs.cache-hit != 'true' ||
steps.cache-cypress-binary.outputs.cache-hit != 'true'
run: npm ci run: npm ci
- name: Lint code for errors only - name: Lint code for errors only
run: npm run lint-errors run: npm run lint-errors
- name: Run all tests - name: Run all tests
run: npm run just-test-in-node && npm run test:unit-jest run: npm run just-test-in-node && npm run test:unit-jest
env: env:
CI: true CI: true
- name: Build SwaggerUI - name: Build SwaggerUI
run: npm run build run: npm run build
- name: Test build artifacts - name: Test build artifacts
run: npm run test:artifact run: npm run test:artifact
@@ -58,27 +59,25 @@ jobs:
containers: ['+(a11y|security|bugs)/**/*.js', 'features/**/+(o|d)*.js', 'features/**/m*.js', 'features/**/!(o|d|m)*.js'] containers: ['+(a11y|security|bugs)/**/*.js', 'features/**/+(o|d)*.js', 'features/**/m*.js', 'features/**/!(o|d|m)*.js']
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Use Node.js 16.x - name: Use Node.js 16.x
uses: actions/setup-node@v2 uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 16
- name: Cache Node Modules
id: cache-node-modules - name: Cache Node Modules and Cypress binary
uses: actions/cache@v2 uses: actions/cache@v3
id: cache-primes
with: with:
path: node_modules path: |
key: node-modules-${{ hashFiles('package-lock.json') }} node_modules
- name: Cache Cypress binary ${{ env.CYPRESS_CACHE_FOLDER }}
id: cache-cypress-binary key: ${{ runner.os }}-node-and-cypress-${{ hashFiles('package-lock.json') }}
uses: actions/cache@v2
with:
path: cypress/cache
key: cypress-binary-${{ hashFiles('package-lock.json') }}
- name: Install dependencies - name: Install dependencies
if: | if: steps.cache-primes.outputs.cache-hit != 'true'
steps.cache-node-modules.outputs.cache-hit != 'true' ||
steps.cache-cypress-binary.outputs.cache-hit != 'true'
run: npm ci run: npm ci
- name: Cypress Test - 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 }}"' run: npx start-server-and-test cy:start http://localhost:3204 'npm run cy:run -- --spec "test/e2e-cypress/tests/${{ matrix.containers }}"'