diff --git a/.editorconfig b/.editorconfig index 5d36dbe..1d1b870 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,6 +7,9 @@ insert_final_newline = true indent_style = tab indent_size = 4 trim_trailing_whitespace = true +block_comment_start = /* +block_comment = * +block_comment_end = */ [*.md] trim_trailing_whitespace = false diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml new file mode 100644 index 0000000..2b4b69d --- /dev/null +++ b/.github/workflows/integrate.yml @@ -0,0 +1,144 @@ +name: "Integrate" + +on: + push: + branches: + - "develop" + - "trunk" + pull_request: null + +jobs: + byte_level: + name: "0️⃣ Byte-level" + runs-on: "ubuntu-20.04" + steps: + - name: "Checkout code" + 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 find . -type f -name "*.php" -print0 | xargs -0 -- grep -PHn "[^\t -~]" + + syntax_errors: + name: "1️⃣ Syntax errors" + runs-on: "ubuntu-20.04" + steps: + - name: "Set up PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "7.2" + + - name: "Checkout code" + uses: "actions/checkout@v3" + + - name: "Install dependencies" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "highest" + + - name: "Check source code for syntax errors" + run: "composer exec -- parallel-lint src/" + + unit_tests: + name: "2️⃣ Unit and functional tests" + needs: + - "byte_level" + - "syntax_errors" + runs-on: "ubuntu-20.04" + strategy: + fail-fast: false + matrix: + php-version: + - "7.2" + - "7.4" + - "8.0" + - "8.1" + dependencies: + - "highest" + - "lowest" + steps: + - name: "Set up PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + + - name: "Checkout code" + uses: "actions/checkout@v3" + + - name: "Install dependencies" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "${{ matrix.dependencies }}" + + - name: "Execute unit tests" + run: "composer run test:phpunit" + # @TODO Functional tests + +# - name: "Tests have failed: display logs" +# if: "${{ failure() }}" +# run: "cat storage/logs/*.log" + +# - name: Send coverage to Coveralls +# if: "matrix.php-version == '8.1' && matrix.dependencies == 'highest'" +# env: +# COVERALLS_REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}" +# run: | +# wget "https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.2/php-coveralls.phar" +# php ./php-coveralls.phar -v + + static_analysis: + name: "3️⃣ Static Analysis" + needs: + - "byte_level" + - "syntax_errors" + runs-on: "ubuntu-20.04" + steps: + - name: "Set up PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "8.0" + + - name: "Checkout code" + uses: "actions/checkout@v3" + + - name: "Validate Composer configuration" + run: "composer validate --strict" + + - name: "Install dependencies" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "highest" + + - name: "Execute static analysis" + run: "composer run test:phpstan" + # @TODO Magic Number Detector, Copy-Paste Detector + + coding_standards: + name: "4️⃣ Coding Standards" + needs: + - "byte_level" + - "syntax_errors" + runs-on: "ubuntu-20.04" + steps: + - name: "Set up PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "8.0" + + - name: "Checkout code" + uses: "actions/checkout@v3" + + - name: "Check adherence to EditorConfig" + uses: "greut/eclint-action@v0" + + - name: "Install dependencies" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "highest" + + - name: "Check coding style" + run: "composer run test:phpcs" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index b522735..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Tests - -on: - push: - branches: - - 'develop' - - 'trunk' - pull_request: - branches: - - '**' - -jobs: - build: - strategy: - matrix: - php: ['7.2', '7.4', '8.0', '8.1'] - fail-fast: false - name: Unit tests - runs-on: ubuntu-18.04 - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Install PHP - uses: shivammathur/setup-php@2.19.1 - with: - php-version: ${{ matrix.php }} - ini-file: development - coverage: none - - - name: Get Composer Cache Directory - id: composer-cache-dir - run: | - echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache PHP Dependencies - id: composer-cache - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache-dir.outputs.dir }} - key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('composer.json') }} - - - name: Install PHP Dependencies - run: | - composer install --prefer-dist --no-progress --no-interaction - - - name: Run the tests - run: | - composer test:phpunit diff --git a/composer.json b/composer.json index 88e2184..5f7b7e6 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "ergebnis/composer-normalize": "^2.0", "ergebnis/phpstan-rules": "^1.0", "humanmade/coding-standards": "^1.1", + "php-parallel-lint/php-parallel-lint": "^1.3", "phpcompatibility/php-compatibility": "^9.3", "phpstan/phpstan": "^1.8", "phpstan/phpstan-phpunit": "^1.1",