71744cc264
Update all GitHub Actions to their latest major versions for improved performance, security patches, and Node.js runtime compatibility. Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
166 lines
4.8 KiB
YAML
166 lines
4.8 KiB
YAML
name: Main Workflow
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
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@v6
|
|
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)**/find.yml' | 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@v6
|
|
with:
|
|
fetch-depth: 50
|
|
- name: Check that the CHANGELOG has been modified in the current branch
|
|
run: git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.after }} | grep 'CHANGELOG.md'
|
|
|
|
lint-changelog:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
- 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/backend
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version-file: "src/backend/pyproject.toml"
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v6
|
|
- name: Install the project
|
|
run: uv sync --locked --all-extras
|
|
|
|
- name: Check code formatting with ruff
|
|
run: uv run ruff format . --diff
|
|
- name: Lint code with ruff
|
|
run: uv run ruff check .
|
|
- name: Lint code with pylint
|
|
run: uv run pylint .
|
|
|
|
test-back:
|
|
runs-on: ubuntu-latest
|
|
|
|
defaults:
|
|
run:
|
|
working-directory: src/backend
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:15
|
|
env:
|
|
POSTGRES_DB: find
|
|
POSTGRES_USER: dinum
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5432:5432
|
|
# needed because the postgres container does not provide a healthcheck
|
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
|
|
|
opensearch:
|
|
image: opensearchproject/opensearch:latest
|
|
env:
|
|
discovery.type: single-node
|
|
plugins.security.disabled: true
|
|
plugins.security.ssl.http.enabled: false
|
|
OPENSEARCH_INITIAL_ADMIN_PASSWORD: find.PASS123
|
|
ports:
|
|
- 9200:9200
|
|
options: >-
|
|
--health-cmd "curl -s http://localhost:9200 > /dev/null || exit 1"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
|
|
env:
|
|
DJANGO_CONFIGURATION: Test
|
|
DJANGO_SETTINGS_MODULE: find.settings
|
|
DJANGO_SECRET_KEY: ThisIsAnExampleKeyForTestPurposeOnly
|
|
OIDC_OP_JWKS_ENDPOINT: /endpoint-for-test-purpose-only
|
|
DB_HOST: localhost
|
|
DB_NAME: find
|
|
DB_USER: dinum
|
|
DB_PASSWORD: pass
|
|
DB_PORT: 5432
|
|
STORAGES_STATICFILES_BACKEND: django.contrib.staticfiles.storage.StaticFilesStorage
|
|
OPENSEARCH_HOST: localhost
|
|
OPENSEARCH_PASSWORD: find.PASS123
|
|
OPENSEARCH_USE_SSL: false
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Create writable /data
|
|
run: |
|
|
sudo mkdir -p /data/media && \
|
|
sudo mkdir -p /data/static
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version-file: "src/backend/pyproject.toml"
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v6
|
|
|
|
- name: Wait for OpenSearch to be ready
|
|
run: |
|
|
for i in {1..60}; do
|
|
if curl -s http://localhost:9200 > /dev/null; then
|
|
echo "OpenSearch is ready"
|
|
exit 0
|
|
fi
|
|
echo "Waiting for OpenSearch... attempt $i"
|
|
sleep 1
|
|
done
|
|
echo "OpenSearch failed to start"
|
|
exit 1
|
|
|
|
- name: Install the dependencies
|
|
run: uv sync --locked --all-extras
|
|
|
|
- name: Run tests
|
|
run: uv run pytest
|