Skip to content

Commit

Permalink
chore(ci): add swagger docs gen to CI (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleGedd authored Aug 7, 2024
1 parent 08b96ad commit aed5b83
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .github/actions/setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ runs:
brew tap defenseunicorns/tap
brew install uds@0.14.0
- name: Install Swagger CLI
shell: bash
run: |
go install github.com/swaggo/swag/cmd/swag@latest
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0

Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/scan-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ jobs:
run: go install golang.org/x/tools/cmd/goimports@latest

- name: Install golangci-lint
run: uds run setup:golangci --no-progress
run: uds run setup:golangci

- name: Check Swagger Docs
run: uds run swagger:test

# build ui so ui/build exists when pre-commit runs
- name: build-ui
Expand All @@ -33,7 +36,7 @@ jobs:
extra_args: --all-files --verbose # pre-commit run --all-files --verbose

- name: Lint Yaml
run: uds run lint:yaml --no-progress
run: uds run lint:yaml

- name: Lint UI
run: uds run lint:ui --no-progress
run: uds run lint:ui
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
exclude: '^docs/swagger.*\.json$|^docs/swagger.*\.yaml$'

repos:
### Global ###
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
2 changes: 1 addition & 1 deletion docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2608,4 +2608,4 @@
}
}
}
}
}
1 change: 1 addition & 0 deletions tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ includes:
- lint: tasks/lint.yaml
- setup: tasks/setup.yaml
- build: tasks/build.yaml
- swagger: tasks/swagger.yaml

variables:
- name: REF
Expand Down
18 changes: 18 additions & 0 deletions tasks/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
tasks:
- name: generate
description: "Generate Swagger docs"
actions:
- cmd: swag init

- name: test
description: "Ensure no changes to Swagger docs"
actions:
- task: generate
- cmd: |
if [ -z "$(git status -s "docs")" ]; then
echo "Success!"
else
echo "Swagger docs changes found, please regenerate docs"
git status "docs"
exit 1
fi

0 comments on commit aed5b83

Please sign in to comment.