Skip to content

Commit cb43934

Browse files
Switched from Travis CI to GitHub Actions
1 parent 8d4ce67 commit cb43934

File tree

3 files changed

+81
-11
lines changed

3 files changed

+81
-11
lines changed

.github/workflows/CI-CD.yaml

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ on:
1515
schedule:
1616
- cron: "0 0 1 * *"
1717

18-
env:
19-
CI: true
20-
2118
jobs:
22-
test:
19+
node_tests:
2320
name: Node ${{ matrix.node }} on ${{ matrix.os }}
2421
runs-on: ${{ matrix.os }}
2522
timeout-minutes: 10
@@ -46,7 +43,7 @@ jobs:
4643
- name: Install dependencies
4744
run: npm ci
4845

49-
- name: Run linters
46+
- name: Run linter
5047
run: npm run lint
5148

5249
- name: Build the code
@@ -55,10 +52,49 @@ jobs:
5552
- name: Run TypeScript tests
5653
run: npm run test:typescript
5754

58-
- name: Run JavaScript tests
59-
run: npm run coverage
55+
- name: Run Node tests
56+
run: npm run coverage:node
57+
58+
- name: Send code coverage results to Coveralls
59+
uses: coverallsapp/github-action@v1.0.1
60+
with:
61+
github-token: ${{ secrets.GITHUB_TOKEN }}
62+
parallel: true
63+
64+
browser_tests:
65+
name: Browser Tests
66+
runs-on: ${{ matrix.os }}
67+
timeout-minutes: 10
68+
strategy:
69+
fail-fast: true
70+
matrix:
71+
os:
72+
- ubuntu-latest # Chrome, Firefox, Safari (via SauceLabs), Edge (via SauceLabs)
73+
- windows-latest # Internet Explorer
74+
75+
steps:
76+
- name: Checkout source
77+
uses: actions/checkout@v2
78+
79+
- name: Install Node
80+
uses: actions/setup-node@v1
81+
with:
82+
node-version: 12
83+
84+
- name: Install dependencies
85+
run: npm ci
86+
87+
- name: Build the code
88+
run: npm run build
89+
90+
- name: Run tests
91+
run: npm run coverage:browser
92+
env:
93+
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
94+
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
6095

6196
- name: Combine code coverage data into a single file
97+
shell: bash
6298
run: |
6399
ls -Rlh coverage/*/lcov.info
64100
cat coverage/*/lcov.info > ./coverage/lcov.info
@@ -73,10 +109,39 @@ jobs:
73109
name: Code Coverage
74110
runs-on: ubuntu-latest
75111
timeout-minutes: 10
76-
needs: test
112+
needs:
113+
- node_tests
114+
- browser_tests
77115
steps:
78116
- name: Let Coveralls know that all tests have finished
79117
uses: coverallsapp/github-action@v1.0.1
80118
with:
81119
github-token: ${{ secrets.GITHUB_TOKEN }}
82120
parallel-finished: true
121+
122+
deploy:
123+
name: Publish to NPM
124+
if: github.ref == 'refs/heads/master'
125+
runs-on: ubuntu-latest
126+
timeout-minutes: 10
127+
needs:
128+
- node_tests
129+
- browser_tests
130+
131+
steps:
132+
- name: Checkout source
133+
uses: actions/checkout@v2
134+
135+
- name: Install Node
136+
uses: actions/setup-node@v1
137+
138+
- name: Install dependencies
139+
run: npm ci
140+
141+
- name: Build the code
142+
run: npm run build
143+
144+
- name: Publish to NPM
145+
uses: JS-DevTools/npm-publish@v1
146+
with:
147+
token: ${{ secrets.NPM_TOKEN }}

karma.conf.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
33
// https://jstools.dev/karma-config/
44

55
"use strict";
6-
const { karmaConfig } = require("karma-config");
6+
const { karmaConfig } = require("@jsdevtools/karma-config");
7+
const { host } = require("@jsdevtools/host-environment");
78

89
module.exports = karmaConfig({
910
sourceDir: "esm",
1011
fixtures: "test/fixtures/**/*.js",
1112
browsers: {
12-
ie: true,
13+
chrome: true,
14+
firefox: host.os.linux,
15+
safari: host.os.linux, // SauceLabs
16+
edge: host.os.linux, // SauceLabs
17+
ie: host.os.windows,
1318
},
1419
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"test:browser": "karma start --single-run",
5050
"test:typescript": "tsc --noEmit test/specs/typescript.spec.ts",
5151
"coverage": "npm run coverage:node && npm run coverage:browser",
52-
"coverage:node": "nyc --reporter=text --reporter=lcov --report-dir coverage/node node_modules/mocha/bin/mocha",
52+
"coverage:node": "nyc --reporter=text --reporter=lcov node_modules/mocha/bin/mocha",
5353
"coverage:browser": "npm run test:browser -- --coverage",
5454
"upgrade": "npm-check -u && npm audit fix",
5555
"bump": "bump --tag --push --all",

0 commit comments

Comments
 (0)