Skip to content

Commit 7989f42

Browse files
author
Paul Boocock
committed
Switch to Github Actions (close #844)
1 parent af7f71e commit 7989f42

20 files changed

+4784
-321
lines changed

.github/workflows/build.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- '**' # Prevents builds on tag
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
env:
14+
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
15+
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
21+
- name: Use Node.js 12
22+
uses: actions/setup-node@v1
23+
with:
24+
node-version: 12.x
25+
26+
- name: npm cache
27+
uses: actions/cache@v2
28+
with:
29+
path: ~/.npm
30+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
31+
restore-keys: ${{ runner.os }}-node-
32+
33+
- name: Core npm ci
34+
working-directory: ./core
35+
run: npm ci
36+
37+
- name: Build core
38+
working-directory: ./core
39+
run: npm run build
40+
41+
- name: Test core
42+
working-directory: ./core
43+
run: npm run test
44+
45+
- name: Tracker npm ci
46+
run: npm ci
47+
48+
- name: Build tracker
49+
run: npm run build
50+
51+
- name: Test tracker
52+
run: npm run test:unit
53+
54+
- name: Block Concurrent Executions of E2E Tests
55+
if: ${{ env.SAUCE_ACCESS_KEY != '' }}
56+
uses: softprops/turnstyle@v1
57+
with:
58+
poll-interval-seconds: 10
59+
same-branch-only: false
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
63+
- name: Add Host for Saucelabs Tunnel
64+
if: ${{ env.SAUCE_ACCESS_KEY != '' }}
65+
run: echo "127.0.0.1 snowplow-js-tracker.local" | sudo tee -a /etc/hosts
66+
67+
- name: Run End to End Tests
68+
run: npm run test:e2e:sauce
69+
if: ${{ env.SAUCE_ACCESS_KEY != '' }}
70+
71+
- name: Upload sp.js artifact
72+
uses: actions/upload-artifact@v2
73+
with:
74+
name: sp.js
75+
path: dist/sp.js
76+

.github/workflows/deploy_core.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Deploy Core
2+
3+
on:
4+
push:
5+
tags:
6+
- 'core/*.*.*'
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
defaults:
13+
run:
14+
working-directory: core
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
20+
- name: Use Node.js 12
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: 12
24+
registry-url: https://registry.npmjs.org/
25+
26+
- name: npm cache
27+
uses: actions/cache@v2
28+
with:
29+
path: ~/.npm
30+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
31+
restore-keys: ${{ runner.os }}-node-
32+
33+
- run: npm ci
34+
35+
- name: Build core
36+
run: npm run build
37+
38+
- name: Test core
39+
run: npm run test
40+
41+
- name: Get tag and tracker version information
42+
id: version
43+
run: |
44+
echo ::set-output name=TAG_VERSION::${GITHUB_REF#refs/*/}
45+
echo "##[set-output name=TRACKER_VERSION;]$(node -p "require('./package.json').version")"
46+
47+
- name: Fail if version mismatch
48+
if: ${{ steps.version.outputs.TAG_VERSION != format('core/{0}', steps.version.outputs.TRACKER_VERSION) }}
49+
run: |
50+
echo "Tag version (${{ steps.version.outputs.TAG_VERSION }}) doesn't match version in project (${{ format('core/{0}', steps.version.outputs.TRACKER_VERSION) }})"
51+
exit 1
52+
53+
- name: Publish
54+
run: npm publish
55+
env:
56+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Deploy Tracker
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
env:
13+
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
14+
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
20+
- name: Use Node.js 12
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: 12
24+
25+
- name: npm cache
26+
uses: actions/cache@v2
27+
with:
28+
path: ~/.npm
29+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
30+
restore-keys: ${{ runner.os }}-node-
31+
32+
- name: Core npm ci
33+
working-directory: ./core
34+
run: npm ci
35+
36+
- name: Build core
37+
working-directory: ./core
38+
run: npm run build
39+
40+
- name: Test core
41+
working-directory: ./core
42+
run: npm run test
43+
44+
- name: Tracker npm ci
45+
run: npm ci
46+
47+
- name: Build tracker
48+
run: npm run build
49+
50+
- name: Test tracker
51+
run: npm run test:unit
52+
53+
- name: Block Concurrent Executions of E2E Tests
54+
if: ${{ env.SAUCE_ACCESS_KEY != '' }}
55+
uses: softprops/turnstyle@v1
56+
with:
57+
poll-interval-seconds: 10
58+
same-branch-only: false
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
62+
- name: Add Host for Saucelabs Tunnel
63+
if: ${{ env.SAUCE_ACCESS_KEY != '' }}
64+
run: echo "127.0.0.1 snowplow-js-tracker.local" | sudo tee -a /etc/hosts
65+
66+
- name: Run End to End Tests
67+
run: npm run test:e2e:sauce
68+
if: ${{ env.SAUCE_ACCESS_KEY != '' }}
69+
70+
- name: Get tag and tracker version information
71+
id: version
72+
run: |
73+
echo ::set-output name=TAG_VERSION::${GITHUB_REF#refs/*/}
74+
echo "##[set-output name=TRACKER_VERSION;]$(node -p "require('./package.json').version")"
75+
76+
- name: Fail if version mismatch
77+
if: ${{ steps.version.outputs.TAG_VERSION != steps.version.outputs.TRACKER_VERSION }}
78+
run: |
79+
echo "Tag version (${{ steps.version.outputs.TAG_VERSION }}) doesn't match version in project (${{ steps.version.outputs.TRACKER_VERSION }})"
80+
exit 1
81+
82+
- name: Create release
83+
id: create_release
84+
uses: actions/create-release@v1
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
with:
88+
tag_name: ${{ github.ref }}
89+
release_name: Snowplow JavaScript Tracker v${{ github.ref }}
90+
draft: false
91+
prerelease: ${{ contains(steps.version.outputs.TAG_VERSION, '-M') }}
92+
93+
- name: Upload sp.js asset
94+
uses: actions/upload-release-asset@v1
95+
env:
96+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97+
with:
98+
upload_url: ${{ steps.create_release.outputs.upload_url }}
99+
asset_path: ./dist/sp.js
100+
asset_name: sp.js
101+
asset_content_type: application/javascript

.github/workflows/snyk.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@ jobs:
1313
node-version: 12
1414

1515
- name: Run npm install on Core
16-
run: npm install
16+
run: npm ci
1717
working-directory: ./core
1818

19-
- name: Link Core to Tracker
20-
run: npm link ./core
21-
2219
- name: Run npm intall on Tracker
23-
run: npm install
20+
run: npm ci
2421

2522
- name: Run Snyk to check for vulnerabilities
2623
uses: snyk/actions/node@master

.travis.yml

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

0 commit comments

Comments
 (0)