Skip to content

Commit

Permalink
ci(prod): Add unit tests and component tests
Browse files Browse the repository at this point in the history
This will also add code coverage for the main branch
  • Loading branch information
DiggidyDev authored Mar 22, 2024
1 parent 0e38c02 commit 80835c2
Showing 1 changed file with 86 additions and 2 deletions.
88 changes: 86 additions & 2 deletions .github/workflows/vercel-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,90 @@ on:
- main

jobs:
install-deps:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Cache dependencies
id: cache
uses: actions/cache@v4
with:
path: |
node_modules
~/.npm
~/.cache/Cypress
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

- if: steps.cache.outputs.cache-hit != 'true'
name: Install dependencies
run: npm ci

- if: steps.cache.outputs.cache-hit == 'true'
name: Link cached dependencies
run: npm install

unit-tests:
needs: install-deps
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Restore dependency cache
uses: actions/cache@v4
with:
path: |
node_modules
~/.npm
~/.cache/Cypress
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

- name: Link cached dependencies
run: npm install

- name: Run unit tests
run: npm run test:unit:cov

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: DiggidyDev/dockerignore-validator
files: ./coverage/lcov.info,./coverage/clover.xml

- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: coverage

test-components:
needs: install-deps
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Restore dependency cache
uses: actions/cache@v4
with:
path: |
node_modules
~/.npm
~/.cache/Cypress
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

- name: Link cached dependencies
run: npm install

- name: Run component tests
uses: cypress-io/github-action@v6
with:
install: false
component: true

test-api:
runs-on: ubuntu-latest
steps:
Expand All @@ -19,7 +103,7 @@ jobs:
api/validate
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.18"

Expand All @@ -34,7 +118,7 @@ jobs:
go test -v
deploy-prod:
needs: test-api
needs: [test-api, unit-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down

0 comments on commit 80835c2

Please sign in to comment.