|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +jobs: |
| 8 | + byte_level: |
| 9 | + name: 0️⃣ Byte-level |
| 10 | + |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Check file permissions |
| 18 | + run: | |
| 19 | + test "$(find . -type f -not -path './.git/*' -executable)" == "" |
| 20 | +
|
| 21 | + - name: Find non-printable ASCII characters |
| 22 | + run: | |
| 23 | + ! LC_ALL=C.UTF-8 find ./src -type f -name "*.php" -print0 | xargs -0 -- grep -PHn "[^ -~]" |
| 24 | +
|
| 25 | + syntax_errors: |
| 26 | + name: 1️⃣ Syntax errors |
| 27 | + |
| 28 | + runs-on: ubuntu-latest |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Set up PHP |
| 32 | + uses: shivammathur/setup-php@v2 |
| 33 | + with: |
| 34 | + php-version: latest |
| 35 | + tools: parallel-lint |
| 36 | + |
| 37 | + - name: Checkout code |
| 38 | + uses: actions/checkout@v4 |
| 39 | + |
| 40 | + - name: Validate Composer configuration |
| 41 | + run: composer validate --strict |
| 42 | + |
| 43 | + - name: Check source code for syntax errors |
| 44 | + run: composer exec -- parallel-lint src/ |
| 45 | + |
| 46 | + unit_tests: |
| 47 | + name: 2️⃣ Unit and Feature tests |
| 48 | + needs: |
| 49 | + - byte_level |
| 50 | + - syntax_errors |
| 51 | + |
| 52 | + runs-on: ubuntu-latest |
| 53 | + |
| 54 | + strategy: |
| 55 | + matrix: |
| 56 | + php-version: |
| 57 | + - 8.1 |
| 58 | + - 8.2 |
| 59 | + - 8.3 |
| 60 | + laravel-constraint: |
| 61 | + - 10.* |
| 62 | + - 11.* |
| 63 | + dependencies: [ lowest, highest ] |
| 64 | + exclude: |
| 65 | + - laravel-constraint: 11.* |
| 66 | + php-version: 8.1 |
| 67 | + |
| 68 | + steps: |
| 69 | + - name: Set up PHP |
| 70 | + uses: shivammathur/setup-php@v2 |
| 71 | + with: |
| 72 | + php-version: ${{ matrix.php-version }} |
| 73 | + extensions: mbstring, intl |
| 74 | + coverage: xdebug |
| 75 | + |
| 76 | + - name: Checkout code |
| 77 | + uses: actions/checkout@v4 |
| 78 | + |
| 79 | + - name: Install dependencies |
| 80 | + uses: ramsey/composer-install@v3 |
| 81 | + with: |
| 82 | + dependency-versions: ${{ matrix.dependencies }} |
| 83 | + composer-options: --with=laravel/framework:${{ matrix.laravel-constraint }} |
| 84 | + |
| 85 | + - name: Execute unit tests |
| 86 | + run: composer run-script test |
| 87 | + |
| 88 | + - name: Upload coverage to Codecov |
| 89 | + uses: codecov/codecov-action@v4 |
| 90 | + |
| 91 | + static_analysis: |
| 92 | + name: 3️⃣ Static Analysis |
| 93 | + needs: |
| 94 | + - byte_level |
| 95 | + - syntax_errors |
| 96 | + |
| 97 | + runs-on: ubuntu-latest |
| 98 | + |
| 99 | + steps: |
| 100 | + - name: Set up PHP |
| 101 | + uses: shivammathur/setup-php@v2 |
| 102 | + with: |
| 103 | + tools: phpstan |
| 104 | + php-version: latest |
| 105 | + coverage: none |
| 106 | + |
| 107 | + - name: Checkout code |
| 108 | + uses: actions/checkout@v4 |
| 109 | + |
| 110 | + - name: Install dependencies |
| 111 | + uses: ramsey/composer-install@v3 |
| 112 | + |
| 113 | + - name: Execute static analysis |
| 114 | + run: composer exec -- phpstan analyze -l 5 src/ |
| 115 | + |
| 116 | + exported_files: |
| 117 | + name: 4️⃣ Exported files |
| 118 | + needs: |
| 119 | + - byte_level |
| 120 | + - syntax_errors |
| 121 | + |
| 122 | + runs-on: ubuntu-latest |
| 123 | + |
| 124 | + steps: |
| 125 | + - name: Checkout code |
| 126 | + uses: actions/checkout@v4 |
| 127 | + |
| 128 | + - name: Check exported files |
| 129 | + run: | |
| 130 | + EXPECTED="LICENSE.md,README.md,composer.json" |
| 131 | + CURRENT="$(git archive HEAD | tar --list --exclude="src" --exclude="src/*" --exclude=".stubs" --exclude=".stubs/*" --exclude="routes" --exclude="routes/*" --exclude="stubs" --exclude="stubs/*" --exclude="lang" --exclude="lang/*" --exclude="config" --exclude="config/*" --exclude="database" --exclude="database/*" --exclude="resources" --exclude="resources/*" | paste -s -d ",")" |
| 132 | + echo "CURRENT =${CURRENT}" |
| 133 | + echo "EXPECTED=${EXPECTED}" |
| 134 | + test "${CURRENT}" == "${EXPECTED}" |
0 commit comments