-
Notifications
You must be signed in to change notification settings - Fork 43
79 lines (68 loc) · 2.63 KB
/
api-jest-coverage.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Express API - Jest Test Coverage
on:
pull_request:
types: [opened, synchronize] # Triggered by opened or changed pull requests.
branches: [main]
paths:
- '.github/workflows/api-jest-coverage.yaml'
- 'express-api/**' # Triggers on changes to files in the express-api/ directory.
- '!express-api/.eslintrc.cjs' # Will not trigger on changes to the following.
- '!express-api/.gitignore'
- '!express-api/prettierrc.cjs'
- '!express-api/Dockerfile*'
- '!express-api/tsconfig.json'
- '!express-api/README.md'
jobs:
codeclimate-jest-coverage:
runs-on: ubuntu-latest
env:
GIT_BRANCH: ${{ github.event.pull_request.head.ref }}
GIT_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
FRONTEND_URL: ${{ secrets.FRONTEND_URL }}
BACKEND_URL: ${{ secrets.BACKEND_URL }}
SSO_CLIENT_ID: ${{ secrets.SSO_CLIENT_ID }}
SSO_CLIENT_SECRET: ${{ secrets.SSO_CLIENT_SECRET }}
CC_TEST_REPORTER_ID: 37fdb6f058122c17fc2419b78b02b1d5582694f7cd84a2b735de8eec235e9c5b
steps:
# Confirm GitHub ENVs.
- name: Echo ENVs
run: |
echo $GIT_BRANCH
echo $GIT_COMMIT_SHA
# Checkout code from Repo.
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
# Import Code Climate test reporter.
- name: Import Code Climate
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
# Allow test reporter to be executed.
- name: Execute Permissions for Code Climate Binary
run: |
chmod +x ./cc-test-reporter
# Notifies Code Climate of impending report.
- name: Test Reporter Before Build
run: |
./cc-test-reporter before-build
# Install dependencies.
- name: Install Dependencies
working-directory: ./express-api
run: |
npm i
# Generate coverage report.
- name: Run Coverage Report
working-directory: ./express-api
run: |
npm run coverage
# Use lcov to format coverage for Code Climate
# -t is for coverage type
- name: Format Test Coverage
run: |
./cc-test-reporter format-coverage ${{ github.workspace }}/express-api/coverage/lcov.info -t lcov --output ${{ github.workspace }}/express-api/coverage/coverage.json
# Upload coverage to Code Climate.
# -i is for input, -d for detached
- name: Upload Coverage
run: |
./cc-test-reporter upload-coverage -d -i ${{ github.workspace }}/express-api/coverage/coverage.json