diff --git a/bin/build-configs b/bin/build-configs index 171cc1e..6c85b6c 100755 --- a/bin/build-configs +++ b/bin/build-configs @@ -203,6 +203,14 @@ function getFiles(array $configurationData): Collection $filesToGenerate[] = new TemplateFile(data: 'drupal-project/phpunit.xml.dist', name: 'phpunit.xml.dist'); } + if (Arr::get($configurationData, 'experimental.createGitHubActionsConfiguration', false) === true) { + $filesToGenerate[] = new TemplateFile( + data: 'ci/github-actions/ci.yml', + name: 'ci.yml', + path: '.github/workflows', + ); + } + return $filesToGenerate; } diff --git a/src/ConfigurationData.php b/src/ConfigurationData.php index 10bd44c..2341614 100644 --- a/src/ConfigurationData.php +++ b/src/ConfigurationData.php @@ -37,7 +37,11 @@ final class ConfigurationData */ #[Assert\Collection( allowExtraFields: false, - fields: ['useNewDatabaseCredentials' => new Assert\Type('boolean')] + allowMissingFields: true, + fields: [ + 'createGitHubActionsConfiguration' => new Assert\Type('boolean'), + 'useNewDatabaseCredentials' => new Assert\Type('boolean'), + ] )] public array $experimental; diff --git a/templates/ci/github-actions/ci.yml.twig b/templates/ci/github-actions/ci.yml.twig new file mode 100644 index 0000000..e587ef1 --- /dev/null +++ b/templates/ci/github-actions/ci.yml.twig @@ -0,0 +1,43 @@ +name: CI + +on: + pull_request: + push: + workflow_dispatch: + +env: + COMPOSE_DOCKER_CLI_BUILD: 1 + DOCKER_BUILDKIT: 1 + DOCKER_UID: 1001 + +jobs: + build_and_test: + name: Build and test + + runs-on: ubuntu-latest + + steps: + - name: Install just + run: | + curl --proto '=https' \ + --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin + + - name: Checkout the code + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + + - name: Build and test + run: | + docker compose version + + cp --no-clobber .env.example .env + + docker compose build --progress plain + + docker compose up --detach + docker compose logs + + just composer install --quiet --no-progress + + # TODO: add PHPCS and PHPStan + + just test --testdox --colors=always diff --git a/templates/justfile.twig b/templates/justfile.twig index 48079f0..f57c648 100644 --- a/templates/justfile.twig +++ b/templates/justfile.twig @@ -57,5 +57,5 @@ _run service command *args: --entrypoint {{ "{{ command }}"|raw }} \ --no-deps \ --rm \ - --tty \ + -T \ {{ "{{ service }} {{ args }}"|raw }}