-
Notifications
You must be signed in to change notification settings - Fork 1
190 lines (184 loc) · 5.74 KB
/
node.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Tests
on:
push:
branches:
- main
- dccboxed-*
- validation
tags:
- 'v*'
pull_request:
branches:
- main
- dccboxed-*
jobs:
format:
name: Check Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Select reviewdog reporter
id: get-reporter
run: |
if test "${{ github.event_name }}" = "pull_request"; then
echo "::set-output name=reporter::github-pr-review"
else
echo "::set-output name=reporter::github-check"
fi
- name: Run prettier with reviewdog
uses: kazkansouh/reviewdog-action-prettier@v1
with:
github_token: ${{ secrets.github_token }}
reporter: ${{ steps.get-reporter.outputs.reporter }}
level: error
prettier_flags: src/**/*.{css,html,ts,json,md,yaml,yml}
fail_on_error: true
- name: Run prettier (catch all)
if: github.event_name == 'pull_request'
run: npm run prettier-check
lint:
name: Check Static Errors
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
- name: Select reviewdog reporter
id: get-reporter
run: |
if test "${{ github.event_name }}" = "pull_request"; then
echo "::set-output name=reporter::github-pr-review"
else
echo "::set-output name=reporter::github-check"
fi
- name: Set up NodeJS 16
uses: actions/setup-node@v4
with:
node-version: 16
- name: Install dependencies
run: npm ci
- name: Run eslint with reviewdog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run lint | reviewdog -f=eslint -reporter=${{ steps.get-reporter.outputs.reporter }} -fail-on-error
- name: Run prettier (catch all)
if: github.event_name == 'pull_request'
run: npm run lint
build:
name: Compile TypeScript
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up NodeJS ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: 16
- name: Install development dependencies
run: npm ci
- name: Build
run: npm run build
- name: Install production dependencies
run: npm ci --omit=dev
- name: Import duis-template.js
run: node -e 'require("./dist/duis-template")'
- name: Import duis-construct.js
run: node -e 'require("./dist/duis-construct")'
- name: Import duis-sign.js
run: node -e 'require("./dist/duis-sign")'
- name: Import duis-parser.js
run: node -e 'require("./dist/duis-parser")'
- name: Import dccboxed-config.js
run: node -e 'require("./dist/dccboxed-config")'
- name: Import dccboxed-send.js
run: node -e 'require("./dist/dccboxed-send")'
- name: Import dccboxed-receive.js
run: node -e 'require("./dist/dccboxed-receive")'
- name: Import gbcs-parser.js
run: node -e 'require("./dist/gbcs-parser")'
- name: Import gbcs-signer.js
run: node -e 'require("./dist/gbcs-signer")'
- name: Import gbcs-utrn.js
run: node -e 'require("./dist/gbcs-utrn")'
- name: Import duis-tariff.js
run: node -e 'require("./dist/duis-tariff")'
test:
if: false # disable as currently no test cases
name: Run Tests on NodeJS ${{ matrix.node }}
runs-on: ubuntu-latest
strategy:
matrix:
node: [ 16, 18 ]
steps:
- uses: actions/checkout@v4
- name: Install reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
- name: Select reviewdog reporter
id: get-reporter
run: |
if test "${{ github.event_name }}" = "pull_request"; then
echo "::set-output name=reporter::github-pr-review"
else
echo "::set-output name=reporter::github-check"
fi
- name: Set up NodeJS ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test:cov
- name: Upload coverage to Codecov
if: matrix.node == '16' && (github.event_name != 'push' || github.ref_type != 'tag' || !startsWith(github.ref_name, 'v'))
uses: codecov/codecov-action@v4
release:
name: Upload Release Package
if: github.event_name == 'push' && github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
needs:
- format
- lint
- build
# Remove test dependency as no test coverage
# - test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up NodeJS 16
uses: actions/setup-node@v4
with:
node-version: 16
- name: Install dependencies
run: npm ci
- name: Build package
run: npm pack
- name: Extract version from package.json
uses: sergeysova/jq-action@v2
id: version
with:
cmd: 'jq .version package.json -r'
- name: Check package version
run: |
version=$(echo ${{ github.ref_name }} | cut -c2-)
if test "${version}" = "${{ steps.version.outputs.value }}"; then
echo "version ok"
else
echo "Error: tag ${{ github.ref_name }} and package version ${version} do not match" 1>&2
exit 1
fi
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: smartdcc-*tgz
file_glob: true
tag: ${{ github.ref }}
overwrite: true
body: "Release ${{ github.ref_name }}"
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_PUBLISH_TOKEN }}
access: public