-
Notifications
You must be signed in to change notification settings - Fork 45
112 lines (104 loc) · 4.44 KB
/
ci.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: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
env:
NODE_LATEST: 22.x
CI: true
defaults:
run:
shell: bash
jobs:
check-linux:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 22.x]
platform: [ubuntu-latest]
runs-on: ${{matrix.platform}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
if: github.event_name == 'pull_request' && matrix.node-version == env.NODE_LATEST
- uses: actions/checkout@v4
with:
fetch-depth: 1
if: github.event_name != 'pull_request' || matrix.node-version != env.NODE_LATEST
- uses: actions/setup-node@v4
with:
node-version: ${{matrix.node-version}}
- uses: actions/cache@v4
with:
path: node_modules
key: ${{matrix.node-version}}@${{matrix.platform}}-build-${{hashFiles('package.json')}}
restore-keys: |
${{matrix.node-version}}@${{matrix.platform}}-build-
- name: install
run: |
npm install
apt-fast --assume-yes install graphviz
- name: lint (on node ${{env.NODE_LATEST}} only)
if: matrix.node-version == env.NODE_LATEST
run: |
npm run depcruise -- --progress performance-log --cache-strategy content
npm run lint
- name: test (on node != ${{env.NODE_LATEST}} only)
if: matrix.node-version != env.NODE_LATEST
run: npm test
- name: test coverage (on node ${{env.NODE_LATEST}} only)
if: matrix.node-version == env.NODE_LATEST
run: npm run test:cover
- name: report coverage to code climate (on node ${{env.NODE_LATEST}} only)
if: matrix.node-version == env.NODE_LATEST
uses: paambaati/codeclimate-action@v5
env:
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_TEST_COVERAGE_ID }}
- name: emit coverage results & depcruise result to step summary
if: always() && matrix.node-version == env.NODE_LATEST
run: |
echo '## Code coverage' >> $GITHUB_STEP_SUMMARY
npx tsx tools/istanbul-json-summary-to-markdown.mts < coverage/coverage-summary.json >> $GITHUB_STEP_SUMMARY
yarn --silent depcruise:github-actions:markdown --progress performance-log --cache-strategy content >> $GITHUB_STEP_SUMMARY
- name: on pushes to the default branch emit graph to the step summary
if: always() && matrix.node-version == env.NODE_LATEST && github.event_name == 'push' && github.ref_name == github.event.repository.default_branch
run: |
echo '## Visual overview' >> $GITHUB_STEP_SUMMARY
echo '```mermaid' >> $GITHUB_STEP_SUMMARY
yarn --silent depcruise:github-actions:mermaid --progress performance-log --cache-strategy content >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: on pull requests emit depcruise graph to step summary with changed modules highlighted
if: always() && matrix.node-version == env.NODE_LATEST && github.event_name == 'pull_request' && github.ref_name != github.event.repository.default_branch
run: |
echo '## Visual diff' >> $GITHUB_STEP_SUMMARY
echo Modules changed in this PR have a fluorescent green color. All other modules in the graph are those directly or indirectly affected by changes in the green modules. >> $GITHUB_STEP_SUMMARY
echo '```mermaid' >> $GITHUB_STEP_SUMMARY
SHA=${{github.event.pull_request.base.sha}} yarn --silent depcruise:github-actions:mermaid:affected --progress performance-log >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: dependency review (manifest scan)
if: matrix.node-version == env.NODE_LATEST && github.event_name == 'pull_request'
uses: actions/dependency-review-action@v4
check-windows:
env:
PLATFORM: windows-latest
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{env.NODE_LATEST}}
- uses: actions/cache@v4
with:
path: node_modules
key: ${{matrix.node-version}}@${{matrix.platform}}-build-${{hashFiles('package.json')}}
restore-keys: |
${{matrix.node-version}}@${{matrix.platform}}-build-
- run: npm install
- run: npm test