diff --git a/.github/workflows/TestStatic.yml b/.github/workflows/TestStatic.yml new file mode 100644 index 00000000..90d43ec1 --- /dev/null +++ b/.github/workflows/TestStatic.yml @@ -0,0 +1,69 @@ +name: Test Static Tests +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + Test-Static: + runs-on: ubuntu-latest + steps: + - name: Create a Drupal project + run: composer create-project drupal/recommended-project . --ignore-platform-req=ext-gd + + - uses: actions/checkout@v3 + with: + path: drainpipe + + - name: Setup drainpipe-dev + run: mv drainpipe/drainpipe-dev . + + - uses: ./drainpipe/scaffold/github/actions/common/set-env + + - name: Install DDEV + uses: ./drainpipe/scaffold/github/actions/common/ddev + with: + git-name: Drainpipe Bot + git-email: no-reply@example.com + + - name: Setup Project + run: | + ddev config --auto + ddev start + ddev composer config extra.drupal-scaffold.gitignore true + ddev composer config --json extra.drupal-scaffold.allowed-packages '["lullabot/drainpipe-dev", "lullabot/drainpipe"]' + ddev composer config --no-plugins allow-plugins.composer/installers true + ddev composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true + ddev composer config --no-plugins allow-plugins.lullabot/drainpipe true + ddev composer config --no-plugins allow-plugins.lullabot/drainpipe-dev true + ddev composer config repositories.drainpipe --json '{"type": "path", "url": "drainpipe", "options": {"symlink": false}}' + ddev composer config repositories.drainpipe-dev --json '{"type": "path", "url": "drainpipe-dev", "options": {"symlink": false}}' + ddev composer config minimum-stability dev + ddev composer require "lullabot/drainpipe @dev" --with-all-dependencies + ddev composer require "lullabot/drainpipe-dev @dev" --dev --with-all-dependencies + # Restart is required to enable the provided Selenium containers + ddev restart + + - name: Verify files were created + run: | + test -f phpcs.xml + + - name: Fix settings.php + run: | + sed -i '/^.*container_yamls.*$/i /** @phpstan-ignore-next-line */' web/sites/default/settings.php + + - name: Run Static Tests + run: ddev task test:static + + - name: Upload test artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: test_result + path: test_result diff --git a/.github/workflows/test-phpunit.yml b/.github/workflows/test-phpunit.yml index 9268d8f4..28169a7f 100644 --- a/.github/workflows/test-phpunit.yml +++ b/.github/workflows/test-phpunit.yml @@ -214,4 +214,3 @@ jobs: command_line: xmllint --xpath 'string(//testsuites/testsuite/@tests)' test_result/phpunit.xml contains: 12 expected_result: PASSED - diff --git a/README.md b/README.md index 49f1cc00..7c21910a 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,11 @@ npx ajv-cli validate -s schema.json -d scaffold/Taskfile.yml See [.github/workflows/validate-taskfile.yml](`.github/workflows/validate-taskfile.yml`) for an example of this in use. +``` +💡 If your docroot is not the standard `web/` path, you must create a symlink to it +ln -s web/ docroot +``` + --- ## .env support diff --git a/drainpipe-dev/composer.json b/drainpipe-dev/composer.json index b914ca83..af95b401 100644 --- a/drainpipe-dev/composer.json +++ b/drainpipe-dev/composer.json @@ -48,7 +48,8 @@ "[web-root]/sites/firefox/settings.php": "scaffold/nightwatch/firefox.settings.php", "[web-root]/sites/sites.php": "scaffold/nightwatch/sites.php", "[project-root]/.ddev/docker-compose.selenium.yaml": "scaffold/nightwatch/docker-compose.selenium.yaml", - "[project-root]/test/nightwatch/example.nightwatch.js": "scaffold/nightwatch/example.nightwatch.js" + "[project-root]/test/nightwatch/example.nightwatch.js": "scaffold/nightwatch/example.nightwatch.js", + "[project-root]/phpcs.xml": "scaffold/phpcs.xml" } } }, diff --git a/scaffold/phpcs.xml b/drainpipe-dev/scaffold/phpcs.xml similarity index 100% rename from scaffold/phpcs.xml rename to drainpipe-dev/scaffold/phpcs.xml diff --git a/scaffold/phpstan.neon b/scaffold/phpstan.neon index d5edd8b2..52e34e74 100644 --- a/scaffold/phpstan.neon +++ b/scaffold/phpstan.neon @@ -1,2 +1,13 @@ includes: - - vendor/lullabot/drainpipe-dev/config/phpstan.neon + - ../../../mglaman/phpstan-drupal/extension.neon + - ../../../phpstan/phpstan-deprecation-rules/rules.neon + +parameters: + excludePaths: + - *sites/simpletest/* + - *default.settings.php + - *sites/*/files/* + - *settings.ddev.php + - */node_modules/* + # PHPStan Level 1 + level: 1 diff --git a/tasks/test.yml b/tasks/test.yml index 2e868010..53a397d5 100644 --- a/tasks/test.yml +++ b/tasks/test.yml @@ -95,11 +95,15 @@ tasks: - | {{ .FUNC_ENSURE_DIRS }} - | + CONFIG="phpstan.neon" + if [ ! -f phpstan.neon ]; then + CONFIG="vendor/lullabot/drainpipe/scaffold/phpstan.neon" + fi if [ "{{.format}}" == "junit" ]; then mkdir -p test_result - ./vendor/bin/phpstan analyse --error-format=junit {{.TEST_DIRS}} > test_result/phpstan.xml + ./vendor/bin/phpstan analyse --error-format=junit -c $CONFIG {{.TEST_DIRS}} > test_result/phpstan.xml else - ./vendor/bin/phpstan analyse {{.TEST_DIRS}} + ./vendor/bin/phpstan analyse -c $CONFIG {{.TEST_DIRS}} fi phpunit: desc: Runs PHPUnit