Add a light version of CI #2
Workflow file for this run
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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow | |
name: "Back-end" | |
on: | |
pull_request: null | |
push: | |
branches: | |
- "main" | |
permissions: | |
contents: "read" | |
concurrency: | |
group: "${{ github.workflow }}-${{ github.ref }}" | |
cancel-in-progress: true | |
jobs: | |
byte_level: | |
name: "0️⃣ Byte-level" | |
runs-on: "ubuntu-22.04" | |
timeout-minutes: 1 | |
steps: | |
- | |
name: "Checkout repository" | |
uses: "actions/checkout@v3" | |
- | |
name: "Check file permissions" | |
run: | | |
test "$(find ./ -type f -not -path './.git/*' -executable)" = "" | |
- | |
name: "Find non-printable ASCII characters" | |
run: | | |
! LC_ALL=C.UTF-8 git grep --perl-regexp --line-number -e '[^ -~]' -- '*\.php' | |
syntax_errors: | |
name: "1️⃣ Syntax errors" | |
runs-on: "ubuntu-22.04" | |
timeout-minutes: 5 | |
steps: | |
- | |
name: "Set up PHP" | |
uses: "shivammathur/setup-php@v2" | |
with: | |
php-version: "8.1" | |
coverage: "none" | |
tools: "parallel-lint" | |
- | |
name: "Checkout repository" | |
uses: "actions/checkout@v3" | |
- | |
name: "Search for conflict markers 🐌" | |
run: | | |
! git grep --line-number -e '^\(<<<<<<<\s\|=======\s\|=======$\|>>>>>>>\s\||||||||\s\)' | |
- | |
name: "Search for invalid complex curly syntax 🐌" | |
run: | | |
! git grep -e '\${[A-Z_a-z]' -- '*\.php' | |
- | |
name: "Check source code for syntax errors" | |
run: "composer exec --no-interaction -- parallel-lint src/ tests/" | |
unit_tests: | |
name: "2️⃣ Unit and functional tests" | |
needs: | |
- "byte_level" | |
- "syntax_errors" | |
strategy: | |
#fail-fast: false | |
matrix: | |
php-version: | |
- "8.1" | |
- "8.2" | |
dependencies: | |
- "lowest" | |
- "highest" | |
runs-on: "ubuntu-22.04" | |
timeout-minutes: 5 | |
steps: | |
- | |
name: "Set up PHP" | |
uses: "shivammathur/setup-php@v2" | |
with: | |
php-version: "${{ matrix.php-version }}" | |
- | |
name: "Setup problem matcher for PHPUnit" | |
run: | | |
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | |
- | |
name: "Checkout repository" | |
uses: "actions/checkout@v3" | |
- | |
name: "Install dependencies" | |
uses: "ramsey/composer-install@v2" | |
with: | |
dependency-versions: "${{ matrix.dependencies }}" | |
- | |
name: "Execute unit tests" | |
run: "composer run unit" | |
- | |
name: "Execute feature tests" | |
run: "composer run feature" | |
- | |
name: "Send coverage to Coveralls" | |
env: | |
COVERALLS_REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
if: "${{ env.COVERALLS_REPO_TOKEN && matrix.php-version == '8.2' && matrix.dependencies == 'highest' }}" | |
run: | | |
wget --no-verbose \ | |
"https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.3/php-coveralls.phar" | |
#php ./php-coveralls.phar --verbose | |
static_analysis: | |
name: "3️⃣ Static Analysis" | |
needs: | |
- "byte_level" | |
- "syntax_errors" | |
runs-on: "ubuntu-22.04" | |
timeout-minutes: 5 | |
steps: | |
- | |
name: "Set up PHP" | |
uses: "shivammathur/setup-php@v2" | |
with: | |
php-version: "8.2" | |
coverage: "none" | |
- | |
name: "Checkout repository" | |
uses: "actions/checkout@v3" | |
- | |
name: "Check JSON files" | |
run: | | |
git ls-files --cached -z -- '*\.json' \ | |
| xargs -t --null -L 1 -- \ | |
php -r 'json_decode(file_get_contents($argv[1]), null, 512, JSON_THROW_ON_ERROR);' | |
- | |
name: "Validate Composer configuration" | |
run: "composer validate --no-interaction --strict" | |
- | |
name: "Install dependencies" | |
uses: "ramsey/composer-install@v2" | |
with: | |
dependency-versions: "highest" | |
- | |
name: "Check PSR-4 mapping 🐌" | |
run: "composer dump-autoload --optimize --strict-psr" | |
- | |
name: "Checks for security vulnerability advisories" | |
run: "composer audit" | |
- | |
name: "Perform static analysis" | |
run: "composer run stan" | |
coding_standards: | |
name: "4️⃣ Coding Standards" | |
needs: | |
- "byte_level" | |
- "syntax_errors" | |
runs-on: "ubuntu-22.04" | |
timeout-minutes: 5 | |
steps: | |
- | |
name: "Set up PHP" | |
uses: "shivammathur/setup-php@v2" | |
with: | |
php-version: "8.2" | |
coverage: "none" | |
tools: "phpcs,cs2pr" | |
- | |
name: "Checkout repository" | |
uses: "actions/checkout@v3" | |
- | |
name: "Check EditorConfig configuration" | |
run: "test -f .editorconfig" | |
- | |
name: "Check adherence to EditorConfig" | |
uses: "greut/eclint-action@v0" | |
- | |
name: "Look for TAB characters in the middle of the line 🐌" | |
run: | | |
! git grep --perl-regexp --line-number -I '^(?!//)[^\t]+\t' | |
- | |
name: "Install dependencies" | |
uses: "ramsey/composer-install@v2" | |
with: | |
dependency-versions: "highest" | |
- | |
name: "Detect coding standards violations" | |
id: "phpcsfixer" | |
run: "composer run cs" | |
- | |
name: "Annotate PHP-CS-Fixer results" | |
if: "${{ failure() && steps.phpcsfixer.outcome == 'failure' }}" | |
run: "composer run cs -- --format=checkstyle | cs2pr" | |
- | |
# Move TODO-s into GitHub issues! | |
name: "Search for TODO-s and FIXME-s 🐌" | |
run: | | |
! git grep --extended-regexp --ignore-case '\b(TODO|FIXME)\b' -- ':!:*/back-end\.yml' | |
exported_files: | |
name: "5️⃣ Exported files" | |
needs: | |
- "byte_level" | |
- "syntax_errors" | |
runs-on: "ubuntu-22.04" | |
timeout-minutes: 1 | |
steps: | |
- | |
name: "Checkout repository" | |
uses: "actions/checkout@v3" | |
- | |
name: "Check for ignored files in the index 🐌" | |
run: | | |
IGNORED_FILES="$(git ls-files --cached --ignored --exclude-standard)" | |
test -z "${IGNORED_FILES}" | |
- | |
name: "Check exported files" | |
run: | | |
EXPECTED="LICENSE,README.md,composer.json" | |
CURRENT="$( | |
git archive HEAD \ | |
| tar --list --exclude="src" --exclude="src/*" --exclude="docs" --exclude="docs/*" \ | |
| paste --serial --delimiters="," | |
)" | |
echo "CURRENT =${CURRENT}" | |
echo "EXPECTED=${EXPECTED}" | |
test "${CURRENT}" = "${EXPECTED}" |