diff --git a/.gitea/README.md b/.gitea/README.md index d7f725b..11fb8f0 100644 --- a/.gitea/README.md +++ b/.gitea/README.md @@ -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). diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 006cfae..102a106 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -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 diff --git a/internal/birdfmt/scenarios_test.go b/internal/birdfmt/scenarios_test.go index 162fbf8..daeda7a 100644 --- a/internal/birdfmt/scenarios_test.go +++ b/internal/birdfmt/scenarios_test.go @@ -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", }