-
Notifications
You must be signed in to change notification settings - Fork 2
170 lines (164 loc) · 4.83 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
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 20
uses: actions/setup-node@v4
with:
node-version: 20
- 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 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install development dependencies
run: npm ci
- name: Build
run: npm run build
- name: Install production dependencies
run: npm ci --omit=dev
- name: Import index.js
run: node -e 'require("./dist/index")'
test:
name: Run Tests on NodeJS ${{ matrix.node }}
runs-on: ubuntu-latest
strategy:
matrix:
node: [ 16, 18, 20, 22 ]
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 == '20' && (github.event_name != 'push' || github.ref_type != 'tag' || !startsWith(github.ref_name, 'v'))
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
release:
name: Upload Release Package
if: github.event_name == 'push' && github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
needs:
- format
- lint
- build
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up NodeJS 20
uses: actions/setup-node@v4
with:
node-version: 20
- 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