Merge pull request #127 from czlonkowski/test/ci-permission-fixes

fix: handle GitHub Actions permission errors gracefully
This commit is contained in:
Romuald Członkowski
2025-08-06 22:39:36 +02:00
committed by GitHub
3 changed files with 145 additions and 113 deletions

View File

@@ -93,8 +93,10 @@ jobs:
- name: Post benchmark comparison to PR - name: Post benchmark comparison to PR
if: always() if: always()
uses: actions/github-script@v7 uses: actions/github-script@v7
continue-on-error: true
with: with:
script: | script: |
try {
const fs = require('fs'); const fs = require('fs');
let comment = '## ⚡ Benchmark Comparison\n\n'; let comment = '## ⚡ Benchmark Comparison\n\n';
@@ -139,13 +141,20 @@ jobs:
body: comment body: comment
}); });
} }
} catch (error) {
console.error('Failed to create/update PR comment:', error.message);
console.log('This is likely due to insufficient permissions for external PRs.');
console.log('Benchmark comparison has been saved to artifacts instead.');
}
# Add status check # Add status check
- name: Set benchmark status - name: Set benchmark status
if: always() if: always()
uses: actions/github-script@v7 uses: actions/github-script@v7
continue-on-error: true
with: with:
script: | script: |
try {
const hasRegression = '${{ steps.compare.outputs.REGRESSION }}' === 'true'; const hasRegression = '${{ steps.compare.outputs.REGRESSION }}' === 'true';
const state = hasRegression ? 'failure' : 'success'; const state = hasRegression ? 'failure' : 'success';
const description = hasRegression const description = hasRegression
@@ -161,3 +170,7 @@ jobs:
description: description, description: description,
context: 'benchmarks/regression-check' context: 'benchmarks/regression-check'
}); });
} catch (error) {
console.error('Failed to create commit status:', error.message);
console.log('This is likely due to insufficient permissions for external PRs.');
}

View File

@@ -103,12 +103,14 @@ jobs:
# Store benchmark results and compare # Store benchmark results and compare
- name: Store benchmark result - name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1 uses: benchmark-action/github-action-benchmark@v1
continue-on-error: true
id: benchmark
with: with:
name: n8n-mcp Benchmarks name: n8n-mcp Benchmarks
tool: 'customSmallerIsBetter' tool: 'customSmallerIsBetter'
output-file-path: benchmark-results-formatted.json output-file-path: benchmark-results-formatted.json
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true auto-push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
# Where to store benchmark data # Where to store benchmark data
benchmark-data-dir-path: 'benchmarks' benchmark-data-dir-path: 'benchmarks'
# Alert when performance regresses by 10% # Alert when performance regresses by 10%
@@ -120,14 +122,17 @@ jobs:
summary-always: true summary-always: true
# Max number of data points to retain # Max number of data points to retain
max-items-in-chart: 50 max-items-in-chart: 50
fail-on-alert: false
# Comment on PR with benchmark results # Comment on PR with benchmark results
- name: Comment PR with results - name: Comment PR with results
uses: actions/github-script@v7 uses: actions/github-script@v7
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request'
continue-on-error: true
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
try {
const fs = require('fs'); const fs = require('fs');
const summary = JSON.parse(fs.readFileSync('benchmark-summary.json', 'utf8')); const summary = JSON.parse(fs.readFileSync('benchmark-summary.json', 'utf8'));
@@ -160,12 +165,17 @@ jobs:
comment += '\n\n📈 [View historical benchmark trends](https://czlonkowski.github.io/n8n-mcp/benchmarks/)\n'; comment += '\n\n📈 [View historical benchmark trends](https://czlonkowski.github.io/n8n-mcp/benchmarks/)\n';
comment += '\n⚡ Performance regressions >10% will be flagged automatically.\n'; comment += '\n⚡ Performance regressions >10% will be flagged automatically.\n';
github.rest.issues.createComment({ await github.rest.issues.createComment({
issue_number: context.issue.number, issue_number: context.issue.number,
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
body: comment body: comment
}); });
} catch (error) {
console.error('Failed to create PR comment:', error.message);
console.log('This is likely due to insufficient permissions for external PRs.');
console.log('Benchmark results have been saved to artifacts instead.');
}
# Deploy benchmark results to GitHub Pages # Deploy benchmark results to GitHub Pages
deploy: deploy:

View File

@@ -148,6 +148,7 @@ jobs:
- name: Create test report comment - name: Create test report comment
if: github.event_name == 'pull_request' && always() if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7 uses: actions/github-script@v7
continue-on-error: true
with: with:
script: | script: |
const fs = require('fs'); const fs = require('fs');
@@ -161,6 +162,7 @@ jobs:
console.error('Error reading test summary:', error); console.error('Error reading test summary:', error);
} }
try {
// Find existing comment // Find existing comment
const { data: comments } = await github.rest.issues.listComments({ const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner, owner: context.repo.owner,
@@ -190,6 +192,11 @@ jobs:
body: summary body: summary
}); });
} }
} catch (error) {
console.error('Failed to create/update PR comment:', error.message);
console.log('This is likely due to insufficient permissions for external PRs.');
console.log('Test results have been saved to the job summary instead.');
}
# Generate job summary # Generate job summary
- name: Generate job summary - name: Generate job summary
@@ -260,11 +267,13 @@ jobs:
- name: Publish test results - name: Publish test results
uses: dorny/test-reporter@v1 uses: dorny/test-reporter@v1
if: always() if: always()
continue-on-error: true
with: with:
name: Test Results name: Test Results
path: 'artifacts/test-results-*/test-results/junit.xml' path: 'artifacts/test-results-*/test-results/junit.xml'
reporter: java-junit reporter: java-junit
fail-on-error: false fail-on-error: false
fail-on-empty: false
# Create a combined artifact with all results # Create a combined artifact with all results
- name: Create combined results artifact - name: Create combined results artifact