138 lines
4.3 KiB
YAML
138 lines
4.3 KiB
YAML
name: 💚 CI Tests
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
branches:
|
|
- '*'
|
|
|
|
jobs:
|
|
lint-git:
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'pull_request' # Makes sense only for pull requests
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: show
|
|
run: git log
|
|
- name: Enforce absence of print statements in code
|
|
run: |
|
|
! git diff origin/${{ github.event.pull_request.base.ref }}..HEAD -- . ':(exclude).github/**' | grep "print("
|
|
- name: Check absence of fixup commits
|
|
run: |
|
|
! git log | grep 'fixup!'
|
|
- name: Install gitlint
|
|
run: pip install --user requests gitlint
|
|
- name: Lint commit messages added to main
|
|
run: ~/.local/bin/gitlint --commits origin/${{ github.event.pull_request.base.ref }}..HEAD
|
|
|
|
check-changelog:
|
|
runs-on: ubuntu-latest
|
|
if: |
|
|
contains(github.event.pull_request.labels.*.name, 'noChangeLog') == false &&
|
|
github.event_name == 'pull_request'
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Check that the CHANGELOG has been modified in the current branch
|
|
run: git log --name-only --pretty="" origin/${{ github.event.pull_request.base.ref }}..HEAD | grep CHANGELOG
|
|
|
|
lint-changelog:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
- name: Check CHANGELOG max line length
|
|
run: |
|
|
max_line_length=$(cat CHANGELOG.md | grep -Ev "^\[.*\]: https://github.com" | wc -L)
|
|
if [ $max_line_length -ge 80 ]; then
|
|
echo "ERROR: CHANGELOG has lines longer than 80 characters."
|
|
exit 1
|
|
fi
|
|
|
|
lint-back:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: src/satosa
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
- name: Install Python
|
|
uses: actions/setup-python@v3
|
|
with:
|
|
python-version: '3.11'
|
|
- name: Install development dependencies
|
|
run: |
|
|
# Python's xmlsec requirement
|
|
sudo apt-get update -y -q && sudo apt-get install -y -q xmlsec1 libxmlsec1-dev
|
|
pip install --user .[dev]
|
|
- name: Check code formatting with ruff
|
|
run: ~/.local/bin/ruff format . --diff
|
|
- name: Lint code with ruff
|
|
run: ~/.local/bin/ruff check .
|
|
- name: Lint code with pylint
|
|
run: ~/.local/bin/pylint .
|
|
|
|
test-back:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: src/satosa
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
- name: Install Python
|
|
uses: actions/setup-python@v3
|
|
with:
|
|
python-version: '3.11'
|
|
- name: Install development dependencies
|
|
run: |
|
|
# Python's xmlsec requirement
|
|
sudo apt-get update -y -q && sudo apt-get install -y -q xmlsec1 libxmlsec1-dev
|
|
pip install --user .[dev]
|
|
- name: Run tests
|
|
run: ~/.local/bin/pytest
|
|
|
|
helmfile-lint:
|
|
runs-on: ubuntu-latest
|
|
# skip this job on forks since they won't have access to the required secrets
|
|
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
|
|
container:
|
|
image: ghcr.io/helmfile/helmfile:v1.2.0
|
|
steps:
|
|
-
|
|
uses: actions/create-github-app-token@v1
|
|
id: app-token
|
|
with:
|
|
app-id: ${{ secrets.APP_ID }}
|
|
private-key: ${{ secrets.PRIVATE_KEY }}
|
|
owner: numerique-gouv
|
|
repositories: secrets
|
|
-
|
|
name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
token: ${{ steps.app-token.outputs.token }}
|
|
-
|
|
name: Helmfile lint
|
|
env:
|
|
SOPS_AGE_KEY: ${{ secrets.SOPS_PRIVATE }}
|
|
run: |
|
|
HELMFILE=src/helm/helmfile.yaml.gotmpl
|
|
environments=$(< $HELMFILE awk -F'[ :]+' '/^ [^ ]/ {print $2} /^---/ { exit }')
|
|
for env in $environments; do
|
|
echo "################### $env lint ###################"
|
|
helmfile -e $env -f "$HELMFILE" lint || exit 1
|
|
echo -e "\n"
|
|
done
|