-
-
Notifications
You must be signed in to change notification settings - Fork 105
274 lines (212 loc) · 9.07 KB
/
tests.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
---
name: tests
on:
push:
branches: [ master ]
pull_request:
schedule:
- cron: '0 0 * * WED,SAT' # 00:00 on Wednesdays and Saturdays, weekly.
jobs:
up-to-date:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Dependencies via Yarn
run: |
rm -rf node_modules
yarn install --frozen-lockfile
- name: Install Dependencies via NPM
run: |
rm -rf node_modules
npm ci
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci
- name: Run ESLint Check
run: npx eslint --max-warnings 0 .
docker-build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6
- name: Build and push Docker image
uses: docker/build-push-action@7f9d37fa544684fb73bfe4835ed7214c255ce02b
with:
context: .
tags: freyr-dev:latest
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/freyr-dev.tar
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: freyr-dev
path: /tmp/freyr-dev.tar
service-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
service:
- { id: spotify, name: Spotify }
- { id: apple-music, name: "Apple Music", slug: apple_music }
- { id: deezer, name: Deezer }
test:
- { type: track, name: Track }
- { type: album, name: Album }
- { type: artist, name: Artist }
- { type: playlist, name: Playlist }
name: ${{ matrix.service.id }}-${{ matrix.test.type }}
needs: docker-build
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: freyr-dev
path: /tmp
- name: Load Docker Image
run: |
docker load --input /tmp/freyr-dev.tar
docker image ls -a
- name: ${{ matrix.service.name }} - Download ${{ matrix.test.name }}
env:
DOCKER_ARGS: "--user root"
run: npm test -- --docker freyr-dev ${{ matrix.service.slug || matrix.service.id }}.${{ matrix.test.type }}
docker-publish:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Get Git SHAs
id: get-shas
run: |
BASE_SHA=$( echo ${{ github.event.pull_request.base.sha || github.sha }} | head -c7 )
echo "base_sha=$BASE_SHA" >> "$GITHUB_OUTPUT"
HEAD_SHA=$( echo ${{ github.event.pull_request.head.sha || github.sha }} | head -c7 )
echo "head_sha=$HEAD_SHA" >> "$GITHUB_OUTPUT"
- name: Get Docker Tag
id: docker-tagger-spec
run: |
if [[ "${{ github.event_name }}" == 'push' ]]; then
echo "spec=type=ref,event=branch" >> "$GITHUB_OUTPUT"
elif [[ "${{ github.event_name }}" == 'pull_request' ]]; then
echo "spec=type=ref,event=pr" >> "$GITHUB_OUTPUT"
fi
- name: Extract Metadata (tags, labels) For Docker
id: docker-meta
uses: docker/metadata-action@e5622373a38e60fb6d795a4421e56882f2d7a681
with:
images: freyrcli/freyrjs-git
tags: |
${{ steps.docker-tagger-spec.outputs.spec }}
type=raw,value=${{ steps.get-shas.outputs.head_sha }}
- name: Extract Tag For Report
id: tag-for-report
if: github.event_name == 'pull_request'
run: |
PR_TAG=$( echo "${{ steps.docker-meta.outputs.tags }}" | head -1 | sed 's/freyrcli\/freyrjs-git://g' )
echo "tag=$PR_TAG" >> "$GITHUB_OUTPUT"
- name: Report Docker Image Build Status
uses: marocchino/sticky-pull-request-comment@39c5b5dc7717447d0cba270cd115037d32d28443
if: github.event_name == 'pull_request'
with:
message: |
<div align=center>
---
🐋 🤖
🔃
**A docker image for this PR is being built!**
```console
docker pull freyrcli/freyrjs-git:${{ steps.tag-for-report.outputs.tag }}
```
| [**Base (${{ github.event.pull_request.base.ref }})**][base-url] | [![](https://img.shields.io/docker/image-size/freyrcli/freyrjs-git/${{ steps.get-shas.outputs.base_sha }}?color=gray&label=%20&logo=docker)][base-url] |
| :-: | - |
---
<details>
<summary>What's this?</summary>
This docker image is a self-contained sandbox that includes all the patches made in this PR. Allowing others to easily use your patches without waiting for it to get merged and released officially.
For more context, see https://github.com/miraclx/freyr-js#docker-development.
</details>
</div>
[base-url]: https://hub.docker.com/r/freyrcli/freyrjs-git/tags?name=${{ steps.get-shas.outputs.base_sha }}
- name: Set up QEMU
uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6
- name: Log in to Docker Hub
uses: docker/login-action@42d299face0c5c43a0487c477f595ac9cf22f1a7
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@7f9d37fa544684fb73bfe4835ed7214c255ce02b
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.docker-meta.outputs.tags }}
labels: ${{ steps.docker-meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Report Docker Image Build Status
uses: marocchino/sticky-pull-request-comment@39c5b5dc7717447d0cba270cd115037d32d28443
if: github.event_name == 'pull_request'
with:
message: |
<div align=center>
---
🐋 🤖
**A docker image for this PR has been built!**
```console
docker pull freyrcli/freyrjs-git:${{ steps.tag-for-report.outputs.tag }}
```
| [**Base (${{ github.event.pull_request.base.ref }})**][base-url] | [![](https://img.shields.io/docker/image-size/freyrcli/freyrjs-git/${{ steps.get-shas.outputs.base_sha }}?color=gray&label=%20&logo=docker)][base-url] |
| :-: | - |
| [**This Patch**][pr-url] | [![](https://img.shields.io/docker/image-size/freyrcli/freyrjs-git/${{ steps.tag-for-report.outputs.tag }}?color=gray&label=%20&logo=docker)][pr-url] |
[![][compare-img]][compare-url]
---
<details>
<summary>What's this?</summary>
This docker image is a self-contained sandbox that includes all the patches made in this PR. Allowing others to easily use your patches without waiting for it to get merged and released officially.
For more context, see https://github.com/miraclx/freyr-js#docker-development.
</details>
</div>
[base-url]: https://hub.docker.com/r/freyrcli/freyrjs-git/tags?name=${{ steps.get-shas.outputs.base_sha }}
[pr-url]: https://hub.docker.com/r/freyrcli/freyrjs-git/tags?name=${{ steps.tag-for-report.outputs.tag }}
[compare-img]: https://img.shields.io/badge/%20-compare-gray?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+CiAgIDxwYXRoIGZpbGw9IiNmZmZmZmYiIGQ9Ik0zLDFDMS44OSwxIDEsMS44OSAxLDNWMTRDMSwxNS4xMSAxLjg5LDE2IDMsMTZINVYxNEgzVjNIMTRWNUgxNlYzQzE2LDEuODkgMTUuMTEsMSAxNCwxSDNNOSw3QzcuODksNyA3LDcuODkgNyw5VjExSDlWOUgxMVY3SDlNMTMsN1Y5SDE0VjEwSDE2VjdIMTNNMTgsN1Y5SDIwVjIwSDlWMThIN1YyMEM3LDIxLjExIDcuODksMjIgOSwyMkgyMEMyMS4xMSwyMiAyMiwyMS4xMSAyMiwyMFY5QzIyLDcuODkgMjEuMTEsNyAyMCw3SDE4TTE0LDEyVjE0SDEyVjE2SDE0QzE1LjExLDE2IDE2LDE1LjExIDE2LDE0VjEySDE0TTcsMTNWMTZIMTBWMTRIOVYxM0g3WiIgLz4KPC9zdmc+
[compare-url]: https://portal.slim.dev/home/diff/dockerhub%3A%2F%2Fdockerhub.public%2Ffreyrcli%2Ffreyrjs-git%3A${{ steps.tag-for-report.outputs.tag }}#file-system
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
- name: Install Dependencies
run: npm ci
- name: Lint Code Base
uses: github/super-linter@v5
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JSCPD_CONFIG_FILE: .jscpd.json
GITLEAKS_CONFIG_FILE: .gitleaks.toml
VALIDATE_JAVASCRIPT_ES: false
VALIDATE_JAVASCRIPT_STANDARD: false