Skip to content

Commit f2050f9

Browse files
authored
tests: setup GitHub Actions to replace Travis (#1497)
Additionally adds testing against many Node.js versions and Redis versions.
1 parent 61318e6 commit f2050f9

File tree

13 files changed

+204
-62
lines changed

13 files changed

+204
-62
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ rules:
102102
globals:
103103
it: true
104104
describe: true
105+
xdescribe: true
105106
before: true
106107
after: true
107108
beforeEach: true

.github/workflows/benchmark.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Benchmarking
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
benchmark:
7+
name: Benchmark
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
node-version: [8.x, 10.x, 12.x]
13+
redis-version: [5]
14+
15+
steps:
16+
- uses: actions/checkout@v1
17+
with:
18+
fetch-depth: 1
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
25+
- name: Setup Redis
26+
uses: shogo82148/actions-setup-redis@v1.0.1
27+
with:
28+
redis-version: ${{ matrix.redis-version }}
29+
auto-start: "true"
30+
31+
- run: npm i --no-audit --prefer-offline
32+
- name: Run Benchmark
33+
run: npm run benchmark > benchmark-output.txt && cat benchmark-output.txt
34+
- name: Upload Benchmark Result
35+
uses: actions/upload-artifact@v1
36+
with:
37+
name: benchmark-output.txt
38+
path: benchmark-output.txt

.github/workflows/linting.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Linting
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
eslint:
7+
name: ESLint
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v1
11+
with:
12+
fetch-depth: 1
13+
- uses: actions/setup-node@v1
14+
with:
15+
node-version: 12
16+
- run: npm i --no-audit --prefer-offline
17+
- name: Test Code Linting
18+
run: npm run lint
19+
- name: Save Code Linting Report JSON
20+
run: npm run lint:report
21+
continue-on-error: true
22+
- name: Annotate Code Linting Results
23+
uses: ataylorme/eslint-annotate-action@1.0.4
24+
with:
25+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
26+
report-json: "eslint-report.json"
27+
- name: Upload ESLint report
28+
uses: actions/upload-artifact@v1
29+
with:
30+
name: eslint-report.json
31+
path: eslint-report.json

.github/workflows/tests.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Tests
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
testing:
7+
name: Test
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
node-version: [6.x, 8.x, 10.x, 12.x]
13+
redis-version: [4.x, 5.x]
14+
15+
steps:
16+
- uses: actions/checkout@v1
17+
with:
18+
fetch-depth: 1
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
25+
- name: Setup Redis
26+
uses: shogo82148/actions-setup-redis@v1.0.1
27+
with:
28+
redis-version: ${{ matrix.redis-version }}
29+
auto-start: "false"
30+
31+
- name: Disable IPv6
32+
run: sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6';
33+
34+
- name: Setup Stunnel
35+
run: sudo apt-get install stunnel4
36+
37+
- name: Install Packages
38+
run: npm i --no-audit --prefer-offline
39+
40+
- name: Run Tests
41+
run: npm test
42+
43+
- name: Submit Coverage
44+
run: npm run coveralls
45+
env:
46+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
47+
48+
- name: Upload Coverage Report
49+
uses: actions/upload-artifact@v1
50+
with:
51+
name: coverage
52+
path: coverage
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Tests Windows
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
testing-windows:
7+
name: Test Windows
8+
runs-on: windows-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
node-version: [6.x, 8.x, 10.x, 12.x]
13+
steps:
14+
- uses: actions/checkout@v1
15+
with:
16+
fetch-depth: 1
17+
18+
- name: Install Redis
19+
uses: crazy-max/ghaction-chocolatey@v1
20+
with:
21+
args: install redis-64 --no-progress
22+
23+
- name: Start Redis
24+
run: |
25+
redis-server --service-install
26+
redis-server --service-start
27+
redis-cli config set stop-writes-on-bgsave-error no
28+
29+
- name: Setup Node.js ${{ matrix.node-version }}
30+
uses: actions/setup-node@v1
31+
with:
32+
node-version: ${{ matrix.node-version }}
33+
34+
- name: Install Packages
35+
run: npm i --no-audit --prefer-offline
36+
37+
- name: Run Tests
38+
run: npm test
39+
40+
- name: Submit Coverage
41+
run: npm run coveralls
42+
env:
43+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
44+
45+
- name: Upload Coverage Report
46+
uses: actions/upload-artifact@v1
47+
with:
48+
name: coverage
49+
path: coverage

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ package-lock.json
1414
# VisualStudioCode IDEs
1515
.vscode
1616
.vs
17+
eslint-report.json

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ CODE_OF_CONDUCT.md
1919
appveyor.yml
2020
package-lock.json
2121
.prettierrc
22+
eslint-report.json

.travis.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
"coveralls": "nyc report --reporter=text-lcov | coveralls",
3131
"coverage": "nyc report --reporter=html",
3232
"benchmark": "node benchmarks/multi_bench.js",
33-
"test": "nyc --cache mocha ./test/*.js ./test/commands/*.js --timeout=8000",
34-
"lint": "eslint . --fix && npm run coverage",
33+
"test": "nyc --cache mocha ./test/*.js ./test/commands/*.js --timeout=8000 && npm run coverage",
34+
"lint": "eslint .",
35+
"lint:fix": "eslint . --fix",
36+
"lint:report": "eslint --output-file=eslint-report.json --format=json .",
3537
"compare": "node benchmarks/diff_multi_bench_output.js beforeBench.txt afterBench.txt"
3638
},
3739
"dependencies": {

test/commands/zadd.spec.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ describe("The 'zadd' method", function () {
3434
client.zrange('infinity', 0, -1, 'WITHSCORES', function (err, res) {
3535
assert.equal(res[5], 'inf');
3636
assert.equal(res[1], '-inf');
37-
assert.equal(res[3], '9.9999999999999992e+22');
37+
if (process.platform !== 'win32') {
38+
assert.equal(res[3], '9.9999999999999992e+22');
39+
} else {
40+
assert.equal(res[3], '9.9999999999999992e+022');
41+
}
3842
done();
3943
});
4044
});

0 commit comments

Comments
 (0)