β¬οΈ Update peter-evans/create-or-update-comment action to v5 #3921
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: Dust and Test | |
| on: | |
| pull_request: | |
| issue_comment: | |
| types: [created] | |
| jobs: | |
| duster: | |
| if: | | |
| github.event_name != 'issue_comment' || | |
| (github.event.issue.pull_request && (contains(github.event.comment.body, '/test') || contains(github.event.comment.body, '/run-tests'))) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: read | |
| outputs: | |
| commit_sha: ${{ steps.get_sha.outputs.sha }} | |
| steps: | |
| - name: Add reaction to comment | |
| if: github.event_name == 'issue_comment' | |
| uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5 | |
| with: | |
| comment-id: ${{ github.event.comment.id }} | |
| reactions: eyes | |
| - name: Get PR branch | |
| if: github.event_name == 'issue_comment' | |
| uses: xt0rted/pull-request-comment-branch@e8b8daa837e8ea7331c0003c9c316a64c6d8b0b1 # v3 | |
| id: comment-branch | |
| - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 | |
| with: | |
| ref: ${{ github.event_name == 'issue_comment' && steps.comment-branch.outputs.head_ref || github.event.pull_request.head.ref }} | |
| repository: ${{ github.event_name == 'issue_comment' && steps.comment-branch.outputs.head_repo || github.event.pull_request.head.repo.full_name }} | |
| - name: "Duster Fix" | |
| uses: tighten/duster-action@557d11cf6d55a7f7cf6324806c633af0062759eb # v3 | |
| with: | |
| args: fix | |
| - uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v6 | |
| id: auto_commit_action | |
| with: | |
| commit_message: π¨ Fix code style | |
| commit_user_name: GitHub Action | |
| commit_user_email: actions@github.com | |
| - name: Get current commit SHA | |
| id: get_sha | |
| run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
| ci: | |
| runs-on: ubuntu-latest | |
| environment: CI | |
| needs: duster | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| services: | |
| postgres: | |
| image: "bsamasi/postgis-pgvector:pg17@sha256:f3133925f641c093fae3f83607cfe21eb6e401b6961ae1cac84f70ff6f767f59" | |
| env: | |
| PGPASSWORD: postgres | |
| POSTGRES_DB: laravel | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| ports: | |
| - 5432:5432 | |
| options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
| steps: | |
| - name: Get PR branch | |
| if: github.event_name == 'issue_comment' | |
| uses: xt0rted/pull-request-comment-branch@e8b8daa837e8ea7331c0003c9c316a64c6d8b0b1 # v3 | |
| id: comment-branch | |
| - name: Checkout | |
| uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 | |
| with: | |
| # Use the commit SHA from duster to ensure we test the code after any duster fixes | |
| ref: ${{ needs.duster.outputs.commit_sha }} | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2 | |
| with: | |
| php-version: 8.2 | |
| tools: composer:v2 | |
| coverage: xdebug | |
| - name: Get Composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-composer- | |
| - name: Setup Node | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| - name: Install Node Dependencies | |
| run: npm ci | |
| - name: Add Wire Credentials Loaded From ENV | |
| run: composer config http-basic.wire-elements-pro.composer.sh ${{ secrets.WIRE_SECRET}} | |
| - name: Copy Environment File | |
| run: cp .env.example .env | |
| - name: Install Dependencies | |
| run: composer install --no-interaction --prefer-dist --optimize-autoloader | |
| - name: Generate Application Key | |
| run: php artisan key:generate | |
| - name: Enable PostgreSQL Extensions | |
| run: | | |
| PGPASSWORD=postgres psql -h localhost -U postgres -d laravel -c "CREATE EXTENSION IF NOT EXISTS vector;" | |
| PGPASSWORD=postgres psql -h localhost -U postgres -d laravel -c "CREATE EXTENSION IF NOT EXISTS postgis;" | |
| PGPASSWORD=postgres psql -h localhost -U postgres -d laravel -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;" | |
| - name: Run Migrations | |
| run: php artisan migrate --force | |
| - name: Build Assets | |
| run: npm run build | |
| - name: Run Tests | |
| id: tests | |
| run: | | |
| # Run PHPUnit with output capturing all test results | |
| # Use tee so we still see output in Actions logs | |
| ./vendor/bin/phpunit --teamcity | tee test_output.txt || true | |
| # Extract finished and failed test names | |
| grep "##teamcity\[testFinished" test_output.txt \ | |
| | sed "s/.*name='\([^']*\)'.*/\1/" > all_finished.txt | |
| grep "##teamcity\[testFailed" test_output.txt \ | |
| | sed "s/.*name='\([^']*\)'.*/\1/" | sort -u > failed_tests.txt | |
| # Compute passed = finished β failed | |
| sort -u all_finished.txt > all_finished_sorted.txt | |
| comm -23 all_finished_sorted.txt failed_tests.txt > passed_tests.txt | |
| # Derive counts from lists | |
| TOTAL=$(wc -l < all_finished_sorted.txt) | |
| FAILED=$(wc -l < failed_tests.txt) | |
| PASSED=$(wc -l < passed_tests.txt) | |
| # Clean up intermediate lists | |
| rm -f all_finished.txt all_finished_sorted.txt | |
| # Store test results for summary step | |
| echo "total=$TOTAL" >> "$GITHUB_OUTPUT" | |
| echo "passed=$PASSED" >> "$GITHUB_OUTPUT" | |
| echo "failed=$FAILED" >> "$GITHUB_OUTPUT" | |
| # Exit with error if any tests failed | |
| if [ "${FAILED:-0}" -gt 0 ]; then | |
| exit 1 | |
| fi | |
| - name: Add Test Results to Summary | |
| if: always() | |
| run: | | |
| echo "# Deployment Summary :rocket:" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "## Build & Test Results" >> $GITHUB_STEP_SUMMARY | |
| if [ "${{ steps.tests.outputs.failed }}" = "0" ]; then | |
| echo "- β CI Tests Passed" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "- β CI Tests Failed" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Test Statistics" >> $GITHUB_STEP_SUMMARY | |
| echo "- Total Tests: \`${{ steps.tests.outputs.total }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "- β Passed: \`${{ steps.tests.outputs.passed }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "- β Failed: \`${{ steps.tests.outputs.failed }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Add passed tests in expandable section | |
| echo "<details><summary>β Passed Tests (${{ steps.tests.outputs.passed }})</summary>" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| cat passed_tests.txt >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| echo "</details>" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Add failed tests in expandable section if any | |
| if [ "${{ steps.tests.outputs.failed }}" != "0" ]; then | |
| echo "<details><summary>β Failed Tests (${{ steps.tests.outputs.failed }})</summary>" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| cat failed_tests.txt >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| echo "</details>" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| - name: Comment success | |
| if: success() && github.event_name == 'issue_comment' | |
| uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5 | |
| with: | |
| issue-number: ${{ github.event.issue.number }} | |
| body: | | |
| β Dust and tests passed successfully! | |
| **Test Results:** | |
| - Total: `${{ steps.tests.outputs.total }}` | |
| - Passed: `${{ steps.tests.outputs.passed }}` | |
| - Failed: `${{ steps.tests.outputs.failed }}` | |
| Triggered by comment from @${{ github.event.comment.user.login }} | |
| - name: Comment failure | |
| if: failure() && github.event_name == 'issue_comment' | |
| uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5 | |
| with: | |
| issue-number: ${{ github.event.issue.number }} | |
| body: | | |
| β Dust and/or tests failed! | |
| **Test Results:** | |
| - Total: `${{ steps.tests.outputs.total }}` | |
| - Passed: `${{ steps.tests.outputs.passed }}` | |
| - Failed: `${{ steps.tests.outputs.failed }}` | |
| Triggered by comment from @${{ github.event.comment.user.login }} | |
| Please check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details. |