name: PR CI # Pull requests go to a release branch (features) or to production (the release). develop only takes # the sync after a release. See README.md, "Development cycle". on: pull_request: branches: ['release/**', production] env: COMPOSER_NO_INTERACTION: '1' jobs: # Does the pull request follow the cycle: right branches, a version above the latest tag, a changelog # section for a release. flow: runs-on: docker container: image: webdevops/php:8.4 steps: - name: checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: tests of the release scripts run: python3 -m unittest discover -s .gitea/scripts - name: development cycle run: | git config --global --add safe.directory "$(pwd)" python3 .gitea/scripts/check_flow.py env: BASE_REF: ${{ github.base_ref }} HEAD_REF: ${{ github.head_ref }} # Every piece of work records its tokens and hours (TOKENS.md). Exempt: release/*, renovate/*, bots. ledger: runs-on: docker container: image: webdevops/php:8.4 steps: - name: checkout uses: actions/checkout@v4 - name: token ledger updated run: | git config --global --add safe.directory "$(pwd)" python3 .gitea/scripts/check_tokens.py env: BASE_REF: ${{ github.base_ref }} HEAD_REF: ${{ github.head_ref }} PR_AUTHOR: ${{ github.event.pull_request.user.login }} # Style and tests, with the newest dependencies the constraints allow and with the oldest: a package # has to work for everyone in between. test: runs-on: docker container: image: webdevops/php:8.4 strategy: fail-fast: false matrix: dependencies: [stable, lowest] steps: - name: checkout uses: actions/checkout@v4 - name: cache composer downloads uses: actions/cache@v4 with: path: ~/.composer/cache key: composer-${{ matrix.dependencies }}-${{ hashFiles('composer.json') }} restore-keys: | composer-${{ matrix.dependencies }}- - name: composer validate run: composer validate --strict --no-check-lock - name: install dependencies (${{ matrix.dependencies }}) env: COMPOSER_MAX_PARALLEL_HTTP: '4' run: | flags="--prefer-stable --prefer-dist" [ "${{ matrix.dependencies }}" = "lowest" ] && flags="--prefer-lowest $flags" for attempt in 1 2 3; do composer update $flags && exit 0 echo "composer failed (attempt $attempt of 3), trying again" >&2 sleep $((attempt * 10)) done exit 1 - name: lint (pint) if: matrix.dependencies == 'stable' run: vendor/bin/pint --test - name: pest tests run: vendor/bin/pest # The screens (ui/) are built into resources/dist, which is committed so a site needs no Node. Check that the # sources type-check and that the committed bundle is what the sources build to. The node image has git (see below). ui: runs-on: docker container: image: node:22-bookworm steps: - name: checkout uses: actions/checkout@v4 - name: install run: cd ui && npm ci --no-audit --no-fund - name: type check run: cd ui && npm run typecheck - name: build run: cd ui && npm run build - name: the committed bundle is up to date run: | git config --global --add safe.directory "$(pwd)" git diff --exit-code -- resources/dist || { echo "resources/dist is out of date: run 'npm run build' in ui/ and commit it" >&2; exit 1; } # Known vulnerabilities in the dependencies, and secrets or bad settings in the repository. security: runs-on: docker container: image: webdevops/php:8.4 steps: - name: checkout uses: actions/checkout@v4 - name: cache composer downloads uses: actions/cache@v4 with: path: ~/.composer/cache key: composer-security-${{ hashFiles('composer.json') }} restore-keys: | composer-security- - name: install dependencies env: COMPOSER_MAX_PARALLEL_HTTP: '4' run: | for attempt in 1 2 3; do composer update --prefer-stable --prefer-dist --no-scripts && exit 0 echo "composer failed (attempt $attempt of 3), trying again" >&2 sleep $((attempt * 10)) done exit 1 - name: composer audit run: composer audit # Pull requests to a release branch merge by themselves when the check below is green. # Every job that checks out runs in an image with git: without git the checkout is the archive of the # repository, which leaves out what .gitattributes export-ignores (.gitea/ with these scripts). release-automerge: runs-on: docker needs: pr-ci if: startsWith(github.base_ref, 'release/') && needs.pr-ci.result == 'success' container: image: webdevops/php:8.4 steps: - name: checkout uses: actions/checkout@v4 - name: enable auto-merge run: python3 .gitea/scripts/auto_merge.py env: GT_URL: https://git.iriks.casa GT_OWNER: iriks-it GT_REPO: laravel-manager GT_TOKEN: ${{ secrets.DEPLOY_TOKEN }} PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} # The one check the branch protection asks for (`PR CI / pr-ci (pull_request)`): green only when # every job above is. Do not rename it without changing the protection rule. pr-ci: runs-on: docker needs: [flow, ledger, test, ui, security] if: always() container: image: alpine:3.20 steps: - name: all checks green run: | echo "flow=${{ needs.flow.result }} ledger=${{ needs.ledger.result }} test=${{ needs.test.result }} ui=${{ needs.ui.result }} security=${{ needs.security.result }}" [ "${{ needs.flow.result }}" = "success" ] && [ "${{ needs.ledger.result }}" = "success" ] && [ "${{ needs.test.result }}" = "success" ] && [ "${{ needs.ui.result }}" = "success" ] && [ "${{ needs.security.result }}" = "success" ]