-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (95 loc) · 3.01 KB
/
main-test.yml
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: main-test
on:
push:
branches:
- main
paths-ignore:
- "docs/"
- "**.md"
jobs:
test:
name: Coverage - Calculation
runs-on: ubuntu-latest
outputs:
workspaces: ${{ steps.workspaces.outputs.directories }}
steps:
# Cloning
- uses: actions/checkout@v3
# Collection
- name: Collect NPM workspaces
id: workspaces
uses: secondtruth/collect-directories-by-contained-files@v1.0.0
with:
files-glob: "*/*/package.json"
unique: true
# Setup and Caching
- name: Use latest Node.js LTS version
uses: actions/setup-node@v3
with:
node-version: lts/*
# NPM Cache using all package-lock files as hash
cache: "npm"
cache-dependency-path: "**/package-lock.json"
# Dependencies
- name: SynTest - Install Dependencies
run: npm ci
# Testing
- name: SynTest - Run Tests
# Generate lcov.info file
run: npm run test:coverage:ci
# Artifact
- name: SynTest - Upload Test Results
uses: actions/upload-artifact@v3
with:
name: coverage-results
path: ${{ github.workspace }}/**/coverage/lcov.info
# Send coverage information to Coveralls
coverage:
name: Coverage(${{ matrix.workspace }}) - Collection
needs: test
runs-on: ubuntu-latest
defaults:
run:
working-directory: "."
strategy:
# Keep running other versions when a job fails
fail-fast: false
matrix:
workspace: ${{ fromJson(needs.test.outputs.workspaces) }}
steps:
# Cloning
- uses: actions/checkout@v3
# Download test results
- uses: actions/download-artifact@v3
with:
name: coverage-results
# Check if the coverage file exists
- name: Check for coverage files
id: check_files
uses: andstor/file-existence-action@v2
with:
files: ${{ matrix.workspace }}/coverage/lcov.info
# Run the Coveralls action which uploads the lcov.info file
- name: Coveralls(${{ matrix.workspace }})
uses: coverallsapp/github-action@master
if: steps.check_files.outputs.files_exists == 'true'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# We collect all coverages in parallel
parallel: true
flag-name: ${{ matrix.workspace }}
base-path: ${{ matrix.workspace }}/
path-to-lcov: ${{ matrix.workspace }}/coverage/lcov.info
- if: steps.check_files.outputs.files_exists == 'false'
run: echo "::warning file=${{ matrix.workspace }}/coverage/lcov.info::Coverage file missing"
# Indicate sending coverage to Coveralls is finished
coverage-finished:
name: Coverage - Finish
needs: coverage
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true