Skip to content

maker-appimage: Wait for tests in more places. #42

maker-appimage: Wait for tests in more places.

maker-appimage: Wait for tests in more places. #42

Workflow file for this run

name: Node.js CI/CD
on:
push:
branches: [ master ]
tags: [ appimage/v*, maker-types/v*, launcher/v* ]
pull_request:
branches: [ master ]
jobs:
test:
strategy:
matrix:
node-version: [18.x, 20.x, 22.x, latest]
name: Build and run tests (${{ github.ref_name }}#${{ matrix.node-version }})
runs-on: ubuntu-latest
steps:
# Initialization
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
# Build
- name: Build project
run: npm run build
# Test
- name: Run tests with coverage+test reporting
if: ${{ matrix.node-version == 'latest' || matrix.node-version == '22.x' }}
run: |
npm run test:coverage -- --experimental-test-coverage \
--test-reporter=spec --test-reporter-destination=stdout \
--test-reporter=junit --test-reporter-destination=junit.xml
- name: Upload coverage reports to Codecov
if: ${{ success() }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: "${{ github.ref_name }}#${{ matrix.node-version }}"
- name: Upload test results to CodeCov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: "${{ github.ref_name }}#${{ matrix.node-version }}"
publish:
name: Distribute ${{ matrix.pkg }}
runs-on: ubuntu-latest
needs: test
permissions:
contents: read
id-token: write
strategy:
matrix:
# FIXME: Consider some smarter scripting capabilities than if ... else
# tag to package mapping. Substring of tag to next slash could
# help a lot.
# At least I can do hacky expression splitting to have it stored
# as a rather "pretty, lengthy" value.
pkg: >-
${{ (startsWith(github.ref_name,'appimage/v') && fromJson('["maker-appimage"]') ||
startsWith(github.ref_name,'maker-types/v') && fromJson('["maker-types"]') ||
startsWith(github.ref_name,'launcher/v') && fromJson('["plugin-launcher"]') ||
fromJson('["maker-appimage","maker-types","plugin-launcher"]')
)}}
steps:
# Initialization
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js latest
uses: actions/setup-node@v3
with:
node-version: latest
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: npm ci
# Create package & publish it as artifact for inspection
- name: Create package tarball
id: pack
run: |
{
printf 'meta<<\0\n'
npm -w "@reforged/${{ matrix.pkg }}" pack --json
printf '\0\n'
} >> "$GITHUB_OUTPUT"
- name: Upload package as artifact
uses: actions/upload-artifact@v4
with:
name: reforged-${{ matrix.pkg }}
path: ${{ fromJson(steps.pack.outputs.meta)[0].filename }}
# Publish to NPM (for tags)
- name: Publish to NPM
if: ${{ github.ref_type == 'tag' }}
run: npm -w "@reforged/${{ matrix.pkg }}" publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}