ci: adapt canary update flow from neostandard
#173
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test External | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
runOnFailures: | |
description: 'Run on failures' | |
type: boolean | |
tsVersion: | |
description: 'Use TS version' | |
type: string | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
jobs: | |
lint: | |
uses: voxpelli/ghatemplates/.github/workflows/lint.yml@main | |
read_external_projects: | |
needs: lint | |
name: Read list of projects | |
runs-on: ubuntu-24.04 | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: set-matrix | |
run: echo "matrix=$(jq -s -c '${{ github.event.inputs.runOnFailures && '' || '[.[].[]] | unique | sort as $all | $all - ' }}[$exclude.[].[].[]]' dependents-data/source-*.json --slurpfile exclude dependents-data/failures.json)" >> $GITHUB_OUTPUT | |
test_external: | |
needs: read_external_projects | |
name: Test ${{ matrix.project }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
node_version: [lts/*] | |
project: ${{ fromJson(needs.read_external_projects.outputs.matrix) }} | |
steps: | |
- name: Checkout main project | |
uses: actions/checkout@v4 | |
with: | |
path: main | |
- name: Checkout ${{ matrix.project }} | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ matrix.project }} | |
path: project | |
- name: ensure project is still using this config | |
run: cat tsconfig.json| grep \"@voxpelli/tsconfig | |
working-directory: ./project | |
- name: Use Node.js ${{ matrix.node_version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node_version }} | |
- name: install main | |
run: '[ -f package-lock.json ] && npm ci --ignore-scripts --force || npm install --ignore-scripts --force' | |
working-directory: ./main | |
- name: install project | |
run: '[ -f package-lock.json ] && npm ci --ignore-scripts --force || npm install --ignore-scripts --force' | |
working-directory: ./project | |
- name: Get source TS version | |
id: source-ts | |
run: echo "TS_VERSION=$(npx tsc --version | sed s/Version\ //)" >> $GITHUB_OUTPUT | |
working-directory: ./project | |
- name: Get target TS version | |
id: target-ts | |
run: echo "TS_VERSION=${{ github.event.inputs.tsVersion || '$(npx tsc --version | sed s/Version\ //)' }}" >> $GITHUB_OUTPUT | |
working-directory: ./main | |
- name: replace typescript version ${{ steps.source-ts.outputs.TS_VERSION }} with ${{ steps.target-ts.outputs.TS_VERSION }} | |
if: steps.source-ts.outputs.TS_VERSION != steps.target-ts.outputs.TS_VERSION | |
run: npm install --force typescript@${{ steps.target-ts.outputs.TS_VERSION }} | |
working-directory: ./project | |
- name: show installed typescript version | |
run: npx tsc --version | |
working-directory: ./project | |
- name: build project if needed | |
run: npm run build-for-test --if-present | |
working-directory: ./project | |
- name: modify project config | |
run: sed 's/"@voxpelli\/tsconfig\//"..\/main\//' tsconfig.json > tmp.tsconfig.json && rm tsconfig.json && mv tmp.tsconfig.json tsconfig.json | |
working-directory: ./project | |
- name: show modified config | |
run: cat tsconfig.json | |
working-directory: ./project | |
- run: npx tsc | |
working-directory: ./project |