Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added updated check for docs in Makefile #291

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2024 The Archivista Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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'
jkjell marked this conversation as resolved.
Show resolved Hide resolved

- name: Install dependencies
run: go mod tidy

- name: Check and update Swagger docs
run: make docs
29 changes: 27 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,34 @@ lint: ## Run linter


.PHONY: docs
docs: ## Generate swagger docs
docs: check_docs # Generate swagger docs

.PHONY: check_docs
check_docs:
@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/swag@v1.16.2; \
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; \
rm -rf $$temp_dir

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



.PHONY: db-migrations
db-migrations: ## Run the migrations for the database
Expand All @@ -62,4 +87,4 @@ db-migrations: ## Run the migrations for the database


help: ## Show this help
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Loading