Skip to content

Commit fad1f9d

Browse files
Merge pull request #129 from su-its/release/v0.0.1
Release/v0.0.1
2 parents 0406449 + 399b9ec commit fad1f9d

File tree

217 files changed

+21350
-0
lines changed

Some content is hidden

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

217 files changed

+21350
-0
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## チケットへのリンク
2+
3+
- https://github.com/orgs/su-its/projects/example-hogehoge-fugafuga
4+
5+
## やったこと
6+
7+
- このプルリクで何をしたのか?
8+
9+
## やらないこと
10+
11+
- このプルリクでやらないことは何か?(あれば。無いなら「無し」で OK)(やらない場合は、いつやるのかを明記する。)
12+
13+
## できるようになること(ユーザ目線)
14+
15+
- 何ができるようになるのか?(あれば。無いなら「無し」で OK)
16+
17+
## できなくなること(ユーザ目線)
18+
19+
- 何ができなくなるのか?(あれば。無いなら「無し」で OK)
20+
21+
## 動作確認
22+
23+
- どのような動作確認を行ったのか? 結果はどうか?
24+
25+
## その他
26+
27+
- レビュワーへの参考情報(実装上の懸念点や注意点などあれば記載)

.github/workflows/build-app.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: build-app
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
- main
8+
paths:
9+
- .github/workflows/build-app.yml
10+
- "typing-app/**"
11+
- "!typing-app/docs/**"
12+
- "!typing-app/README.md"
13+
workflow_dispatch:
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
defaults:
20+
run:
21+
working-directory: typing-app
22+
23+
jobs:
24+
build:
25+
name: Build
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
# Corepack enable をしておけば package.json の packageManager を読んで適切なバージョンの yarn を使ってくれる。
33+
# ただし非公式な方法であり、あくまでワークアラウンド。
34+
# https://github.com/actions/setup-node/issues/480#issuecomment-1820622085
35+
# > enable corepack **before** setup-node.
36+
- name: Enable Corepack
37+
run: corepack enable
38+
39+
- uses: actions/setup-node@v4
40+
with:
41+
node-version: "20"
42+
43+
- name: Get yarn cache folder
44+
id: get-yarn-cache-folder
45+
shell: bash
46+
# will fail if yarn version is 1
47+
run: echo "folder=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
48+
49+
- uses: actions/cache@v4
50+
with:
51+
path: |
52+
${{ steps.get-yarn-cache-folder.outputs.folder }}
53+
./typing-app/.next
54+
key: yarn-cache-${{ runner.os }}-${{ hashFiles('typing-app/yarn.lock') }}
55+
restore-keys: |
56+
yarn-cache-${{ runner.os }}-${{ hashFiles('typing-app/yarn.lock') }}
57+
yarn-cache-${{ runner.os }}-
58+
59+
- name: Install Dependencies
60+
run: yarn
61+
62+
- name: Check Code Style (Prettier)
63+
run: yarn run format:ci
64+
65+
- name: Build Next.js Project
66+
run: yarn build
67+
test:
68+
name: Test
69+
runs-on: ubuntu-latest
70+
permissions:
71+
contents: read
72+
steps:
73+
- uses: actions/checkout@v4
74+
75+
- name: Enable Corepack
76+
run: corepack enable
77+
78+
- uses: actions/setup-node@v4
79+
with:
80+
node-version: "20"
81+
82+
- name: Get yarn cache folder
83+
id: get-yarn-cache-folder
84+
shell: bash
85+
# will fail if yarn version is 1
86+
run: echo "folder=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
87+
88+
- uses: actions/cache@v4
89+
with:
90+
path: |
91+
${{ steps.get-yarn-cache-folder.outputs.folder }}
92+
./typing-app/.next
93+
key: yarn-cache-${{ runner.os }}-${{ hashFiles('typing-app/yarn.lock') }}
94+
restore-keys: |
95+
yarn-cache-${{ runner.os }}-${{ hashFiles('typing-app/yarn.lock') }}
96+
yarn-cache-${{ runner.os }}-
97+
98+
- name: Install Dependencies
99+
run: yarn
100+
101+
- name: Run Tests
102+
run: yarn test

.github/workflows/build-image.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build / Push Docker Image to Registry
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
12+
jobs:
13+
image:
14+
name: Build / Push
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
- name: Log in to the Container registry
23+
uses: docker/login-action@v3
24+
with:
25+
registry: ghcr.io
26+
username: su-its
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
# FIXME: できることなら NEXT_PUBLIC_ は使いたくない
29+
- name: Prepare environment variable file
30+
working-directory: typing-app
31+
run: echo 'NEXT_PUBLIC_API_URL=${{ secrets.PROD_NEXT_PUBLIC_API_URL }}' >> .env.production
32+
- name: Docker Buildx Bake
33+
uses: docker/bake-action@v4
34+
with:
35+
workdir: docker
36+
files: compose.ci.yaml
37+
push: true

.github/workflows/deploy-oapi-doc.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Generate / Deploy API docs
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
paths:
8+
- typing-server/openapi.yaml
9+
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
concurrency:
16+
group: "pages"
17+
cancel-in-progress: false
18+
19+
jobs:
20+
build:
21+
name: Build Static HTML
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
- name: Setup Pages
27+
uses: actions/configure-pages@v4
28+
- name: Generate OpenAPI Document as HTML
29+
run: npx @redocly/cli build-docs ./typing-server/openapi.yaml --output=./_site/index.html
30+
- name: Upload artifact
31+
uses: actions/upload-pages-artifact@v3
32+
deploy:
33+
name: Deploy
34+
environment:
35+
name: github-pages
36+
url: ${{ steps.deployment.outputs.page_url }}
37+
runs-on: ubuntu-latest
38+
needs: build
39+
steps:
40+
- name: Deploy to GitHub Pages
41+
id: deployment
42+
uses: actions/deploy-pages@v4

.github/workflows/deploy.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deploy Containers
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_dispatch:
8+
9+
jobs:
10+
deploy:
11+
name: Deploy
12+
runs-on: self-hosted
13+
env:
14+
# COMPOSE_PROJECT_NAME を指定しないと docker_app_1 のような
15+
# 分かりづらい名前のコンテナが作成される.
16+
# -p オプションをつければ同じことができる.
17+
# -p はコマンドの直後に置くこと. podman-compose -p typing up
18+
# SSHで直接実行する際にも忘れず指定すること.
19+
COMPOSE_PROJECT_NAME: typing
20+
defaults:
21+
run:
22+
shell: bash
23+
working-directory: docker
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: podman-compose pull
29+
run: podman-compose -f compose.yaml pull
30+
31+
- name: Down and Up (app)
32+
run: |
33+
podman-compose -f compose.yaml down app
34+
podman-compose -f compose.yaml up -d app
35+
36+
- name: Down and Up (api)
37+
run: |
38+
podman-compose -f compose.yaml down api
39+
podman-compose -f compose.yaml up -d api
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Generate TypeScript Type Definitions from OpenAPI
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- typing-server/openapi.yaml
7+
8+
jobs:
9+
generate-client:
10+
name: Generate TypeScript Type Definitions
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Enable Corepack
17+
run: corepack enable
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: "20"
21+
cache: "yarn"
22+
cache-dependency-path: typing-app/yarn.lock
23+
- name: Install Dependencies
24+
working-directory: typing-app
25+
run: yarn
26+
- name: Retrieve the Schema version
27+
uses: mikefarah/yq@master
28+
id: get_schema_version
29+
with:
30+
cmd: 'yq ".info.version" ./typing-server/openapi.yaml'
31+
- name: Generate
32+
shell: bash
33+
working-directory: typing-app
34+
# ${SCHEMA_VERSION%%.*} removes the longest substring starting with a period from $SCHEMA_VERSION
35+
run: |
36+
SCHEMA_VERSION=${{ steps.get_schema_version.outputs.result }}
37+
SCHEMA_MAJOR_VERSION=${SCHEMA_VERSION%%.*}
38+
npx openapi-typescript ../typing-server/openapi.yaml --output ./src/libs/api/v${SCHEMA_MAJOR_VERSION}.d.ts
39+
# TODO: エラーになるので tsc は一旦やめる
40+
# Error: src/components/atoms/Banner.tsx(3,25): error TS2307: Cannot find module '@/assets/images/banner.png' or its corresponding type declarations.
41+
# - name: Validate
42+
# working-directory: typing-app
43+
# run: yarn exec tsc --noEmit
44+
- name: Commit
45+
uses: stefanzweifel/git-auto-commit-action@v5
46+
with:
47+
commit_message: generate TS code from api schema
48+
# Do not run on local (see. https://nektosact.com/usage/index.html)
49+
if: ${{ !env.ACT }}

.github/workflows/golangci-lint.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: golangci-lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
paths:
9+
- "typing-server/**"
10+
pull_request:
11+
branches:
12+
- main
13+
- develop
14+
paths:
15+
- "typing-server/**"
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
golangci:
22+
name: lint
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: actions/setup-go@v5
27+
with:
28+
go-version: "1.22.0"
29+
- name: golangci-lint
30+
uses: golangci/golangci-lint-action@v4
31+
with:
32+
version: v1.54
33+
working-directory: typing-server # Set this to the directory where your Go code is located

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @KinjiKawaguchi @h-takeyeah

docker/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# docker ディレクトリ
2+
3+
- **compose.ci.yaml** Docker イメージをビルドするためのレシピ
4+
- **compose.yaml** デプロイ先のサーバで実際にサービスを起動するための構成を記述したファイル
5+
6+
手元でやるときはこのディレクトリで以下のようにすると本番サーバの様子をそこそこ再現できます。
7+
```bash
8+
docker compose build -f compose.ci.yaml
9+
docker compose -f compose.yaml up -d
10+
# docker compose -f compose.yaml logs -f # ログを tail
11+
```

docker/compose.ci.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
services:
2+
app:
3+
image: ghcr.io/su-its/typing-app:dev
4+
build:
5+
context: ../typing-app
6+
cache_from:
7+
- node:20.11-slim
8+
api:
9+
image: ghcr.io/su-its/typing-server:dev
10+
build:
11+
context: ../typing-server
12+
cache_from:
13+
- golang:1.22.0
14+
- alpine:latest

0 commit comments

Comments
 (0)