Skip to content

Commit

Permalink
docs: Add http/openapi documentation & ci workflow (#2678)
Browse files Browse the repository at this point in the history
## Relevant issue(s)
Related #510 
Resolve #2677

## Description
- Detect OpenAPI / HTTP documentation is always up to date.
- Generate open-api docs in the appropriate dir.

## How has this been tested?
- using `act` tool
- manually introducing a change and seeing the action fail:
https://github.com/sourcenetwork/defradb/actions/runs/9359749777/job/25763961265?pr=2678

Specify the platform(s) on which this was tested:
- WSL2 instance
  • Loading branch information
shahzadlone authored Jun 4, 2024
1 parent 1eb1fb5 commit 7dc07e7
Show file tree
Hide file tree
Showing 4 changed files with 2,151 additions and 9 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/check-cli-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ jobs:
- name: Checkout code into the directory
uses: actions/checkout@v3

# This check is there as a safety to ensure we start clean (without any changes).
# If there are ever changes here, the rest of the job will output false result.
- name: Check no changes exist initially
uses: tj-actions/verify-changed-files@v20
with:
fail-if-changed: true
files: |
docs/website/references/cli
- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/check-http-documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2024 Democratized Data Foundation
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.

# This workflow checks that all HTTP documentation is up to date.
# If the documentation is not up to date then this action will fail.
name: Check HTTP Documentation Workflow

on:
pull_request:
branches:
- master
- develop

push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
branches:
- master
- develop

jobs:
check-http-documentation:
name: Check http documentation job

runs-on: ubuntu-latest

steps:
- name: Checkout code into the directory
uses: actions/checkout@v3

- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.21"
check-latest: true

- name: Try generating http documentation
run: make docs:http

- name: Check no new changes exist
uses: tj-actions/verify-changed-files@v20
with:
fail-if-changed: true
files: |
docs/website/references/http
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,17 @@ chglog:
docs:
@$(MAKE) docs\:cli
@$(MAKE) docs\:manpages
@$(MAKE) docs\:http

.PHONY: docs\:cli
docs\:cli:
rm -f docs/website/references/cli/*.md
go run cmd/genclidocs/main.go -o docs/website/references/cli

.PHONY: docs\:http
docs\:http:
go run cmd/genopenapi/main.go | python -m json.tool > docs/website/references/http/openapi.json

.PHONY: docs\:manpages
docs\:manpages:
go run cmd/genmanpages/main.go -o build/man/
Expand Down
Loading

0 comments on commit 7dc07e7

Please sign in to comment.