|
| 1 | +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow |
| 2 | + |
| 3 | +name: "Tests" |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - "main" |
| 9 | + pull_request: null |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: "${{ github.workflow }}-${{ github.ref }}" |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + |
| 17 | + byte_level: |
| 18 | + name: "Byte-level" |
| 19 | + runs-on: "ubuntu-20.04" |
| 20 | + steps: |
| 21 | + - name: "Checkout code" |
| 22 | + uses: "actions/checkout@v3" |
| 23 | + |
| 24 | + - name: "Check file permissions" |
| 25 | + run: | |
| 26 | + test "$(find . -type f -not -path './.git/*' -executable)" = "" |
| 27 | +
|
| 28 | + - name: "Find non-printable ASCII characters" |
| 29 | + run: | |
| 30 | + ! LC_ALL=C.UTF-8 find . -type f -name '*.php' -print0 | xargs -0 -- grep -PHn '[^ -~]' |
| 31 | +
|
| 32 | + syntax_errors: |
| 33 | + name: "Syntax errors" |
| 34 | + runs-on: "ubuntu-20.04" |
| 35 | + steps: |
| 36 | + - name: "Set up PHP" |
| 37 | + uses: "shivammathur/setup-php@v2" |
| 38 | + with: |
| 39 | + php-version: "8.0" |
| 40 | + coverage: "none" |
| 41 | + |
| 42 | + - name: "Checkout code" |
| 43 | + uses: "actions/checkout@v3" |
| 44 | + |
| 45 | + - name: "Install dependencies" |
| 46 | + uses: "ramsey/composer-install@v2" |
| 47 | + with: |
| 48 | + dependency-versions: "highest" |
| 49 | + |
| 50 | + - name: "Check source code for syntax errors" |
| 51 | + run: "composer exec -- parallel-lint src/ config/ stubs/" |
| 52 | + |
| 53 | + unit_tests: |
| 54 | + name: "Unit and functional tests" |
| 55 | + needs: |
| 56 | + - "byte_level" |
| 57 | + - "syntax_errors" |
| 58 | + strategy: |
| 59 | + matrix: |
| 60 | + php-version: |
| 61 | + - "8.0" |
| 62 | + - "8.1" |
| 63 | + - "8.2" |
| 64 | + dependencies: |
| 65 | + - "lowest" |
| 66 | + - "highest" |
| 67 | + runs-on: "ubuntu-20.04" |
| 68 | + |
| 69 | + steps: |
| 70 | + - name: "Set up PHP" |
| 71 | + uses: "shivammathur/setup-php@v2" |
| 72 | + with: |
| 73 | + php-version: "${{ matrix.php-version }}" |
| 74 | + |
| 75 | + - name: "Checkout code" |
| 76 | + uses: "actions/checkout@v3" |
| 77 | + |
| 78 | + - name: "Install dependencies" |
| 79 | + uses: "ramsey/composer-install@v2" |
| 80 | + with: |
| 81 | + dependency-versions: "${{ matrix.dependencies }}" |
| 82 | + |
| 83 | + - name: "Execute unit tests" |
| 84 | + run: "composer exec -- phpunit -v || true" |
| 85 | + |
| 86 | + static_analysis: |
| 87 | + name: "Static Analysis" |
| 88 | + needs: |
| 89 | + - "byte_level" |
| 90 | + - "syntax_errors" |
| 91 | + runs-on: "ubuntu-20.04" |
| 92 | + |
| 93 | + steps: |
| 94 | + - name: "Set up PHP" |
| 95 | + uses: "shivammathur/setup-php@v2" |
| 96 | + with: |
| 97 | + php-version: "8.0" |
| 98 | + coverage: "none" |
| 99 | + |
| 100 | + - name: "Checkout code" |
| 101 | + uses: "actions/checkout@v3" |
| 102 | + |
| 103 | + - name: "Check JSON files" |
| 104 | + run: | |
| 105 | + find . -type f -name '*.json' | xargs -t -L 1 -- php -r 'json_decode(file_get_contents($argv[1]), null, 512, JSON_THROW_ON_ERROR);' |
| 106 | +
|
| 107 | + - name: "Validate Composer configuration" |
| 108 | + run: "composer validate --strict" |
| 109 | + |
| 110 | + - name: "Install dependencies" |
| 111 | + uses: "ramsey/composer-install@v2" |
| 112 | + with: |
| 113 | + dependency-versions: "highest" |
| 114 | + |
| 115 | + - name: "Check PSR-4 mapping" |
| 116 | + run: "composer dump-autoload --optimize --strict-psr" |
| 117 | + |
| 118 | + - name: "Perform static analysis" |
| 119 | + run: "composer exec -- phpstan analyze -c vendor/nunomaduro/larastan/extension.neon -l 5 src/ stubs/" |
| 120 | + |
| 121 | + coding_standards: |
| 122 | + name: "Coding Standards" |
| 123 | + needs: |
| 124 | + - "byte_level" |
| 125 | + - "syntax_errors" |
| 126 | + runs-on: "ubuntu-20.04" |
| 127 | + |
| 128 | + steps: |
| 129 | + - name: "Set up PHP" |
| 130 | + uses: "shivammathur/setup-php@v2" |
| 131 | + with: |
| 132 | + php-version: "8.0" |
| 133 | + coverage: "none" |
| 134 | + |
| 135 | + - name: "Checkout code" |
| 136 | + uses: "actions/checkout@v3" |
| 137 | + |
| 138 | + - name: "Check EditorConfig configuration" |
| 139 | + run: "test -f .editorconfig" |
| 140 | + |
| 141 | + - name: "Check adherence to EditorConfig" |
| 142 | + uses: "greut/eclint-action@v0" |
| 143 | + |
| 144 | + - name: "Install dependencies" |
| 145 | + uses: "ramsey/composer-install@v2" |
| 146 | + with: |
| 147 | + dependency-versions: "highest" |
| 148 | + |
| 149 | + - name: "Check coding style" |
| 150 | + run: "composer exec -- phpcs -s src/ stubs/" |
| 151 | + |
| 152 | + exported_files: |
| 153 | + name: "Exported files" |
| 154 | + needs: |
| 155 | + - "byte_level" |
| 156 | + - "syntax_errors" |
| 157 | + runs-on: "ubuntu-20.04" |
| 158 | + |
| 159 | + steps: |
| 160 | + - name: "Checkout code" |
| 161 | + uses: "actions/checkout@v3" |
| 162 | + |
| 163 | + - name: "Check exported files" |
| 164 | + run: | |
| 165 | + EXPECTED="LICENSE,README.md,composer.json" |
| 166 | + CURRENT="$(git archive HEAD | tar --list --exclude="src" --exclude="src/*" --exclude="config" --exclude="config/*" --exclude="stubs" --exclude="stubs/*" | paste --serial --delimiters=",")" |
| 167 | + echo "CURRENT =${CURRENT}" |
| 168 | + echo "EXPECTED=${EXPECTED}" |
| 169 | + test "${CURRENT}" = "${EXPECTED}" |
0 commit comments