mirror of
https://github.com/FoxxMD/multi-scrobbler.git
synced 2026-08-30 02:52:09 +00:00
71 lines
2.1 KiB
YAML
71 lines
2.1 KiB
YAML
name: Tests and Sanity Run
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
node-version:
|
|
description: "Node version"
|
|
required: false
|
|
default: '24.x'
|
|
type: string
|
|
ref:
|
|
description: "Ref to checkout"
|
|
required: false
|
|
type: string
|
|
|
|
jobs:
|
|
test:
|
|
name: Tests / Build / Sanity Run
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out the repo (gha)
|
|
if: ${{ !env.ACT }}
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
|
|
with:
|
|
ref: ${{ inputs.ref }}
|
|
persist-credentials: false
|
|
|
|
- name: Check out the repo (act)
|
|
if: ${{ env.ACT }}
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
|
|
- name: Use Node.js
|
|
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f #6.3.0
|
|
with:
|
|
node-version: ${{ inputs.node-version }}
|
|
cache: 'npm'
|
|
|
|
- name: Install concurrently
|
|
run: npm install -g concurrently
|
|
|
|
- name: Install dev dependencies
|
|
run: npm run install:parallel
|
|
|
|
- name: Test Backend
|
|
run: npm run test
|
|
|
|
- name: Build
|
|
run: npm run build:parallel
|
|
|
|
# remove modules that might include dev stuff
|
|
# so that in the next step we are sure that prod-only runs work correctly
|
|
- name: Install Prod Deps
|
|
run: |
|
|
rm -rf node_modules && \
|
|
rm -rf docsite/node_modules && \
|
|
NODE_ENV=production npm ci --omit=dev
|
|
|
|
# run app for 10 seconds as sanity check to see if it errors for any reason
|
|
# easy testcase for missing packages and init errors
|
|
- name: Sanity Run
|
|
run: |
|
|
set +e
|
|
export NODE_ENV=production
|
|
timeout --preserve-status 10s node src/backend/index.ts
|
|
exitcode="$?"
|
|
if [[ "$exitcode" -eq 143 ]] || [[ "$exitcode" -eq 137 ]]; then
|
|
echo "App stayed up long enough and exited with expected status"
|
|
exit 0
|
|
else
|
|
echo "App exited with unexpected code $exitcode"
|
|
exit "$exitcode"
|
|
fi
|