Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions .github/workflows/test-summary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ permissions:

jobs:
comment:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
if: github.event.workflow_run.event == 'pull_request'

steps:
Expand All @@ -30,7 +30,7 @@ jobs:

- name: Download test artifacts
if: steps.pr.outputs.number != ''
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
name: test-results-node-20.x
run-id: ${{ github.event.workflow_run.id }}
Expand All @@ -39,7 +39,7 @@ jobs:

- name: Comment PR with test summary
if: steps.pr.outputs.number != ''
uses: actions/github-script@v6
uses: actions/github-script@v9
with:
script: |
const fs = require('fs');
Expand All @@ -62,15 +62,20 @@ jobs:
const emoji = testStatus === 'success' ? '✅' : '❌';
const message = testStatus === 'success' ? 'All tests passed!' : 'Some tests failed.';

// Get the job outputs to determine individual step results
const jobs = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});

const testJob = jobs.data.jobs.find(job => job.name.includes('test'));
const steps = testJob ? testJob.steps : [];
// Prefer step outcomes recorded by the test workflow; the jobs API
// sometimes returns an empty steps array.
let steps = [];
try {
steps = JSON.parse(fs.readFileSync('step-outcomes.json', 'utf8'));
} catch (e) {
const jobs = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
const testJob = jobs.data.jobs.find(job => job.name.includes('test'));
steps = testJob ? testJob.steps : [];
}

const lintStep = steps.find(step => step.name === 'Run linting');
const formatStep = steps.find(step => step.name === 'Run formatting check');
Expand Down
26 changes: 22 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

strategy:
matrix:
node-version: [20.x]

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v7

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
Expand All @@ -28,22 +28,26 @@ jobs:
run: npm ci

- name: Run linting
id: lint
run: |
npm run lint 2>&1 | tee lint-output.txt
exit ${PIPESTATUS[0]}
continue-on-error: true

- name: Run formatting check
id: format
run: |
npm run format 2>&1 | tee format-output.txt
exit ${PIPESTATUS[0]}
continue-on-error: true

- name: Run type checking and build
id: build
run: npm run build
continue-on-error: false

- name: Run specific test suites
id: tests
run: |
echo "Running individual test suites for better visibility..."
npm run test:run -- src/testing/tests/BeamEnergy.test.tsx
Expand Down Expand Up @@ -127,8 +131,21 @@ jobs:
env:
CI: true

# Record step outcomes ourselves; the jobs API sometimes returns no step data.
- name: Record step outcomes
if: always()
run: |
cat > step-outcomes.json <<EOF
[
{ "name": "Run linting", "conclusion": "${{ steps.lint.outcome }}" },
{ "name": "Run formatting check", "conclusion": "${{ steps.format.outcome }}" },
{ "name": "Run type checking and build", "conclusion": "${{ steps.build.outcome }}" },
{ "name": "Run specific test suites", "conclusion": "${{ steps.tests.outcome }}" }
]
EOF

- name: Upload test results
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
if: always()
with:
name: test-results-node-${{ matrix.node-version }}
Expand All @@ -137,4 +154,5 @@ jobs:
test-results/
lint-output.txt
format-output.txt
step-outcomes.json
retention-days: 30
Loading