Skip to content

[5.x] Improve feedback when action fails #23735

[5.x] Improve feedback when action fails

[5.x] Improve feedback when action fails #23735

Workflow file for this run

name: Run Tests
on:
push:
branches:
- master
- '*.x'
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
php-tests:
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, '[ci skip]')"
strategy:
matrix:
php: [8.1, 8.2, 8.3]
laravel: [10.*, 11.*]
stability: [prefer-lowest, prefer-stable]
os: [ubuntu-latest]
include:
- os: windows-latest
php: 8.3
laravel: 10.*
stability: prefer-stable
- os: windows-latest
php: 8.3
laravel: 11.*
stability: prefer-stable
exclude:
- php: 8.1
laravel: 11.*
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
config
resources/lang
resources/users
resources/views
routes
src
tests
composer.json
phpunit.xml.dist
.github/workflows/tests.yml
**.php
- name: Determine whether tests should run
id: should-run-tests
if: steps.changed-files.outputs.any_modified == 'true' || github.event_name == 'schedule'
run: |
echo "result=true" >> $GITHUB_OUTPUT
echo "result=true" >> $env:GITHUB_OUTPUT
- name: Update apt sources
if: steps.should-run-tests.outputs.result == 'true' && matrix.os == 'ubuntu-latest'
run: |
sudo apt-get check || sudo apt --fix-broken install -y
sudo apt-get update
- name: Install French Locale
if: steps.should-run-tests.outputs.result == 'true' && matrix.os == 'ubuntu-latest'
run: sudo apt-get install language-pack-fr
- name: Setup PHP
uses: shivammathur/setup-php@v2
if: steps.should-run-tests.outputs.result == 'true'
with:
php-version: ${{ matrix.php }}
extensions: fileinfo, exif, gd, pdo, sqlite, pdo_sqlite
ini-values: short_open_tag=on
coverage: none
- name: Install dependencies
uses: nick-invision/retry@v3
if: steps.should-run-tests.outputs.result == 'true'
with:
timeout_minutes: 5
max_attempts: 5
command: |
composer require "illuminate/contracts:${{ matrix.laravel }}" --dev --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: List Installed Dependencies
if: steps.should-run-tests.outputs.result == 'true'
run: composer show -D
- name: Execute tests
if: steps.should-run-tests.outputs.result == 'true'
run: vendor/bin/phpunit
js-tests:
runs-on: ubuntu-20.04
if: "!contains(github.event.head_commit.message, '[ci skip]')"
name: JavaScript tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
**/*.{js,vue,ts}
package.json
.github/workflows/tests.yml
- name: Determine whether tests should run
id: should-run-tests
if: steps.changed-files.outputs.any_modified == 'true' || github.event_name == 'schedule'
run: |
echo "result=true" >> $GITHUB_OUTPUT
echo "result=true" >> $env:GITHUB_OUTPUT
- name: Use Node.js 16.13.0
uses: actions/setup-node@v4
with:
node-version: 16.13.0
- name: Install required npm version
if: steps.should-run-tests.outputs.result == 'true'
run: npm -g install [email protected]
- name: Install dependencies
if: steps.should-run-tests.outputs.result == 'true'
run: npm ci
- name: Execute tests
if: steps.should-run-tests.outputs.result == 'true'
run: npm run test
slack:
name: Slack Notification
runs-on: ubuntu-20.04
needs: [php-tests, js-tests]
if: always()
steps:
- uses: technote-space/workflow-conclusion-action@v3
- name: Send Slack notification
uses: 8398a7/action-slack@v3
if: env.WORKFLOW_CONCLUSION == 'failure' && github.event_name == 'schedule'
with:
status: failure
fields: repo,message,commit,author,action,eventName,ref,workflow
author_name: ${{ github.actor }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}