Initial general CI workflows #4
This file contains hidden or 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 marker = 'to show where the warning was created)'; | |
| const output = steps.run_tests.outputs.tests_report; | |
| const sanitized = output.split(marker); | |
| const msg = (sanitized.length > 1) ? sanitized[1] : sanitized[0]; | |
| const prNumber = context.payload.issue.number; | |
| if (sanitized.length >= 1) { | |
| github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body: msg, | |
| }); | |
| } else { | |
| core.setFailed('No tests report data available.') | |
| } |