-
Notifications
You must be signed in to change notification settings - Fork 9
138 lines (118 loc) · 4.59 KB
/
ci.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
name: Continuous Integration
on:
pull_request:
branches: ["*"]
push:
branches: ["*"]
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: "Install node & npm"
uses: actions/setup-node@v1
with:
node-version: 18.x
- name: "Install repository dependencies"
run: npm ci
- name: "Check code style"
run: find . -type f \( -iname \*.js -o -iname \*.jsx -o -iname \*.ts -o -iname \*.tsx \) | grep -v node_modules | grep -v /dist/ | xargs ./node_modules/.bin/prettier --check
- name: "Upload Widget (npm install)"
run: npm ci
working-directory: ./lib
- name: "Upload Widget (npm pack)"
run: npm pack
working-directory: ./lib
env:
NODE_OPTIONS: --openssl-legacy-provider
- name: "Acceptance tests (npm install)"
run:
# We use 'install' rather than 'ci' due to lack of 'packages-lock.json' in this specific
# project: we don't use 'packages-lock.json' because this project has a local dependency on
# '@bytescale/upload-widget' via tarball, which is rarely rebuilt on the developers machine, making the
# 'package-lock.json' often stale, causing 'npm ci' to fail. We don't mind using 'npm install'
# and missing out on the hash-checks, as we don't actually publish this package, so security
# isn't as much of a concern.
npm install
working-directory: ./examples
- name: "Type checks"
run: npm run typecheck
- name: "Linting"
run: npm run lint
- name: "Acceptance tests (start web server)"
run:
# Run in 'dist' mode to ensure the packaged 'uploadjs' NPM module is used,
# rather than loading '@bytescale/upload-widget' from source (for a better end-to-end test).
npm run start:dist &
working-directory: ./examples
env:
NODE_OPTIONS: --openssl-legacy-provider
- name: "Documentation (npm install)"
run: npm ci
working-directory: ./docs
- name: "Verify POLYFILLS.md up-to-date"
run: |
npm run generate-polyfills-md
changes=$(git --no-pager diff -- ../POLYFILLS.md)
if [[ ! -z "$changes" ]]; then
echo "Changes to POLYFILLS.md:"
echo ""
echo $changes
echo ""
echo "POLYFILLS.md needs updating!"
echo ""
echo "Please run the following command:"
echo ""
echo " (cd docs && npm run generate-polyfills-md)"
echo ""
exit 1
fi
working-directory: ./docs
env:
NODE_OPTIONS: --openssl-legacy-provider
# Note: we put other steps between the 'npm start' and the test runs, just to make time for the server to spin-up.
- name: "Acceptance tests"
run: npm test
working-directory: ./lib
- name: Save test report
if: always()
uses: actions/upload-artifact@v2
with:
name: test-report
path: ./lib/tmp/test-report
- name: "Publish"
if: github.ref == 'refs/heads/main'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_EC2_METADATA_DISABLED: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Automatically generated by GitHub / is not in our secrets.
NPM_AUTH_TOKEN: ${{ secrets.BYTESCALE_NPM_AUTH_TOKEN }}
NODE_OPTIONS: --openssl-legacy-provider
working-directory: ./lib
run: |
npm set //registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}
npm run publish:executeIfReleaseCommit
- name: "Notification on success"
if: github.ref == 'refs/heads/main'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: deployments
SLACK_COLOR: "#17BB5E"
SLACK_TITLE: "Built: @bytescale/upload-widget :rocket:"
SLACK_FOOTER: "This package was successfully built."
MSG_MINIMAL: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
- name: "Notification on failure"
if: github.ref == 'refs/heads/main' && failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: deployments
SLACK_COLOR: "#BB1717"
SLACK_TITLE: "Failed: @bytescale/upload-widget :boom:"
SLACK_FOOTER: "No packages published."
MSG_MINIMAL: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}