-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (113 loc) · 3.83 KB
/
node-ci-workflow.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# This workflow will build and test a Node.js project
name: Deploy to Firebase Functions via github action
on:
push:
branches: ["feature/*"]
pull_request:
branches: ["feature/*", "main"]
workflow_call:
jobs:
build:
runs-on: ubuntu-22.04
timeout-minutes: 5
permissions:
checks: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Set up Node v18
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
working-directory: .
run: find ./* -maxdepth 2 -name package.json -execdir npm ci \;
- name: Lint with ESLint
run: DEBUG=eslint:cli-engine npx eslint .
- name: Test with 'ava' and 'nyc'
id: unit-tests-step
run: |
find ./* -maxdepth 2 -name ava.config.js -print0 | \
xargs --null -I {} sh -c 'cd "$(dirname "{}")" && \
npx nyc --temp-dir="../.nyc_output" --no-clean ava --tap | \
npx tap-junit > test_report.xml && cd -'
- name: cwd
run: |
echo $(ls -alh) && echo $(ls -alh src) && \
echo $(ls -alh .nyc_output)
- name: Publish test report
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
report_paths: '**/test_report.xml'
check_name: 'Test report'
require_passed_tests: true
detailed_summary: true
include_passed: true
- name: Generate test coverage report
id: unit-tests-cov-step
run: npx nyc report --reporter lcov --reporter json-summary --reporter cobertura
- name: Get current datetime
id: current-datetime
run: echo "datetime=$(date +'%Y-%m-%d_%H-%M-%S')" >> $GITHUB_OUTPUT
- name: Upload test artifact
id: upload-test-artifact
uses: actions/upload-artifact@v4
with:
name: test-report-artifact_${{ steps.current-datetime.outputs.datetime }}
path: coverage/lcov-report
retention-days: 14
- name: Upload artifact
id: upload-artifact
uses: actions/upload-artifact@v4
with:
name: artifact
path: .nyc_output
retention-days: 1
# - name: Publish test coverage report
# uses: sidx1024/[email protected]
# with:
# coverage_file: "coverage/coverage-summary.json"
- name: cwd2
run: |
echo $(ls -alh) && echo $(ls -alh src) && echo $(ls -alh coverage) && \
cat coverage/cobertura-coverage.xml && \
cat coverage/coverage-summary.json
- name: Code Coverage Summary Report
uses: irongut/[email protected]
id: cov-report
with:
filename: coverage/cobertura-coverage.xml
badge: true
format: markdown
indicators: true
output: both
thresholds: '60 80'
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
# if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
- name: Add Coverage
id: test-id
run: |
{
echo 'summary<<='
awk '{printf "%s\\n", $0}' code-coverage-results.md
echo
echo =
} >> "$GITHUB_OUTPUT"
- name: Add d
id: test-ids
run: |
echo "${{ steps.test-id.outputs.summary }}"
- name: Add Coverage check
uses: LouisBrunner/[email protected]
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test coveragec
conclusion: ${{ job.status }}
output: |
{"summary": "${{ steps.test-id.outputs.summary }}"}