diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7326fda..3d02762 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,10 +9,41 @@ on: - 'main' - 'hotfix-*' +permissions: + contents: read + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + jobs: + static-checks: + name: Run static checks + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.3" + + - name: Validate composer.json + run: composer validate + + - name: Install dependencies + run: composer update --prefer-dist --no-progress + + - name: Run PHP_CodeSniffer + run: vendor/bin/phpcs -sp + + - name: Run Psalm + run: vendor/bin/psalm --shepherd + tests: - name: PHP ${{ matrix.php-version }} on ${{ matrix.os }} (${{ matrix.composer-options }}) - runs-on: ${{ matrix.os }} + name: Test on ${{ matrix.os }} php${{ matrix.php-version }} + runs-on: ${{ matrix.os }}-latest strategy: fail-fast: false matrix: @@ -22,15 +53,13 @@ jobs: - "8.2" - "8.3" os: - - ubuntu-latest - - windows-latest - - macOS-latest - composer-options: - - "" - - "--prefer-lowest" + - ubuntu + - windows + - macOS + steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up PHP ${{ matrix.php-version }} uses: shivammathur/setup-php@v2 @@ -40,14 +69,21 @@ jobs: coverage: xdebug ini-values: error_reporting=E_ALL - - name: Validate composer.json and composer.lock - run: composer validate - - name: Install dependencies - run: composer update - --prefer-dist - --no-progress - ${{ matrix.composer-options }} + run: composer update --prefer-dist --no-progress + + - name: Show Codeception version + run: | + echo "Tested against Codeception **v$( + composer show codeception/codeception --format json | jq -r '.versions[0]' + )**" >> "$GITHUB_STEP_SUMMARY" + shell: bash + + - name: Run unit tests tests + run: composer test-unit + + - name: Run samples + run: composer test-report-generate - - name: Run tests - run: composer test + - name: Assert samples + run: composer test-report-check diff --git a/.github/workflows/labels-verify.yml b/.github/workflows/labels-verify.yml index 2c3bd2a..a79f60f 100644 --- a/.github/workflows/labels-verify.yml +++ b/.github/workflows/labels-verify.yml @@ -4,10 +4,13 @@ on: pull_request: types: [opened, labeled, unlabeled, synchronize] +permissions: + contents: read + jobs: triage: runs-on: ubuntu-latest steps: - uses: baev/match-label-action@master with: - allowed: 'type:bug,type:new feature,type:improvement,type:dependencies,type:internal,type:invalid' + allowed: 'type:bug,type:new feature,type:improvement,type:dependencies,type:internal,type:invalid,type:docs' diff --git a/composer.json b/composer.json index 7cdc834..dc4a984 100644 --- a/composer.json +++ b/composer.json @@ -27,11 +27,11 @@ "allure-framework/allure-php-commons": "^2.3.1" }, "require-dev": { - "psalm/plugin-phpunit": "^0.19.0", + "psalm/plugin-phpunit": "^0.19.0 || ^0.20.1", "remorhaz/php-json-data": "^0.5.3", "remorhaz/php-json-path": "^0.7.7", - "squizlabs/php_codesniffer": "^3.7.2", - "vimeo/psalm": "^5.12" + "squizlabs/php_codesniffer": "^4.0.1", + "vimeo/psalm": "^5.26.1 || ^6.16.1" }, "autoload": { "psr-4": { diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 227a3bb..0ba55b0 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -4,6 +4,8 @@ src test + test/codeception/_support/_generated/* + test/codeception-report/_support/_generated/* diff --git a/src/Internal/GherkinProvider.php b/src/Internal/GherkinProvider.php index 86a8345..415768b 100644 --- a/src/Internal/GherkinProvider.php +++ b/src/Internal/GherkinProvider.php @@ -36,8 +36,8 @@ public function getLabels(): array return array_map( fn (string $value) => Label::feature($value), [ - ...array_values($this->test->getFeatureNode()->getTags()), - ...array_values($this->test->getScenarioNode()->getTags()), + ...$this->test->getFeatureNode()->getTags(), + ...$this->test->getScenarioNode()->getTags(), ], ); } diff --git a/src/Internal/UnitInfoBuilder.php b/src/Internal/UnitInfoBuilder.php index 61dfae9..524be55 100644 --- a/src/Internal/UnitInfoBuilder.php +++ b/src/Internal/UnitInfoBuilder.php @@ -22,10 +22,15 @@ public function build(?string $host, ?string $thread): TestInfo $index = $this->test->getMetadata()->getIndex(); $dataLabel = is_int($index) ? "#$index" : $index; + /** + * @var null|string + */ + $class = $fields['class']; + return new TestInfo( originalTest: $this->test, signature: $this->test->getSignature(), - class: $fields['class'] ?? null, + class: $class ?? null, method: $this->test->getMetadata()->getName(), dataLabel: $dataLabel, host: $host, diff --git a/test/codeception-report/unit/StepsTest.php b/test/codeception-report/unit/StepsTest.php index bbfefb5..fbb53de 100644 --- a/test/codeception-report/unit/StepsTest.php +++ b/test/codeception-report/unit/StepsTest.php @@ -85,6 +85,9 @@ private function createFailingStep(string $name, string $failure): Step return new class ($failure, $name) extends Meta { private string $failure; + /** + * @param array $arguments + */ public function __construct(string $failure, string $action, array $arguments = []) { parent::__construct($action, $arguments);