์ปจํธ๋ฆฌ๋ทฐํฐ๋ ์์ค์ฝ๋์ API ๊ด๋ จ ๋ด์ฉ(struct, comment ๋ฑ)์ ์์ ํ ๊ฒฝ์ฐ, make swag ์ ํตํด API ๋ฌธ์๋ฅผ ์๋ ์์ฑํ๊ณ ์์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ปจํธ๋ฆฌ๋ทฐํฐ๊ฐ PR์ ์ด์ด์ ํด๋น ํ์ผ์ ์
๋ฐ์ดํธํ๊ณ ์์ต๋๋ค. (https://github.com/cloud-barista/cb-tumblebug/wiki/API-Document-Update)
ํ์ฌ ์ด ๊ณผ์ (make swag ๋๋ swag init)์ ์ปจํธ๋ฆฌ๋ทฐํฐ๊ฐ ์ง์ ์ํํ๊ณ ์๋๋ฐ, ๋ค์ ๊ท์ฐฎ์ ์์
์
๋๋ค. (API ์์ ์ ๋ํ ๋ฆฌ๋ทฐ๊ฐ ์๋ฃ๋์๋ค๋ฉด, ๋ณดํต ์๋ ์์ฑ๋๋ ๋ฌธ์์ ๋ํด์ ๋ฐ๋ก ๋ฆฌ๋ทฐ๊ฐ ํ์ํ์ง๋ ์์ต๋๋ค.)
๋์ ์ฃผ์แฏ ๋ถแซ~?
[Pseudocode]
src/core/*/*.go ํ์ผ OR src/api/rest/server/*/*.go ํ์ผ์ ๋ณ๊ฒฝ์ด ๋ฐ์ํ ๊ฒฝ์ฐactions/checkout@v2)swag ์ค์น (go install ... ๋ก ์ค์นํ ์๋ ์์ง๋ง, ๋ง์ฝ go build๋ฅผ ์ํ ํ๊ฒฝ์ด ํ์ํ์ง ์๋ค๋ฉด, swag ๋ฐ์ด๋๋ฆฌ๋ฅผ ๋ฐ์์ ํ์ฉํ ์๋ ์์)src/ ์์ make swag ์คํdocs.go, swagger.json, swagger.yaml ํ์ผ ์
๋ฐ์ดํธ๊ฐ ํ์ํ์ง ์ฒดํฌํ๊ณ , ํ์ํ ๊ฒฝ์ฐ์๋ง PR์ ์ด๋๋ก ํ ์๋ ์์@computerphilosopher
Github workflow ๋ง๋ค์ด๋ณด์ ์ ์์ผ์ ๊ฐ์? ^^ (์์ ์ test workflow ์ ์ํด์ฃผ์
จ๋ ๊ฒ์ด ์๊ฐ๋ฌ์ต๋๋ค.)
ํน์ ๊ธฐ์ฌ๊ฐ ๊ฐ๋ฅํ์ค์ง ๋ฌธ์ ๋๋ฆฝ๋๋ค. ํธํ๊ฒ ์๋ต ์ฃผ์ธ์
@seokho-son
github workflow๋ ํด๋ณธ์ ์ด ์์ง๋ง Travis CI๋ ํ์ฌ์์ ์จ๋ณธ ๊ฒฝํ์ด ์์ต๋๋ค.
๊ธฐ๋ณธ ๊ตฌ์กฐ๋ ๋น์ทํ ํ ๋ ํ ๋ฒ ์๋ํด๋ณด๊ฒ ์ต๋๋ค.
@computerphilosopher
๊ฐ์ฌํฉ๋๋ค!! ๐
ํ์๋ฉด์ ์ด๋ ค์ด ๋ถ๋ถ์ด ์์ผ๋ฉด ์๋ ค์ฃผ์ธ์~! (์ฐธ๊ณ ๋ก ์์ฑํ workflow์ ํ ์คํธ๋ 1์ฐจ์ ์ผ๋ก๋ ๋ณธ์ธ์ forked repository์์ ๋๋ ค๋ณด์๋ฉด ๋ ๊ฒ ๊ฐ์ต๋๋ค. ๊ถํ ์ด์๋ก upstream์์ ๋ฐ๋ก ๊ตฌ๋์ํฌ ์๋ ์์ ๊ฑฐ์์.)
@jihoon-seo ๋~
ํน์ @computerphilosopher ๊ธฐ์ฌ์๊ป์ ์ฐธ๊ณ ํ์ค๋งํ reference๊ฐ ์์๊น์? ^^
๋๋ต ๊ธฐ์ต๋์๋ ๊ฒ์ด ์์ผ์๋ฉด ๊ณต์ ํด์ฃผ์ธ์~~
/assign @computerphilosopher
@hermitkim1 ๋~ ์ข์ ์ ๋ณด๊ฐ ์์ผ์๋ฉด ์ฌ๊ธฐ ๊ณต์ ํด์ฃผ์ธ์ ^^
(๋์ค์ @computerphilosopher ๊ป์ PR ์คํํ์๋ฉด, ๋ฆฌ๋ทฐ๋ ๋ถํ๋๋ ค๋ณด๊ฒ ์ต๋๋ค!! ใ
ใ
)
reference ๋ฑ์ ํ๋ฒ ์์ฑํด ๋ณด๊ฒ ์ต๋๋ค ๐
๋ฑ์ ์ฐธ๊ณ ํ์ฌ..
[์์] (ํ ์คํธ ํด ๋ณด์ง ์์์ต๋๋ค. ํ ์คํธ๊ฐ ํ์ํฉ๋๋ค ๐)
name: Open Swagger-doc-updating PR
on:
push:
branches:
- main
paths:
- 'src/core/**/**.go'
- 'src/api/rest/server/**/**.go'
jobs:
# The job key is "update-swagger-doc"
update-swagger-doc:
# Job name is "Update Swagger doc"
name: Update Swagger doc
# This job runs on Ubuntu-latest
runs-on: ubuntu-18.04
strategy:
matrix:
go-version: [ '1.17' ]
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout source code
uses: actions/[email protected]
- name: Install swag
run: |
go install github.com/swaggo/swag/cmd/swag@latest
- name: Update Swagger doc
run: |
cd src
make swag
- name: Create Pull Request
id: create-pull-request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.UPDATE_SWAGGER_DOC_PAT }}
commit-message: Update Swagger REST API doc
committer: cb-bot <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: update-swagger-doc
base: main
delete-branch: true
title: '[Workflow] Update Swagger REST API doc'
body: |
Update Swagger REST API doc
- Updated with *today's* date
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
labels: |
swagger
automated pr
assignees: cloud-barista/cb-tumblebug-maintainer
reviewers: cloud-barista/cb-tumblebug-maintainer
team-reviewers: |
owners
maintainers
draft: false
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.create-pull-request.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.create-pull-request.outputs.pull-request-url }}"
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Dump runner context
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}
run: echo "$RUNNER_CONTEXT"
- name: Dump strategy context
env:
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
run: echo "$STRATEGY_CONTEXT"
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJson(matrix) }}
run: echo "$MATRIX_CONTEXT"
@computerphilosopher
Forked repository์์ workflow๋ฅผ ํ ์คํธ ํด๋ณด์ค๋ ํ์ํ ๋ช๊ฐ์ง ์ ๋ณด(์ ๊ฐ ์ด์ ์ ์ฝ์ง ํ๋... ใ )๋ฅผ ๊ณต์ ๋๋ฆฝ๋๋ค.
PAT ์ค์ ์ ์ฒดํฌํด์ผํ๋ ํญ๋ชฉ์ด ์์๋๊ฒ ๊ฐ์๋ฐ์. ์ถํ์ ๊ณต์ ๋๋ฆฌ๊ฒ ์ต๋๋ค~
@computerphilosopher ๊ฐ์ฌํฉ๋๋ค!! ๐
ํ์๋ฉด์ ์ด๋ ค์ด ๋ถ๋ถ์ด ์์ผ๋ฉด ์๋ ค์ฃผ์ธ์~! (์ฐธ๊ณ ๋ก ์์ฑํ workflow์ ํ ์คํธ๋ 1์ฐจ์ ์ผ๋ก๋ ๋ณธ์ธ์ forked repository์์ ๋๋ ค๋ณด์๋ฉด ๋ ๊ฒ ๊ฐ์ต๋๋ค. ๊ถํ ์ด์๋ก upstream์์ ๋ฐ๋ก ๊ตฌ๋์ํฌ ์๋ ์์ ๊ฑฐ์์.)
@jihoon-seo ๋~ ํน์ @computerphilosopher ๊ธฐ์ฌ์๊ป์ ์ฐธ๊ณ ํ์ค๋งํ reference๊ฐ ์์๊น์? ^^ ๋๋ต ๊ธฐ์ต๋์๋ ๊ฒ์ด ์์ผ์๋ฉด ๊ณต์ ํด์ฃผ์ธ์~~
@jihoon-seo
ํ์ฌ ์ด์ ๊ฒํ ์ค์ ๋๋ค.
์ ์ํ์ ํ์ผ์์๋ make swag ๋ช ๋ น์ด ์ ์ฉ ํ ์๋์ผ๋ก Pull request๋ฅผ ์ฌ๋ ๊ฒ์ผ๋ก ๋ณด์ด๋๋ฐ, ์๋ํ๋ ๋ณ๊ฒฝ์ฌํญ์ด๋ผ PR๋ณด๋ค๋ ์ปค๋ฐ์ ๋ฐ๋ก ํ๋ ํธ์ด ๋ซ์ง ์์๊น์?
๋ค์์ ์์ action์ ๋๋ค.
@computerphilosopher
์ด๋ชจ์ง๋ก ์๋ ํ์ธ์ ๋ชปํ์
จ์ ์๋ ์์ผ๋.. ^^
์ ๋ ๋ฐ๋ก ์
์คํธ๋ฆผ์ ์ปค๋ฐํ๋ ๊ฒ ๋ณด๋ค๋
PR์ด ์คํ๋๋ฉด, ํน์๋ผ๋ ๋ชจ๋ฅผ ๋ฌธ์ (swagger api์ ์ค๋ฅ, ๋ค๋ฅธ PR๋ค๊ณผ ์ปค๋ฐ ์ถฉ๋ ๋ฑ๋ฑ)๋ฅผ ๊ฒํ ํ ์ ์์ด์,
PR์ผ๋ก ์ฌ๋ ๊ฒ์ ์ ํธํฉ๋๋ค.. ^^
API ๋ณ๊ฒฝ์ ์ํด์ ๋ฐ์ํ ๋ฌธ์ ๋ ํ ๋ฒ ํ์ธํ ๊ฒธ ๋ง์ด์ฃ .
ํ์ง๋ง, ๋ง์ํ์ ๊ฒ๊ณผ ๊ฐ์ด, PR์ ๊ด๋ฆฌํด์ผ ํ๋ ๋ถ๋ด๋ ์๊ธด ํ ๊ฒ ๊ฐ์ต๋๋ค. ํธ๋ ์ด๋์คํ๊ฐ ์๋ค์.
@jihoon-seo @hermitkim1 ๊ป์๋ ๋์ํ์๋ ๋ฏํ๋ ~~
์ ์ํด์ฃผ์ ๋ฐฉ๋ฒ์ผ๋ก ๊ธฐ์ฌ๋ฅผ ํด์ฃผ์๋ฉด ๋ ๊ฒ ๊ฐ์ต๋๋ค..!
Most helpful comment
@seokho-son
github workflow๋ ํด๋ณธ์ ์ด ์์ง๋ง Travis CI๋ ํ์ฌ์์ ์จ๋ณธ ๊ฒฝํ์ด ์์ต๋๋ค.
๊ธฐ๋ณธ ๊ตฌ์กฐ๋ ๋น์ทํ ํ ๋ ํ ๋ฒ ์๋ํด๋ณด๊ฒ ์ต๋๋ค.