ci: refactoring the tests-report step into their own ECMAscript module #5
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 Action Scripts | |
on: | |
push: | |
paths: | |
- 'actions_scripts/**' # Trigger only when files in this folder are modified | |
pull_request: | |
paths: | |
- 'actions_scripts/**' # Run on PRs affecting the actions_scripts folder | |
jobs: | |
test-and-coverage-action-scripts: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Set up Node.js environment | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '23' | |
# Install dependencies | |
- name: Install dependencies | |
run: npm ci | |
# Run tests and capture output | |
- name: Run tests | |
id: run_tests | |
run: | | |
{ | |
echo 'tests_report<<EOF' | |
npm test 2>&1 | |
echo EOF | |
} >> "$GITHUB_OUTPUT" | |
# Post comment on PR | |
- name: Add JEST results as a PR comment | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const steps = ${{ toJSON(steps) }}; | |
const { default: testReportOnPrComment } = | |
await import('${{ github.workspace }}/actions_scripts/tests_report_on_pr_comment.js'); | |
await testReportOnPrComment(github, context, steps); |