tsest #1
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: Grade Assignment | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| - name: Run tests | |
| id: test | |
| run: | | |
| node .hyf/tester.js > test-output.txt 2>&1 | |
| echo "exit_code=$?" >> $GITHUB_OUTPUT | |
| continue-on-error: true | |
| - name: Read test output | |
| id: output | |
| run: | | |
| OUTPUT=$(cat test-output.txt) | |
| echo "results<<EOF" >> $GITHUB_OUTPUT | |
| echo "$OUTPUT" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Comment PR | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const output = `${{ steps.output.outputs.results }}`; | |
| const exitCode = '${{ steps.test.outputs.exit_code }}'; | |
| const status = exitCode === '0' ? '✅ Passed' : '❌ Failed'; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: `## Assignment Grade ${status}\n\n\`\`\`\n${output}\n\`\`\`` | |
| }); | |
| - name: Fail if tests failed | |
| if: steps.test.outputs.exit_code != '0' | |
| run: exit 1 |