undo test dir ignore #3531
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: Run Tests | |
on: | |
push: | |
branches: ['**'] | |
pull_request: | |
branches: ['**'] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
env: | |
OSM_URI: ${{ secrets.OSM_URI }} | |
JWT_SECRET: test123 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup JS Runtime environment | |
uses: ./.github/actions/setup-js-runtime | |
- name: Find or create comment | |
uses: actions/github-script@v6 | |
id: find_or_create_comment | |
if: github.event_name == 'pull_request' | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const commentIdentifier = '<!-- test_results -->'; | |
const commentBody = `${commentIdentifier}\n🚀 Running tests... Please wait for the results! 🕐`; | |
const comments = await github.rest.issues.listComments({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}); | |
const existingComment = comments.data.find(comment => comment.body.startsWith(commentIdentifier)); | |
if (existingComment) { | |
core.setOutput('comment_id', existingComment.id); | |
} else { | |
const { data: { id: commentId } } = await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: commentBody | |
}); | |
core.setOutput('comment_id', commentId); | |
} | |
- name: Install dependencies | |
uses: ./.github/actions/install-deps | |
- name: Setup API | |
run: cp -n server/wrangler.toml.example server/wrangler.toml | |
- name: Run tests | |
id: run_tests | |
run: yarn test | |
continue-on-error: true | |
- name: Update comment with test results | |
uses: actions/github-script@v6 | |
if: always() && github.event_name == 'pull_request' | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const commentIdentifier = '<!-- test_results -->'; | |
const commentId = process.env.COMMENT_ID; | |
const testLogs = `${{ steps.run_tests.outputs.stdout }}\n${{ steps.run_tests.outputs.stderr }}`; | |
const testStatus = `${{ steps.run_tests.outcome }}`; | |
const workflowUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
const includeTestLogs = false; // Set this to true when you want to include the test logs | |
let commentBody = `${commentIdentifier}\n`; | |
let emoji = ''; | |
if (testStatus === 'success') { | |
commentBody += '✅ Tests passed successfully! 🎉\n\n'; | |
emoji = '💚'; | |
} else { | |
commentBody += '❌ Tests failed for this pull request. 😞\n\n'; | |
emoji = '❤️'; | |
} | |
commentBody += `[View Test Workflow](${workflowUrl})\n\n`; | |
if (includeTestLogs) { | |
commentBody += `<details><summary>Test Logs</summary>\n\n\`\`\`\n${testLogs}\n\`\`\`\n</details>`; | |
} | |
await github.rest.issues.updateComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: commentId, | |
body: commentBody | |
}); | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
labels: [`tests-${testStatus}${emoji}`] | |
}); | |
env: | |
COMMENT_ID: ${{ steps.find_or_create_comment.outputs.comment_id }} |