-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (56 loc) · 2.29 KB
/
Copy pathTest-Unit.yml
File metadata and controls
67 lines (56 loc) · 2.29 KB
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
# Display Name of the workflow
name: Dynamic Analysis - Unit Test
# When this workflow triggers
on:
# Run the unit tests on every change
push:
branches: [main]
pull_request:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allows you to run this workflow from other workflows as a library/unit of reusable code
workflow_call:
# Define each session of execution that should be executed
jobs:
Test:
# Display name of the job
name: Code Unit Test
# Operating system filter for the runners
runs-on: ubuntu-latest
# Sets the scopes available to the github_token injected to the GH Actions runner
permissions:
contents: read
pull-requests: write
# Set of execution steps to perform
steps:
# Checkout is required before using local composite actions from this repository.
- name: Download Source Code
uses: actions/checkout@v7
# Prepare runner environment shared across CI workflows.
- name: Setup CI Environment
uses: ./.github/actions/setup-ci
# Build the project, run the unit tests, and print the coverage report into the check log
- name: Run the Unit Tests With Coverage
shell: bash
run: |
npm run coverage 2>&1 | tee coverage-output.txt
# Promote the coverage summary into the GitHub Actions job summary for easier PR review
- name: Publish Coverage Summary
run: node ./scripts/publish-coverage-summary.ts
# Create or update one coverage comment for pull request runs.
- name: Publish Coverage Report to Pull Request
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
uses: actions/github-script@v8
env:
COVERAGE_SUMMARY_FILE: coverage-summary.md
with:
script: |
const { pathToFileURL } = require('node:url');
const commentScriptUrl = pathToFileURL(`${process.env.GITHUB_WORKSPACE}/scripts/publish-coverage-comment.ts`);
const { default: publishCoverageComment } = await import(commentScriptUrl.href);
await publishCoverageComment({
github,
context,
summaryPath: process.env.COVERAGE_SUMMARY_FILE,
});