Skip to content

fix(AAP-79243): sync job labels and expose label_ids in report response #1437

fix(AAP-79243): sync job labels and expose label_ids in report response

fix(AAP-79243): sync job labels and expose label_ids in report response #1437

Workflow file for this run

name: "PR checks"
on:
pull_request:
jobs:
pr-checks:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: metrics_service
POSTGRES_USER: metrics_service
POSTGRES_PASSWORD: metrics_service
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: "Check PR target"
env:
BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
run: |
if [[ "$BASE_REPO" == "ansible/metrics-service" && "$BASE_BRANCH" == "devel" ]]; then
echo "✓ PR targets devel on upstream"
elif [[ "$BASE_BRANCH" == stable-2.* ]]; then
echo "✓ PR targets $BASE_BRANCH"
else
echo "::error::PRs should target devel on ansible/metrics-service or a stable-2.x branch"
exit 1
fi
- name: "Checkout metrics-service (${{ github.ref }})"
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: "Check for wildcard cron minutes in renovate config"
run: |
if grep -Pn '"schedule".*"\* ' renovate.json; then
echo "::error::Cron schedules in renovate.json must not use * for minutes (runs every minute). Use a specific minute like 0."
exit 1
fi
- name: "Install uv"
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
- name: "Set up Python"
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version-file: "pyproject.toml"
- name: "Check for changes in uv.lock"
run: |
uv sync
if ! git diff --quiet uv.lock; then
echo "uv.lock has changed. Run 'uv sync' locally and commit the updated lock file."
git diff uv.lock
exit 1 # Fail the job
fi
- name: "Run ruff check"
run: |
uvx ruff check --output-format=github .
- name: "Check ruff format"
run: |
uvx ruff format --check
- name: "Check for missing migrations"
env:
METRICS_SERVICE_DATABASES__default__HOST: localhost
METRICS_SERVICE_DATABASES__default__PORT: 5432
METRICS_SERVICE_DATABASES__default__USER: metrics_service
METRICS_SERVICE_DATABASES__default__PASSWORD: metrics_service
METRICS_SERVICE_DATABASES__default__NAME: metrics_service
METRICS_SERVICE_DATABASES__default__OPTIONS__sslmode: disable
run: |
if ! uv run ./manage.py makemigrations --check; then
echo "Models have changed. Run 'uv run ./manage.py makemigrations' locally and commit the updated migrations."
exit 1 # Fail the job
fi
- name: Generate OpenAPI schema
env:
METRICS_SERVICE_DATABASES__default__HOST: localhost
METRICS_SERVICE_DATABASES__default__PORT: 5432
METRICS_SERVICE_DATABASES__default__USER: metrics_service
METRICS_SERVICE_DATABASES__default__PASSWORD: metrics_service
METRICS_SERVICE_DATABASES__default__NAME: metrics_service
METRICS_SERVICE_DATABASES__default__OPTIONS__sslmode: disable
run: |
mkdir -p tools/openapi-schema
uv run --frozen python manage.py spectacular --file tools/openapi-schema/metrics-service.yaml
uv run --frozen python manage.py spectacular --format openapi-json --file tools/openapi-schema/metrics-service.json
git diff --exit-code -- tools/openapi-schema/metrics-service.yaml
git diff --exit-code -- tools/openapi-schema/metrics-service.json
- name: Validate OpenAPI schema
run: |
uv run --frozen python -c "
from openapi_spec_validator import validate
import yaml
spec = yaml.safe_load(open('tools/openapi-schema/metrics-service.yaml'))
validate(spec)
print('✓ OpenAPI schema is valid!')
"