Skip to content

Commit 1455898

Browse files
authored
Merge pull request #1221 from traPtitech/fix/openapi
openapiベースに変更(v3)
2 parents 6dce517 + c7b8fba commit 1455898

262 files changed

Lines changed: 16290 additions & 46502 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,59 +10,21 @@ updates:
1010
schedule:
1111
interval: weekly
1212
open-pull-requests-limit: 10
13-
ignore:
14-
- dependency-name: alpine
15-
versions:
16-
- 3.13.1
17-
- 3.13.2
18-
- 3.13.3
19-
- 3.13.4
20-
- dependency-name: golang
21-
versions:
22-
- 1.15.7.pre.alpine
23-
- 1.15.8.pre.alpine
24-
- 1.16.0.pre.alpine
25-
- 1.16.1.pre.alpine
26-
- 1.16.2.pre.alpine
2713
- package-ecosystem: docker
2814
directory: "/docker/dev"
2915
schedule:
3016
interval: weekly
3117
open-pull-requests-limit: 10
32-
ignore:
33-
- dependency-name: golang
34-
versions:
35-
- 1.15.7.pre.alpine
36-
- 1.15.8.pre.alpine
37-
- 1.16.0.pre.alpine
38-
- 1.16.1.pre.alpine
39-
- 1.16.2.pre.alpine
4018
- package-ecosystem: docker
41-
directory: "/docker/staging"
19+
directory: "/docker/neoshowcase"
4220
schedule:
4321
interval: weekly
4422
open-pull-requests-limit: 10
45-
ignore:
46-
- dependency-name: golang
47-
versions:
48-
- 1.15.7.pre.alpine
49-
- 1.15.8.pre.alpine
50-
- 1.16.0.pre.alpine
51-
- 1.16.1.pre.alpine
52-
- 1.16.2.pre.alpine
5323
- package-ecosystem: docker
54-
directory: "/docker/tuning"
24+
directory: "/docker/test"
5525
schedule:
5626
interval: weekly
5727
open-pull-requests-limit: 10
58-
ignore:
59-
- dependency-name: golang
60-
versions:
61-
- 1.15.7.pre.alpine
62-
- 1.15.8.pre.alpine
63-
- 1.16.0.pre.alpine
64-
- 1.16.1.pre.alpine
65-
- 1.16.2.pre.alpine
6628
- package-ecosystem: github-actions
6729
directory: "/"
6830
schedule:
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
jobs:
1313
image:
1414
name: Build Docker Image (master)
15-
runs-on: ubuntu-latest
15+
runs-on: ubuntu-24.04
1616
steps:
1717
- uses: actions/checkout@v4
1818
- name: Set up QEMU
@@ -26,7 +26,7 @@ jobs:
2626
username: traPtitech
2727
password: ${{ secrets.GITHUB_TOKEN }}
2828
- name: Build and push
29-
uses: docker/build-push-action@v5
29+
uses: docker/build-push-action@v6
3030
with:
3131
context: .
3232
push: true
@@ -37,7 +37,7 @@ jobs:
3737
cache-to: type=gha,mode=max
3838
deploy-staging:
3939
name: Deploy staging
40-
runs-on: ubuntu-latest
40+
runs-on: ubuntu-24.04
4141
needs: [image]
4242
steps:
4343
- name: Install SSH key

.github/workflows/main.yml

Lines changed: 100 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,109 +11,160 @@ env:
1111
TZ: Asia/Tokyo
1212

1313
jobs:
14+
generate:
15+
name: Generate files
16+
runs-on: ubuntu-24.04
17+
permissions:
18+
contents: write
19+
concurrency:
20+
group: auto-generate-${{ github.head_ref || github.ref_name }}
21+
cancel-in-progress: true
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
26+
- uses: actions/setup-go@v5
27+
with:
28+
go-version-file: 'go.mod'
29+
- run: go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@v2.5.1
30+
- run: go install github.com/google/wire/cmd/wire@v0.7.0
31+
- run: go generate ./openapi
32+
- run: go generate -run "wire" ./...
33+
- name: Auto-commit generated files
34+
if: github.event_name == 'pull_request' && github.actor != 'github-actions[bot]' && github.event.pull_request.head.repo.full_name == github.repository
35+
run: |
36+
git config user.name "github-actions[bot]"
37+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
38+
files=(openapi/server.go openapi/spec.go openapi/types.go wire_gen.go)
39+
if ! git diff --quiet -- "${files[@]}"; then
40+
git add "${files[@]}"
41+
git commit -m "chore: regenerate generated files"
42+
git push origin HEAD:${{ github.head_ref }}
43+
fi
44+
- name: Verify generated files are committed
45+
if: github.event_name != 'pull_request' || github.actor == 'github-actions[bot]' || github.event.pull_request.head.repo.full_name != github.repository
46+
run: |
47+
files=(openapi/server.go openapi/spec.go openapi/types.go wire_gen.go)
48+
if ! git diff --quiet -- "${files[@]}"; then
49+
echo "Generated files are out of date. Run generation locally and commit the results." >&2
50+
git diff -- "${files[@]}"
51+
exit 1
52+
fi
1453
mod:
1554
name: Mod
16-
runs-on: ubuntu-latest
55+
runs-on: ubuntu-24.04
56+
needs: [generate]
1757
steps:
1858
- uses: actions/checkout@v4
19-
- uses: actions/setup-go@v4
2059
with:
21-
go-version-file: 'go.mod'
22-
- uses: actions/cache@v3.3.2
60+
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
61+
- uses: actions/setup-go@v5
2362
with:
24-
path: ~/go/pkg/mod
25-
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}
63+
go-version-file: 'go.mod'
2664
- run: go mod download
2765
build:
2866
name: Build
29-
runs-on: ubuntu-latest
67+
runs-on: ubuntu-24.04
3068
needs: [mod]
31-
env:
32-
GOCACHE: "/tmp/go/cache"
3369
steps:
3470
- uses: actions/checkout@v4
35-
- uses: actions/setup-go@v4
71+
with:
72+
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
73+
- uses: actions/setup-go@v5
3674
with:
3775
go-version-file: 'go.mod'
38-
- uses: actions/cache@v3.3.2
39-
with:
40-
path: ~/go/pkg/mod
41-
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}
42-
restore-keys: |
43-
${{ runner.os }}-gomod-
44-
- uses: actions/cache@v3.3.2
45-
with:
46-
path: /tmp/go/cache
47-
key: ${{ runner.os }}-go-build-${{ github.ref }}-${{ github.sha }}
48-
restore-keys: |
49-
${{ runner.os }}-go-build-${{ github.ref }}-
50-
${{ runner.os }}-go-build-
5176
- run: go build -o anke-to
52-
- uses: actions/upload-artifact@v3
77+
- uses: actions/upload-artifact@v4
5378
with:
5479
name: anke-to
5580
path: anke-to
5681
test:
5782
name: Test
58-
runs-on: ubuntu-latest
83+
runs-on: ubuntu-24.04
5984
needs: [mod]
6085
services:
6186
mysql:
62-
image: mariadb:10.3.9
87+
image: mariadb:12.1.2
6388
ports:
6489
- 3306:3306
6590
env:
6691
MYSQL_ROOT_PASSWORD: password
6792
MYSQL_DATABASE: anke-to
6893
steps:
6994
- uses: actions/checkout@v4
70-
- uses: actions/setup-go@v4
95+
with:
96+
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
97+
- uses: actions/setup-go@v5
7198
with:
7299
go-version-file: 'go.mod'
73-
- uses: actions/cache@v3.3.2
74-
with:
75-
path: ~/go/pkg/mod
76-
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}
77-
restore-keys: |
78-
${{ runner.os }}-gomod-
79-
- run: go install github.com/golang/mock/mockgen@v1.5.0
80-
- run: go generate ./...
81-
- run: go test ./model ./router -v -coverprofile=coverage.txt -race -vet=off
100+
- run: go install go.uber.org/mock/mockgen@v0.6.0
101+
- run: go generate ./model ./traq
102+
- run: go test ./model -v -coverprofile=coverage-model.txt -race -vet=off
82103
env:
104+
ENV: test
105+
PORT: :1323
83106
MARIADB_USERNAME: root
84107
MARIADB_PASSWORD: password
85108
MARIADB_HOSTNAME: 127.0.0.1
86109
MARIADB_DATABASE: anke-to
110+
MARIADB_PORT: 3306
111+
TRAQ_BOT_TOKEN: ""
112+
TRAQ_WEBHOOK_ID: ""
113+
TRAQ_WEBHOOK_SECRET: ""
114+
- run: go test ./controller -v -coverprofile=coverage-controller.txt -race -vet=off
115+
env:
116+
ENV: test
117+
PORT: :1323
118+
MARIADB_USERNAME: root
119+
MARIADB_PASSWORD: password
120+
MARIADB_HOSTNAME: 127.0.0.1
121+
MARIADB_DATABASE: anke-to
122+
MARIADB_PORT: 3306
123+
TRAQ_BOT_TOKEN: ""
124+
TRAQ_WEBHOOK_ID: ""
125+
TRAQ_WEBHOOK_SECRET: ""
87126
- name: Upload coverage data
88-
uses: codecov/codecov-action@v3.1.4
127+
uses: codecov/codecov-action@v5
128+
with:
129+
files: ./coverage-model.txt ./coverage-controller.txt
130+
token: ${{ secrets.CODECOV_TOKEN }}
131+
- uses: actions/upload-artifact@v4
89132
with:
90-
file: ./coverage.txt
91-
yml: ./codecov.yml
92-
- uses: actions/upload-artifact@v3
133+
name: coverage-model.txt
134+
path: coverage-model.txt
135+
- uses: actions/upload-artifact@v4
93136
with:
94-
name: coverage.txt
95-
path: coverage.txt
137+
name: coverage-controller.txt
138+
path: coverage-controller.txt
96139
lint:
97140
name: Lint
98-
runs-on: ubuntu-latest
141+
runs-on: ubuntu-24.04
142+
needs: [mod]
99143
steps:
100144
- uses: actions/checkout@v4
101-
- uses: actions/setup-go@v4
145+
with:
146+
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
147+
- uses: actions/setup-go@v5
102148
with:
103149
go-version-file: 'go.mod'
150+
- run: go install go.uber.org/mock/mockgen@v0.6.0
151+
- run: go generate ./model ./traq
104152
- name: golangci-lint
105-
uses: reviewdog/action-golangci-lint@v2.3
153+
uses: reviewdog/action-golangci-lint@v2
106154
with:
107155
reporter: github-pr-check
108156
github_token: ${{ secrets.GITHUB_TOKEN }}
109-
fail_on_error: true
157+
fail_level: error
158+
cache: false
110159
spectral:
111160
name: Spectral
112-
runs-on: ubuntu-latest
161+
runs-on: ubuntu-24.04
162+
needs: [mod]
113163
steps:
114164
- uses: actions/checkout@v4
165+
with:
166+
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
115167
- name: Spectral checks
116-
uses: stoplightio/spectral-action@v0.8.7
168+
uses: stoplightio/spectral-action@v0.8.13
117169
with:
118170
file_glob: docs/swagger/*.yaml
119-
repo_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ env:
1111
jobs:
1212
image:
1313
name: Build Docker Image
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-24.04
1515
steps:
1616
- uses: actions/checkout@v4
1717
- name: Set up QEMU
@@ -25,7 +25,7 @@ jobs:
2525
username: traPtitech
2626
password: ${{ secrets.GITHUB_TOKEN }}
2727
- name: Build and push
28-
uses: docker/build-push-action@v5
28+
uses: docker/build-push-action@v6
2929
with:
3030
context: .
3131
push: true

.golangci.yml

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
1-
run:
2-
skip-dirs:
3-
- tuning/openapi
4-
1+
version: "2"
52
linters:
63
enable:
7-
- govet
8-
- errcheck
9-
- staticcheck
10-
- unused
11-
- gosimple
12-
- structcheck
13-
- varcheck
14-
- ineffassign
15-
- deadcode
16-
- typecheck
174
- revive
5+
exclusions:
6+
generated: lax
7+
presets:
8+
- comments
9+
- common-false-positives
10+
- legacy
11+
- std-error-handling
12+
paths:
13+
- third_party$
14+
- builtin$
15+
- examples$
16+
- tuning/openapi
17+
- model/mock_model
18+
settings:
19+
staticcheck:
20+
checks:
21+
- all
22+
- -QF1008 # ignore embedded field check
23+
formatters:
24+
enable:
1825
- gofmt
26+
exclusions:
27+
generated: lax
28+
paths:
29+
- third_party$
30+
- builtin$
31+
- examples$
32+
- tuning/openapi
33+
- model/mock_model

.spectral.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extends: ["spectral:oas"]

0 commit comments

Comments
 (0)