1
- # GitHub Actions workflow
2
- # https://help.github.com/en/actions/automating-your-workflow-with-github-actions
3
- # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions
4
- # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions
5
-
6
1
name : CI-CD
7
2
8
3
on :
12
7
tags-ignore :
13
8
- " *"
14
9
10
+ # run CI every Monday at 12:25 UTC
15
11
schedule :
16
- - cron : " 0 0 1 * *"
12
+ - cron : " 25 12 * * 1 "
17
13
18
14
jobs :
15
+ lint :
16
+ name : Lint
17
+ runs-on : ubuntu-latest
18
+ timeout-minutes : 10
19
+
20
+ steps :
21
+ - name : Checkout source
22
+ uses : actions/checkout@v3
23
+
24
+ - name : Install Node.js and dependencies
25
+ uses : ./.github/actions/setup
26
+
27
+ - name : Run linters
28
+ run : npm run lint
29
+
19
30
test :
20
- name : Node ${{ matrix.node }} on ${{ matrix.os }}
31
+ name : Run tests using Node ${{ matrix.node }} on ${{ matrix.os }}
21
32
runs-on : ${{ matrix.os }}
22
33
timeout-minutes : 10
23
34
strategy :
@@ -36,25 +47,19 @@ jobs:
36
47
- name : Checkout source
37
48
uses : actions/checkout@v3
38
49
39
- - name : Install Node ${{ matrix.node }}
40
- uses : actions/setup-node@v3
50
+ - name : Install Node.js ${{ matrix.node }} and dependencies
51
+ uses : ./.github/ actions/setup
41
52
with :
42
53
node-version : ${{ matrix.node }}
43
54
44
- - name : Install dependencies
45
- run : npm ci
46
-
47
- - name : Run linters
48
- run : npm run lint
49
-
50
55
- name : Build the code
51
56
run : npm run build
52
57
53
58
- name : Run tests
54
59
run : npm run coverage
55
60
56
61
- name : Send code coverage results to Coveralls
57
- uses : coverallsapp/github-action@v1.1.0
62
+ uses : coverallsapp/github-action@045a25193560dc194e405657f552faeb6b9433aa
58
63
with :
59
64
github-token : ${{ secrets.GITHUB_TOKEN }}
60
65
parallel : true
@@ -66,31 +71,132 @@ jobs:
66
71
needs : test
67
72
steps :
68
73
- name : Let Coveralls know that all tests have finished
69
- uses : coverallsapp/github-action@v1.1.0
74
+ uses : coverallsapp/github-action@045a25193560dc194e405657f552faeb6b9433aa
70
75
with :
71
76
github-token : ${{ secrets.GITHUB_TOKEN }}
72
77
parallel-finished : true
73
78
74
- deploy :
75
- name : Publish to NPM
76
- if : github.ref == 'refs/heads/master'
79
+ build :
80
+ name : Build
77
81
runs-on : ubuntu-latest
78
82
timeout-minutes : 10
79
- needs : test
80
83
81
84
steps :
82
85
- name : Checkout source
83
86
uses : actions/checkout@v3
84
87
85
- - name : Install Node
86
- uses : actions/setup-node@v3
87
-
88
- - name : Install dependencies
89
- run : npm ci
88
+ - name : Install Node.js and dependencies
89
+ uses : ./.github/actions/setup
90
90
91
- - name : Build the code
91
+ - name : Build
92
92
run : npm run build
93
93
94
+ - name : Upload publish artifact
95
+ uses : actions/upload-artifact@v3
96
+ with :
97
+ name : publish-artifact
98
+ path : lib
99
+
100
+ e2e :
101
+ name : Run end-to-end tests
102
+ runs-on : ubuntu-latest
103
+ timeout-minutes : 10
104
+ needs : build
105
+
106
+ services :
107
+ verdaccio :
108
+ image : verdaccio/verdaccio:5
109
+ ports :
110
+ - 4873:4873
111
+
112
+ steps :
113
+ - name : Checkout source
114
+ uses : actions/checkout@v3
115
+
116
+ - name : Install Node.js and dependencies
117
+ uses : ./.github/actions/setup
118
+ with :
119
+ install-command : npm install --production
120
+
121
+ - name : Download publish artifact
122
+ uses : actions/download-artifact@v3
123
+ with :
124
+ name : publish-artifact
125
+ path : lib
126
+
127
+ - id : setup
128
+ name : Login to local registry and set up fixture package
129
+ shell : bash
130
+ run : |
131
+ echo "token=$(./e2e/00-login.sh)" >> "$GITHUB_OUTPUT"
132
+ echo "package=$(./e2e/01-setup-package.sh ./e2e/fixture 0.0.1)" >> "$GITHUB_OUTPUT"
133
+
134
+ - name : Run CLI end-to-end test
135
+ shell : bash
136
+ env :
137
+ TOKEN : ${{ steps.setup.outputs.token }}
138
+ PACKAGE : ${{ steps.setup.outputs.package }}
139
+ run : |
140
+ ./e2e/02-publish.sh ${PACKAGE} ${TOKEN}
141
+ ./e2e/03-verify.sh ${PACKAGE}
142
+ ./e2e/02-publish.sh ${PACKAGE} ${TOKEN}
143
+ ./e2e/01-setup-package.sh ${PACKAGE} 0.0.2
144
+ ./e2e/02-publish.sh ${PACKAGE} ${TOKEN}
145
+ ./e2e/03-verify.sh ${PACKAGE}
146
+
147
+ - id : action-no-publish
148
+ name : Publish with already published version
149
+ uses : ./
150
+ with :
151
+ registry : http://localhost:4873
152
+ package : ${{ steps.setup.outputs.package }}/package.json
153
+ token : ${{ steps.setup.outputs.token }}
154
+
155
+ - name : Check action output
156
+ if : ${{ steps.action-no-publish.outputs.type != 'none' }}
157
+ run : |
158
+ echo "::error::Expected release type to be 'none', got '${{ steps.action-no-publish.outputs.type }}'"
159
+ exit 1
160
+
161
+ - name : Create new version for Action end-to-end test
162
+ shell : bash
163
+ run : ./e2e/01-setup-package.sh ${{ steps.setup.outputs.package }} 0.0.3
164
+
165
+ - id : action-publish
166
+ name : Publish a new version
167
+ uses : ./
168
+ with :
169
+ registry : http://localhost:4873
170
+ package : ${{ steps.setup.outputs.package }}/package.json
171
+ token : ${{ steps.setup.outputs.token }}
172
+
173
+ - name : Check release output
174
+ if : ${{ steps.action-publish.outputs.type != 'patch' }}
175
+ run : |
176
+ echo "::error::Expected release type to be 'patch', got '${{ steps.action-publish.outputs.type }}'"
177
+ exit 1
178
+
179
+ deploy :
180
+ if : ${{ github.ref == 'refs/heads/master' }}
181
+ name : Publish to NPM
182
+ runs-on : ubuntu-latest
183
+ timeout-minutes : 10
184
+ needs :
185
+ - lint
186
+ - test
187
+ - build
188
+ - e2e
189
+
190
+ steps :
191
+ - name : Checkout source
192
+ uses : actions/checkout@v3
193
+
194
+ - name : Download publish artifact
195
+ uses : actions/download-artifact@v3
196
+ with :
197
+ name : publish-artifact
198
+ path : lib
199
+
94
200
- name : Publish to NPM
95
201
uses : ./
96
202
with :
0 commit comments