diff --git a/.github/settings.yml b/.github/settings.yml index d727013e..23a63fc3 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -89,31 +89,35 @@ rulesets: strict_required_status_checks_policy: true do_not_enforce_on_create: false required_status_checks: - - context: 'cgl' + - context: 'Checks / Perform Composer checks' integration_id: 15368 - - context: 'Tests (PHP 8.2, Ubuntu & highest dependencies)' + - context: 'Checks / Perform npm checks' integration_id: 15368 - - context: 'Tests (PHP 8.2, Ubuntu & lowest dependencies)' + - context: 'Checks / Perform repository checks' integration_id: 15368 - - context: 'Tests (PHP 8.3, Ubuntu & highest dependencies)' + - context: 'Unit tests (PHP 8.2, Ubuntu & highest dependencies) / Run tests' integration_id: 15368 - - context: 'Tests (PHP 8.3, Ubuntu & lowest dependencies)' + - context: 'Unit tests (PHP 8.2, Ubuntu & lowest dependencies) / Run tests' integration_id: 15368 - - context: 'Tests (PHP 8.4, Ubuntu & highest dependencies)' + - context: 'Unit tests (PHP 8.3, Ubuntu & highest dependencies) / Run tests' integration_id: 15368 - - context: 'Tests (PHP 8.4, Ubuntu & lowest dependencies)' + - context: 'Unit tests (PHP 8.3, Ubuntu & lowest dependencies) / Run tests' integration_id: 15368 - - context: 'Tests (PHP 8.5, Ubuntu & highest dependencies)' + - context: 'Unit tests (PHP 8.4, Ubuntu & highest dependencies) / Run tests' integration_id: 15368 - - context: 'Tests (PHP 8.5, Ubuntu & lowest dependencies)' + - context: 'Unit tests (PHP 8.4, Ubuntu & lowest dependencies) / Run tests' integration_id: 15368 - - context: 'Tests (PHP 8.5, macOS & highest dependencies)' + - context: 'Unit tests (PHP 8.5, Ubuntu & highest dependencies) / Run tests' integration_id: 15368 - - context: 'Tests (PHP 8.5, Windows & highest dependencies)' + - context: 'Unit tests (PHP 8.5, Ubuntu & lowest dependencies) / Run tests' integration_id: 15368 - - context: 'Tests (E2E)' + - context: 'Unit tests (PHP 8.5, macOS & highest dependencies) / Run tests' integration_id: 15368 - - context: 'Test coverage' + - context: 'Unit tests (PHP 8.5, Windows & highest dependencies) / Run tests' + integration_id: 15368 + - context: 'E2E tests / Run tests' + integration_id: 15368 + - context: 'Test coverage / Collect test coverage' integration_id: 15368 bypass_actors: - actor_id: 5 diff --git a/.github/workflows/cgl.yaml b/.github/workflows/cgl.yaml deleted file mode 100644 index bec8d2ae..00000000 --- a/.github/workflows/cgl.yaml +++ /dev/null @@ -1,60 +0,0 @@ -name: CGL -on: - push: - branches: - - '**' - pull_request: - branches: - - main - -permissions: - contents: read - -jobs: - prepare: - name: Prepare workflow - uses: eliashaeussler/.github/.github/workflows/pull-request.yaml@fdc23f43e6ba48018b997f552dd39f9944c17c86 # main - - cgl: - runs-on: ubuntu-latest - needs: prepare - if: needs.prepare.outputs.continue == 'true' - permissions: - security-events: write - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - with: - persist-credentials: false - - # Prepare environment - - name: Setup PHP - uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2 - with: - # We use the minimum supported PHP version - php-version: 8.2 # renovate-ignore - ini-file: development - tools: composer:v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Setup Node - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 - with: - node-version: 24 - cache: npm - - # Install dependencies - - name: Install Composer dependencies - uses: ramsey/composer-install@5c2bcf28d7b060ef3c601d7b476d5430a7b46c27 #v4 - - name: Install Frontend dependencies - run: npm ci - - # Perform checks - - name: Perform Composer checks - run: composer ci - shell: bash - - name: Perform npm checks - run: npm run ci - - # Zizmor - - name: Run zizmor - uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..a370f5fd --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,77 @@ +name: CI + +on: + push: + branches: + - '**' + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + prepare: + name: 'Prepare workflow' + uses: eliashaeussler/gha/.github/workflows/preparation.yaml@b4023b28e2974ed4e7ec3ce4b9a4503c98369b3c # 0.1.1 + + checks: + name: 'Checks' + + needs: [prepare] + if: ${{ needs.prepare.outputs.continue == 'true' }} + + permissions: + security-events: write + + uses: eliashaeussler/gha/.github/workflows/checks.yaml@b4023b28e2974ed4e7ec3ce4b9a4503c98369b3c # 0.1.1 + with: + # We use the minimum supported PHP version + php-version: 8.2 # renovate-ignore + npm: true + + unit-tests: + name: 'Unit tests (PHP ${{ matrix.php-version }}, ${{ matrix.os }} & ${{ matrix.dependencies }} dependencies)' + + needs: [prepare] + if: ${{ needs.prepare.outputs.continue == 'true' }} + + strategy: + fail-fast: false + matrix: + php-version: ["8.2", "8.3", "8.4", "8.5"] + dependencies: ["highest", "lowest"] + os: ["Ubuntu"] + include: + - php-version: "8.5" + dependencies: "highest" + os: "macOS" + - php-version: "8.5" + dependencies: "highest" + os: "Windows" + + uses: eliashaeussler/gha/.github/workflows/composer-tests.yaml@b4023b28e2974ed4e7ec3ce4b9a4503c98369b3c # 0.1.1 + with: + php-version: ${{ matrix.php-version }} + dependencies: ${{ matrix.dependencies }} + os: ${{ matrix.os }} + command: 'test:unit' + + e2e-tests: + name: 'E2E tests' + + needs: [prepare] + if: ${{ needs.prepare.outputs.continue == 'true' }} + + uses: eliashaeussler/gha/.github/workflows/composer-tests.yaml@b4023b28e2974ed4e7ec3ce4b9a4503c98369b3c # 0.1.1 + with: + command: 'test:e2e' + + test-coverage: + name: 'Test coverage' + + needs: [prepare] + if: ${{ needs.prepare.outputs.continue == 'true' }} + + uses: eliashaeussler/gha/.github/workflows/composer-test-coverage.yaml@b4023b28e2974ed4e7ec3ce4b9a4503c98369b3c # 0.1.1 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a215e05a..c658398e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -6,232 +6,116 @@ on: workflow_dispatch: env: + PHAR_FILE: '.build/cache-warmup.phar' REF_NAME: ${{ github.ref_name }} jobs: - phar: - name: Compile PHAR + assets: + name: 'Build release assets' runs-on: ubuntu-latest - permissions: - contents: read - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - with: - persist-credentials: false - # Prepare environment - - name: Setup PHP - uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2 - with: - php-version: 8.5 - tools: composer:v2, phive - - # Compile PHAR - - name: Install box - run: phive install --trust-gpg-keys 2DF45277AEF09A2F humbug/box - - name: Install Composer dependencies - uses: ramsey/composer-install@5c2bcf28d7b060ef3c601d7b476d5430a7b46c27 #v4 - with: - composer-options: "--no-dev" - ignore-cache: true - - name: Compile PHAR - run: ./tools/box compile --with-docker - - # Sign PHAR file - - name: Import GPG key - uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7 - with: - gpg_private_key: ${{ secrets.PHAR_GPG_PRIVATE_KEY }} - passphrase: ${{ secrets.PHAR_GPG_PASSPHRASE }} - - name: Sign PHAR file - run: gpg --armor --output .build/cache-warmup.phar.asc --yes --detach-sig .build/cache-warmup.phar - - # Upload compiled PHAR as artifact - - name: Upload artifact - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 - with: - name: phar - path: | - .build/cache-warmup.phar - .build/cache-warmup.phar.asc - Dockerfile - - docker: - name: Docker deploy - runs-on: ubuntu-latest - needs: phar permissions: contents: read packages: write + + outputs: + phar-artifact-name: ${{ steps.phar.outputs.artifact-name }} + steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - name: 'Checkout' + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: persist-credentials: false - # Check if tag is valid - - name: Check tag - if: ${{ github.event_name != 'workflow_dispatch' }} - run: | - if ! [[ "$REF_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - exit 1 - fi - - # Download PHAR and Dockerfile - - name: Download artifact - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 - with: - name: phar - - name: Make PHAR executable - run: chmod +x .build/cache-warmup.phar - - # Generate metadata - - name: Generate image metadata - id: meta - uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6 + - name: 'Build PHAR' + uses: eliashaeussler/gha/.github/actions/build-phar@b4023b28e2974ed4e7ec3ce4b9a4503c98369b3c # 0.1.1 + id: phar with: - images: | - eliashaeussler/cache-warmup - ghcr.io/eliashaeussler/cache-warmup - tags: | - type=raw,value=latest,enable=${{ github.event_name != 'workflow_dispatch' }} - type=semver,pattern={{version}} - type=raw,value=${{ env.REF_NAME }},enable=${{ github.event_name == 'workflow_dispatch' }} - - # Prepare build - - name: Set up QEMU - uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4 - - # Login at Docker Hub - - name: Login to Docker Hub - uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + target-file: ${{ env.PHAR_FILE }} + build-dockerfile: true + gpg-key: ${{ secrets.PHAR_GPG_PRIVATE_KEY }} + gpg-passphrase: ${{ secrets.PHAR_GPG_PASSPHRASE }} - # Login at GitHub container registry - - name: Login to GHCR - uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + - name: 'Make PHAR executable' + run: chmod +x "$PHAR_FILE" - # Build and push image - - name: Build and push - uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7 + - name: 'Build Docker' + uses: eliashaeussler/gha/.github/actions/build-docker@b4023b28e2974ed4e7ec3ce4b9a4503c98369b3c # 0.1.1 with: - context: . - push: true - platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} + ghcr-token: ${{ secrets.GITHUB_TOKEN }} docs: - name: Publish documentation + name: 'Build and deploy documentation' runs-on: ubuntu-latest - needs: phar + + needs: [assets] + environment: name: github-pages - url: ${{ steps.deployment.outputs.page_url }} + url: ${{ steps.deploy.outputs.pages-url }} + permissions: contents: read pages: write id-token: write - # Allow one concurrent deployment concurrency: group: pages cancel-in-progress: true steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - name: 'Checkout' + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: persist-credentials: false - # Prepare environment - - name: Setup Node - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 - with: - node-version: 24 - package-manager-cache: false - - name: Setup PHP - uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2 - with: - php-version: 8.5 - coverage: none - - name: Setup Pages - uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6 - - # Download PHAR file - - name: Download artifact + - name: 'Download PHAR file' uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 with: - name: phar - - name: Make PHAR executable - run: chmod +x .build/cache-warmup.phar - - # Move PHAR to public folder - - name: Publish PHAR file - run: | - mv -v .build/cache-warmup.phar docs/public/ - mv -v .build/cache-warmup.phar.asc docs/public/ + name: ${{ needs.assets.outputs.phar-artifact-name }} - # Install dependencies - - name: Install Frontend dependencies - run: npm ci + - name: 'Make PHAR executable' + run: chmod +x "$PHAR_FILE" - # Render documentation - - name: Render documentation - run: npm run docs:build + - name: 'Publish PHAR file' + run: | + mv -v "${PHAR_FILE}" docs/public/ + mv -v "${PHAR_FILE}.asc" docs/public/ - # Deploy documentation - - name: Upload artifact - uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5 + - name: 'Build and deploy docs' + id: deploy + uses: eliashaeussler/gha/.github/actions/deploy-pages@b4023b28e2974ed4e7ec3ce4b9a4503c98369b3c # 0.1.1 with: - path: 'docs/.vitepress/dist' - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5 + build-command: 'docs:build' + base-path: 'docs/.vitepress/dist' - # Warm up cache - - name: Run cache warmup + - name: 'Run cache warmup' uses: eliashaeussler/cache-warmup-action@a0c1504d177d494a44681009bc6838df654d4b98 # v1 with: - sitemaps: ${{ steps.deployment.outputs.page_url }}/sitemap.xml + sitemaps: ${{ steps.deploy.outputs.pages-url }}/sitemap.xml progress: true verbosity: v release: - name: Create release - if: ${{ github.event_name != 'workflow_dispatch' }} + name: 'Create release' runs-on: ubuntu-latest - needs: phar + + if: ${{ github.event_name != 'workflow_dispatch' }} + + needs: [assets] + permissions: contents: write + steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - name: 'Checkout' + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: persist-credentials: false - # Check if tag is valid - - name: Check tag - run: | - if ! [[ "${REF_NAME}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - exit 1 - fi - - # Download PHAR - - name: Download artifact - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 + - name: 'Create release' + uses: eliashaeussler/gha/.github/actions/create-release@b4023b28e2974ed4e7ec3ce4b9a4503c98369b3c # 0.1.1 with: - name: phar - - name: Make PHAR executable - run: chmod +x .build/cache-warmup.phar - - # Create release - - name: Create release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh release create "${REF_NAME}" --generate-notes .build/cache-warmup.phar .build/cache-warmup.phar.asc + artifact-name: ${{ needs.assets.outputs.phar-artifact-name }} diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml deleted file mode 100644 index 2b3159bf..00000000 --- a/.github/workflows/tests.yaml +++ /dev/null @@ -1,142 +0,0 @@ -name: Tests -on: - push: - branches: - - '**' - pull_request: - branches: - - main - -permissions: - contents: read - -jobs: - prepare: - name: Prepare workflow - uses: eliashaeussler/.github/.github/workflows/pull-request.yaml@fdc23f43e6ba48018b997f552dd39f9944c17c86 # main - - tests: - name: Tests (PHP ${{ matrix.php-version }}, ${{ matrix.os }} & ${{ matrix.dependencies }} dependencies) - runs-on: ${{ matrix.os }}-latest - needs: prepare - if: needs.prepare.outputs.continue == 'true' - strategy: - fail-fast: false - matrix: - php-version: ["8.2", "8.3", "8.4", "8.5"] - dependencies: ["highest", "lowest"] - os: ["Ubuntu"] - include: - - php-version: "8.5" - dependencies: "highest" - os: "macOS" - - php-version: "8.5" - dependencies: "highest" - os: "Windows" - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - with: - persist-credentials: false - - # Prepare environment - - name: Setup PHP - uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2 - with: - php-version: ${{ matrix.php-version }} - ini-file: development - tools: composer:v2 - coverage: none - - # Install dependencies - - name: Install Composer dependencies - uses: ramsey/composer-install@5c2bcf28d7b060ef3c601d7b476d5430a7b46c27 #v4 - with: - dependency-versions: ${{ matrix.dependencies }} - - # Run tests - - name: Run tests - run: composer test:unit - - coverage: - name: Test coverage - runs-on: ubuntu-latest - needs: prepare - if: needs.prepare.outputs.continue == 'true' - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - with: - persist-credentials: false - - # Prepare environment - - name: Setup PHP - uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2 - with: - php-version: 8.5 - ini-file: development - tools: composer:v2 - coverage: pcov - - # Install dependencies - - name: Install Composer dependencies - uses: ramsey/composer-install@5c2bcf28d7b060ef3c601d7b476d5430a7b46c27 #v4 - - # Run tests - - name: Build coverage directory - run: mkdir -p .build/coverage - - name: Run tests with coverage - run: composer test:unit:coverage - - # Upload artifact - - name: Fix coverage path - working-directory: .build/coverage - run: sed -i 's#/home/runner/work/cache-warmup/cache-warmup#${{ github.workspace }}#g' clover.xml - - name: Upload coverage artifact - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 - with: - name: coverage - path: .build/coverage/clover.xml - retention-days: 7 - - coverage-report: - name: Report test coverage - runs-on: ubuntu-latest - needs: coverage - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - with: - persist-credentials: false - - # Download artifact - - name: Download coverage artifact - id: download - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 - with: - name: coverage - - # Coveralls - - name: Coveralls report - uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2 - with: - file: ${{ steps.download.outputs.download-path }}/clover.xml - - e2e: - name: Tests (E2E) - runs-on: ubuntu-latest - needs: prepare - if: needs.prepare.outputs.continue == 'true' - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - with: - persist-credentials: false - - # Prepare environment - - name: Setup PHP - uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2 - with: - php-version: 8.5 - ini-file: development - tools: composer:v2 - - # Run tests - - name: Run tests - run: composer test:e2e