ci: add conditional job for OpenAPI linting based on file changes; update README with workflow details
CI / changes (push) Successful in 5s
CI / go (push) Successful in 18s
CI / openapi (push) Has been skipped
CI / bird2 (push) Failing after 25s

This commit is contained in:
Denozordec
2026-04-04 01:32:29 +07:00
parent 3992d01c3e
commit 3adfc49e5c
3 changed files with 46 additions and 1 deletions
+2
View File
@@ -2,6 +2,8 @@
В репозитории включён workflow [workflows/ci.yaml](workflows/ci.yaml).
Job **openapi** (Redocly) запускается только если в коммите или PR изменились `docs/openapi.yaml` или `redocly.yaml`; иначе шаг пропускается. Остальные jobs (`go`, `bird2`) выполняются как раньше.
Требования к runner:
- Метка `ubuntu-latest` (или измените `runs-on` под свои labels).
+43
View File
@@ -7,7 +7,50 @@ on:
branches: [main, master]
jobs:
changes:
runs-on: ubuntu-latest
outputs:
openapi: ${{ steps.openapi.outputs.changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: openapi
name: Detect OpenAPI-related file changes
run: |
set -euo pipefail
PATHS="docs/openapi.yaml redocly.yaml"
changed=false
if [ "${{ github.event_name }}" = "pull_request" ]; then
base="${{ github.event.pull_request.base.sha }}"
head="${{ github.event.pull_request.head.sha }}"
if git diff --name-only "$base" "$head" -- $PATHS | grep -q .; then
changed=true
fi
else
before="${{ github.event.before }}"
after="${{ github.sha }}"
if [ -n "$before" ] && [ "$before" != "0000000000000000000000000000000000000000" ]; then
if git diff --name-only "$before" "$after" -- $PATHS | grep -q .; then
changed=true
fi
elif git rev-parse --verify HEAD~1 >/dev/null 2>&1; then
if git diff --name-only HEAD~1 HEAD -- $PATHS | grep -q .; then
changed=true
fi
else
# Нет родителя (первый коммит / тонкий clone) — линт OpenAPI выполняем один раз
changed=true
fi
fi
echo "changed=$changed" >> "$GITHUB_OUTPUT"
echo "OpenAPI lint will run: $changed"
openapi:
needs: [changes]
if: needs.changes.outputs.openapi == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
+1 -1
View File
@@ -21,8 +21,8 @@ func TestBirdScenarioPaths_Table(t *testing.T) {
"empty_static",
"filter_export",
"large_prefix_list",
"mixed_static_bgp",
"minimal",
"mixed_static_bgp",
"static_ipv4",
"with_include",
}