CI and release cycle: release branches, tag, Packagist, sync, tests, audit, Trivy
This commit is contained in:
1 parent
f74ab3a94b
commit
302a1c699d
20 files changed
+1029
-9
No files matched your search
+140
-8
@@ -1,18 +1,150 @@
|
||||
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: [production, staging]
|
||||
branches: ['release/**', production]
|
||||
|
||||
env:
|
||||
COMPOSER_NO_INTERACTION: '1'
|
||||
|
||||
jobs:
|
||||
pr-ci:
|
||||
# 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:
|
||||
- uses: actions/checkout@v4
|
||||
- run: composer validate
|
||||
- run: composer install --no-interaction --prefer-dist
|
||||
- run: vendor/bin/pint --test
|
||||
- run: vendor/bin/pest
|
||||
- run: composer audit
|
||||
- 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.
|
||||
release-automerge:
|
||||
runs-on: docker
|
||||
needs: pr-ci
|
||||
if: startsWith(github.base_ref, 'release/') && needs.pr-ci.result == 'success'
|
||||
container:
|
||||
image: python:3.12-alpine
|
||||
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" ]
|
||||
@@ -0,0 +1,90 @@
|
||||
name: Release
|
||||
|
||||
# A push to production is the merge of a release pull request. Check it once more, tag it, tell
|
||||
# Packagist, and bring develop up to date, so the next features start from what was released.
|
||||
on:
|
||||
push:
|
||||
branches: [production]
|
||||
|
||||
concurrency:
|
||||
group: release
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
verify:
|
||||
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
|
||||
|
||||
- name: pest tests
|
||||
run: vendor/bin/pest
|
||||
|
||||
- name: composer audit
|
||||
run: composer audit
|
||||
|
||||
tag:
|
||||
runs-on: docker
|
||||
needs: verify
|
||||
container:
|
||||
image: webdevops/php:8.4
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: release
|
||||
run: |
|
||||
git config --global --add safe.directory "$(pwd)"
|
||||
python3 .gitea/scripts/release.py
|
||||
env:
|
||||
GT_URL: https://git.iriks.casa
|
||||
GT_OWNER: iriks-it
|
||||
GT_REPO: laravel-manager
|
||||
GT_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
|
||||
COMMIT_HASH: ${{ github.sha }}
|
||||
|
||||
# Needs the secrets PACKAGIST_USERNAME and PACKAGIST_TOKEN on the repository, and the package
|
||||
# submitted on packagist.org once. Without them this step only says so.
|
||||
packagist:
|
||||
runs-on: docker
|
||||
needs: tag
|
||||
container:
|
||||
image: python:3.12-alpine
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: tell Packagist
|
||||
run: python3 .gitea/scripts/packagist.py
|
||||
env:
|
||||
PACKAGIST_USERNAME: ${{ secrets.PACKAGIST_USERNAME }}
|
||||
PACKAGIST_TOKEN: ${{ secrets.PACKAGIST_TOKEN }}
|
||||
PACKAGE_URL: https://git.iriks.casa/iriks-it/laravel-manager
|
||||
|
||||
# Last: merge what was released into develop. Runs even when Packagist could not be told.
|
||||
sync-develop:
|
||||
runs-on: docker
|
||||
needs: [tag, packagist]
|
||||
if: always() && needs.tag.result == 'success'
|
||||
container:
|
||||
image: webdevops/php:8.4
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: sync develop
|
||||
run: python3 .gitea/scripts/sync_develop.py
|
||||
env:
|
||||
GT_URL: https://git.iriks.casa
|
||||
GT_OWNER: iriks-it
|
||||
GT_REPO: laravel-manager
|
||||
GT_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
|
||||
GT_BOT_USER: deploy-bot
|
||||
COMMIT_HASH: ${{ github.sha }}
|
||||
@@ -0,0 +1,32 @@
|
||||
name: Scheduled checks
|
||||
|
||||
# What was released does not stay safe: new vulnerabilities are found in old dependencies. Every
|
||||
# Monday the released code is checked again; a red run is the signal.
|
||||
on:
|
||||
schedule:
|
||||
- cron: '30 5 * * 1'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
audit:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: webdevops/php:8.4
|
||||
steps:
|
||||
- name: checkout production
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: production
|
||||
|
||||
- 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
|
||||
|
||||
- name: trivy
|
||||
run: |
|
||||
trivy fs --no-progress --scanners vuln,secret,misconfig --severity HIGH,CRITICAL --exit-code 1 --skip-dirs vendor .
|
||||
@@ -0,0 +1,27 @@
|
||||
name: Start release
|
||||
|
||||
# By hand (Actions → Start release → Run workflow): makes release/vX.Y.Z from develop.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version of the release, like 0.2.0'
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
start:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: python:3.12-alpine
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: make the release branch
|
||||
run: python3 .gitea/scripts/start_release.py
|
||||
env:
|
||||
GT_URL: https://git.iriks.casa
|
||||
GT_OWNER: iriks-it
|
||||
GT_REPO: laravel-manager
|
||||
GT_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
|
||||
VERSION: ${{ inputs.version }}
|
||||
Reference in new issue
Block a user