shiori/scripts/swagger_check.sh
Felipe Martin 9082f98f41
deps: upgrade to Go 1.21 (#698)
* go 1.21

* update dependencies

* Updated direct dependencies

* -count=1 to test flags

* group dependabot updates into one PR

* get swag version from go.mod

* show changes in swagger check

* go mod tidy

* updated swag generated files

* use go version from go.mod

* remove stray \

* proper grep
2023-09-16 08:20:55 +02:00

35 lines
1 KiB
Bash

#!/bin/bash
# This script is used to check if the swagger files are up to date.
# Check if swag version is correct
CURRENT_SWAG_VERSION=$(swag --version | cut -d " " -f 3)
if [ "$CURRENT_SWAG_VERSION" != "$REQUIRED_SWAG_VERSION" ]; then
echo "swag version is incorrect. Required version: $REQUIRED_SWAG_VERSION, current version: $CURRENT_SWAG_VERSION"
exit 1
fi
# Check if the git tree for CWD is clean
if [ -n "$(git status --porcelain)" ]; then
echo "❌ git tree is not clean. Please commit all changes before running this script."
git diff
exit 1
fi
# Check swag comments
make swag-fmt
if [ -n "$(git status --porcelain)" ]; then
echo "❌ swag comments are not formatted. Please run 'make swag-fmt' and commit the changes."
git diff
git reset --hard
exit 1
fi
# Check swagger documentation
make swagger
if [ -n "$(git status --porcelain)" ]; then
echo "❌ swagger documentation not updated, please run 'make swagger' and commit the changes."
git diff
git reset --hard
exit 1
fi