vibetunnel/.github/workflows/node.yml
Peter Steinberger 163e1b6f03 fix: Add CI-specific build script to skip native executable build
The Node.js CI build was failing because it tried to build the native
executable which requires postject and other tools that may not be
available in all CI environments. Created a separate build:ci script
that skips the native build step for CI.
2025-06-22 07:34:59 +02:00

167 lines
No EOL
4.3 KiB
YAML

name: Node.js CI
on:
workflow_call:
permissions:
contents: read
pull-requests: write
issues: write
jobs:
lint:
name: Lint TypeScript/JavaScript Code
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: useblacksmith/setup-node@v5
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Install dependencies
working-directory: web
run: npm ci
- name: Check formatting with Prettier
id: prettier
working-directory: web
continue-on-error: true
run: |
npm run format:check 2>&1 | tee prettier-output.txt
echo "result=${PIPESTATUS[0]}" >> $GITHUB_OUTPUT
- name: Run ESLint
id: eslint
working-directory: web
continue-on-error: true
run: |
npm run lint 2>&1 | tee eslint-output.txt
echo "result=${PIPESTATUS[0]}" >> $GITHUB_OUTPUT
- name: Read Prettier Output
if: always()
id: prettier-output
working-directory: web
run: |
if [ -f prettier-output.txt ]; then
echo 'content<<EOF' >> $GITHUB_OUTPUT
cat prettier-output.txt >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
else
echo "content=No output" >> $GITHUB_OUTPUT
fi
- name: Read ESLint Output
if: always()
id: eslint-output
working-directory: web
run: |
if [ -f eslint-output.txt ]; then
echo 'content<<EOF' >> $GITHUB_OUTPUT
cat eslint-output.txt >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
else
echo "content=No output" >> $GITHUB_OUTPUT
fi
- name: Report Prettier Results
if: always()
uses: ./.github/actions/lint-reporter
with:
title: 'Node.js Prettier Formatting'
lint-result: ${{ steps.prettier.outputs.result == '0' && 'success' || 'failure' }}
lint-output: ${{ steps.prettier-output.outputs.content }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Report ESLint Results
if: always()
uses: ./.github/actions/lint-reporter
with:
title: 'Node.js ESLint'
lint-result: ${{ steps.eslint.outputs.result == '0' && 'success' || 'failure' }}
lint-output: ${{ steps.eslint-output.outputs.content }}
github-token: ${{ secrets.GITHUB_TOKEN }}
build-and-test:
name: Build and Test
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: useblacksmith/setup-node@v5
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Install dependencies
working-directory: web
run: npm ci
- name: Build frontend and backend
working-directory: web
run: npm run build:ci
- name: Run tests
working-directory: web
run: npm test
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: node-build-artifacts
path: |
web/dist/
web/public/bundle/
type-check:
name: TypeScript Type Checking
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: useblacksmith/setup-node@v5
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Install dependencies
working-directory: web
run: npm ci
- name: Check TypeScript types
working-directory: web
run: npm run typecheck
audit:
name: Security Audit
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: useblacksmith/setup-node@v5
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Run npm audit
working-directory: web
run: npm audit --audit-level=moderate || true
# || true to not fail the build on vulnerabilities, but still report them