Skip to content

Commit

Permalink
added the changes and github workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Dariksha <[email protected]>
  • Loading branch information
DarikshaAnsari authored and jkjell committed Jun 6, 2024
1 parent 32b77a4 commit f7e3cc3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.16'

- name: Install dependencies
run: go mod tidy

- name: Check and update Swagger docs
run: make docs
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,29 @@ docs: check_docs # Generate swagger docs

.PHONY: check_docs
check_docs:
@server_mod_time=$$(stat -c %Y internal/server/server.go); \
swagger_mod_time=$$(stat -c %Y docs/swagger.json); \
if [ $$server_mod_time -gt $$swagger_mod_time ]; then \
@echo "Checking if Swagger documentation needs to be updated..."
@temp_dir=$$(mktemp -d); \
mkdir -p $$temp_dir/docs; \
go install github.com/swaggo/swag/cmd/[email protected]; \
swag init -o $$temp_dir/docs -d internal/server -g server.go -pd > /dev/null 2>&1; \
if [ ! -f docs/swagger.json ]; then \
echo "Swagger documentation needs to be generated"; \
make update_docs; \
elif ! diff -q $$temp_dir/docs/swagger.json docs/swagger.json > /dev/null; then \
echo "Swagger documentation needs to be updated"; \
make update_docs; \
else \
echo "Swagger documentation is up to date"; \
fi
fi; \
rm -rf $$temp_dir

.PHONY: update_docs
update_docs:
@echo "Updating Swagger documentation..."
@go install github.com/swaggo/swag/cmd/[email protected]
@swag init -o docs -d internal/server -g server.go -pd
@echo "Swagger documentation updated"



.PHONY: db-migrations
Expand Down

0 comments on commit f7e3cc3

Please sign in to comment.