forked from jandre/node-userid
-
Notifications
You must be signed in to change notification settings - Fork 9
200 lines (142 loc) · 5.99 KB
/
main.yml
File metadata and controls
200 lines (142 loc) · 5.99 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
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
191
192
193
194
195
196
197
198
199
200
name: Main
on:
create:
push:
branches-ignore:
- 'npm-check-updates'
pull_request:
jobs:
install-and-run-from-git:
name: Test - Install & Run from Github
runs-on: ubuntu-latest
steps:
- name: Enable color for Npm output
run: echo color = always >> .npmrc
- name: Checkout latest code
uses: actions/checkout@v1
- name: Install Node dependencies without building locally
run: npm ci --ignore-scripts
- name: 'Debug: List post build files'
run: find * \( -path node_modules -o -path .git \) -print -prune -o -type f -print | tee /tmp/build.list
# Prepare Test Environment
- name: Create Dummy Package.json
run: echo \{\} > test/package.json
- name: Install Current Version as Git Dependency
working-directory: test
run: npm install ${{ github.repository }}#${{ github.sha }}
- name: 'Debug: List Dependency Folder Contents'
working-directory: test
run: find node_modules/userid -type f -print
# Ensure the code works
- name: Add long username for test
run: sudo useradd UsernameWithMoreThan15Chars
- name: Add long groupname for test
run: sudo useradd GroupnameWithMoreThan15Chars
- name: Run Tests with Prepared Git Dependency
run: npm test -- --color
env:
MOCHA_IMPORT_OVERRIDE: userid
LONG_USERNAME_TEST: UsernameWithMoreThan15Chars
LONG_GROUPNAME_TEST: GroupnameWithMoreThan15Chars
test-native-api:
# We fully support importing/requiring the native API `.node` directly.
# For historical reasons, the Native Node API is slightly different than the JavaScript API, so we have slightly different tests.
name: Test - Native API Stability
runs-on: ubuntu-latest
steps:
- name: Enable color for Npm output
run: echo color = always >> .npmrc
- name: Checkout latest code
uses: actions/checkout@v1
- name: Install Node dependencies without building locally
run: npm ci
- name: 'Debug: List post build files'
run: find * \( -path node_modules -o -path .git \) -print -prune -o -type f -print | tee /tmp/build.list
- name: Add long username for test
run: sudo useradd UsernameWithMoreThan15Chars
- name: Add long groupname for test
run: sudo useradd GroupnameWithMoreThan15Chars
- name: Run Tests with Prepared Git Dependency
run: npm test -- --color
env:
MOCHA_IMPORT_OVERRIDE: ../build/Release/userid.node
MOCHA_USE_NODE_API: true
LONG_USERNAME_TEST: UsernameWithMoreThan15Chars
LONG_GROUPNAME_TEST: GroupnameWithMoreThan15Chars
checks:
name: Check - Formatting, Spelling, & Linting
runs-on: ubuntu-latest
steps:
- name: Enable color for Npm output
run: echo color = always >> .npmrc
- name: Install clang-tidy
run: sudo apt-get install clang-tidy
- name: Checkout latest code
uses: actions/checkout@v1
- name: Install Node dependencies and build
run: npm ci
- name: Run Formatting Checks
# We allow any line endings in code but always commit and expect only LF
run: npm run prettier -- --end-of-line lf
- name: Run Spelling Checks
run: npm run spelling
- name: Run Lint Checks
run: npm run lint #-- --use-color # Color needs clang-tidy >= 11.0.0
coverage:
needs: [test-native-api, install-and-run-from-git]
name: Generate - Coverage Reports
runs-on: ubuntu-latest
steps:
- name: Enable color for Npm output
run: echo color = always >> .npmrc
- name: Checkout latest code
uses: actions/checkout@v1
- name: Install Lcov
run: sudo apt-get install lcov -y
- name: 'Debug: Node version'
run: node --version
- name: Build
run: npm ci
env:
# Turns on Gcov instrumentation in compiled binaries
GENERATE_COVERAGE: 'yes'
- name: 'Debug: List post build files'
run: find * \( -path node_modules -o -path .git \) -print -prune -o -type f -print | tee /tmp/build.list
- name: Test Coverage of JavaScript
run: npm run coverage
- name: 'Debug: List post Coverage files'
run: find * \( -path node_modules -o -path .git \) -print -prune -o -type f -print | tee /tmp/coverage.list
- name: 'Debug: Coverage diff'
run: 'diff -U 0 /tmp/build.list /tmp/coverage.list || :'
- name: Lcov Capture Gcov Data
run: lcov --capture --directory . --output-file coverage/cc.info
- name: Extract Our C++ Sources' Coverage Data
run: lcov --extract coverage/cc.info '*.cc' --output-file coverage/cc.info
- name: Combine Our C++ Sources' Coverage Data with JavaScript's Coverage Data
run: lcov --add-tracefile coverage/cc.info --add-tracefile coverage/lcov.info --output-file coverage/lcov.info
- name: 'Debug: Print coverage report'
run: lcov --list coverage/lcov.info
- name: 'Debug: List post lcov files'
run: find * \( -path node_modules -o -path .git \) -print -prune -o -type f -print | tee /tmp/lcov.list
- name: 'Debug: lcov diff'
run: 'diff -U 0 /tmp/coverage.list /tmp/lcov.list || :'
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v1.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
publish:
name: Publish - Master
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [coverage, install-and-run-from-git, checks]
steps:
- name: Enable color for Npm output
run: echo color = always >> .npmrc
- name: Checkout latest code
uses: actions/checkout@v1
- name: Create .npmrc with Auth Token
run: echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc
- name: Publish to npm
run: npm publish
env:
NPM_TOKEN: ${{ secrets.npm_token }}