Skip to content

tests

tests #1675

Workflow file for this run

---
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