153 lines
5.0 KiB
YAML
153 lines
5.0 KiB
YAML
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 }})
|
|
run: |
|
|
if [ "${{ matrix.dependencies }}" = "lowest" ]; then
|
|
composer update --prefer-lowest --prefer-stable --prefer-dist
|
|
else
|
|
composer update --prefer-stable --prefer-dist
|
|
fi
|
|
|
|
- name: lint (pint)
|
|
if: matrix.dependencies == 'stable'
|
|
run: vendor/bin/pint --test
|
|
|
|
- name: pest tests
|
|
run: vendor/bin/pest
|
|
|
|
# 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: install dependencies
|
|
run: composer update --prefer-stable --prefer-dist --no-scripts
|
|
|
|
- name: composer audit
|
|
run: composer audit
|
|
|
|
- name: install trivy
|
|
run: .gitea/scripts/install-trivy.sh
|
|
|
|
# Fails on HIGH and CRITICAL. vendor/ is left out of the secret and settings scan (it is other
|
|
# people's code); the lock file made above is what the vulnerability scan reads.
|
|
- name: trivy
|
|
run: |
|
|
trivy fs --no-progress --scanners vuln,secret,misconfig --severity HIGH,CRITICAL --exit-code 1 --skip-dirs vendor .
|
|
|
|
# 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, 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 }} security=${{ needs.security.result }}"
|
|
[ "${{ needs.flow.result }}" = "success" ] && [ "${{ needs.ledger.result }}" = "success" ] && [ "${{ needs.test.result }}" = "success" ] && [ "${{ needs.security.result }}" = "success" ]
|