diff --git a/.claude/settings.json b/.claude/settings.json new file mode 120000 index 0000000..0915a23 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1 @@ +../way/settings/backend/settings.json \ No newline at end of file diff --git a/.claude/skills b/.claude/skills new file mode 120000 index 0000000..e839045 --- /dev/null +++ b/.claude/skills @@ -0,0 +1 @@ +../way/skills/backend \ No newline at end of file diff --git a/.codex/AGENTS.md b/.codex/AGENTS.md new file mode 120000 index 0000000..5ac27ca --- /dev/null +++ b/.codex/AGENTS.md @@ -0,0 +1 @@ +../way/instructing/backend/AGENTS.md \ No newline at end of file diff --git a/.codex/config.toml b/.codex/config.toml new file mode 120000 index 0000000..36ade79 --- /dev/null +++ b/.codex/config.toml @@ -0,0 +1 @@ +../way/settings/backend/config.toml \ No newline at end of file diff --git a/.codex/skills b/.codex/skills new file mode 120000 index 0000000..e839045 --- /dev/null +++ b/.codex/skills @@ -0,0 +1 @@ +../way/skills/backend \ No newline at end of file diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index a0d98cc..0000000 --- a/.dockerignore +++ /dev/null @@ -1,13 +0,0 @@ -.claude/ -.git/ -.github/ -.serena/ - -.dockerignore -.env* -.gitignore -.mcp.json -CLAUDE.md -Dockerfile -mise.toml -Taskfile.yaml diff --git a/.dockerignore b/.dockerignore new file mode 120000 index 0000000..c20213b --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +./way/packaging/backend/.dockerignore \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index d553a78..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: CI -on: - push: - branches: - - main - pull_request: - branches: - - main - types: - - opened - - ready_for_review - - reopened - - synchronize - workflow_dispatch: -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true -jobs: - test: - if: github.event.pull_request.draft == false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - uses: jdx/mise-action@v3 - - name: Test - run: task test diff --git a/.github/workflows/cd.yaml b/.github/workflows/deploy.yml similarity index 55% rename from .github/workflows/cd.yaml rename to .github/workflows/deploy.yml index 8da818e..66c59d5 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: CD +name: Deploy on: push: branches: @@ -15,7 +15,7 @@ on: - qa - prod concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.inputs.environment_name }} + group: ${{ github.repository }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.event.inputs.environment_name }} cancel-in-progress: true jobs: set-env: @@ -26,40 +26,11 @@ jobs: image_tag: ${{ steps.set-env.outputs.image_tag }} steps: - uses: actions/checkout@v6 - - name: Set Environmet - id: set-env - run: | - # Environment - IS_WORKFLOW_DISPATCH="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment_name != '' }}" - IS_PUSH_TO_MAIN="${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.base_ref == 'main') }}" - if [ $IS_WORKFLOW_DISPATCH = "true" ]; then - export TARGET_ENVIRONMENT="${{ github.event.inputs.environment_name }}" - elif [ $IS_PUSH_TO_MAIN = "true" ]; then - export TARGET_ENVIRONMENT="stg" - else - exit 1 - fi - - echo "Environment: $TARGET_ENVIRONMENT" - - # Service name suffix - if [ "$TARGET_ENVIRONMENT" = "prod" ]; then - export SERVICE_NAME_SUFFIX="" - else - export SERVICE_NAME_SUFFIX="-$TARGET_ENVIRONMENT" - fi - - export REPO_NAME=$(echo ${{ github.repository }} | awk -F '/' '{print $2}') - export SERVICE_NAME=$REPO_NAME$SERVICE_NAME_SUFFIX - export IMAGE_TAG=${{ vars._AR_HOSTNAME }}/${{ vars.PROJECT_ID }}/github-actions/$REPO_NAME/$SERVICE_NAME:${{ github.sha }} - - echo "Repository name: $REPO_NAME" - echo "Service name: $SERVICE_NAME" - echo "Image tag: $IMAGE_TAG" - - echo "environment=$TARGET_ENVIRONMENT" >> "$GITHUB_OUTPUT" - echo "service_name=$SERVICE_NAME" >> "$GITHUB_OUTPUT" - echo "image_tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT" + - id: set-env + uses: fun-dotto/way/.github/actions/set-env@main + with: + ar_hostname: ${{ vars._AR_HOSTNAME }} + project_id: ${{ vars.PROJECT_ID }} build-and-push: runs-on: ubuntu-latest permissions: @@ -72,6 +43,9 @@ jobs: - set-env steps: - uses: actions/checkout@v6 + with: + fetch-depth: 0 + submodules: true - name: Build run: | docker build \ @@ -79,14 +53,11 @@ jobs: . \ -f Dockerfile \ --no-cache - - name: Authenticate - id: auth - uses: google-github-actions/auth@v2 + - uses: google-github-actions/auth@v3 with: workload_identity_provider: ${{ vars.WORKLOAD_IDENTITY_PROVIDER }} service_account: ${{ vars.SERVICE_ACCOUNT }} - - name: Setup Google Cloud - uses: google-github-actions/setup-gcloud@v2 + - uses: google-github-actions/setup-gcloud@v3 with: project_id: ${{ vars.PROJECT_ID }} - name: Configure Docker @@ -110,15 +81,11 @@ jobs: - set-env - build-and-push steps: - - name: Authenticate - id: auth - uses: google-github-actions/auth@v2 + - uses: google-github-actions/auth@v3 with: workload_identity_provider: ${{ vars.WORKLOAD_IDENTITY_PROVIDER }} service_account: ${{ vars.SERVICE_ACCOUNT }} - - name: Deploy - id: deploy - uses: google-github-actions/deploy-cloudrun@v2 + - uses: google-github-actions/deploy-cloudrun@v3 with: service: ${{ env.SERVICE_NAME }} image: ${{ env.IMAGE_TAG }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e324330 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,20 @@ +name: Test +on: + push: + branches: + - main + pull_request: + branches: + - main + types: + - opened + - ready_for_review + - reopened + - synchronize + workflow_dispatch: +jobs: + test: + uses: fun-dotto/way/.github/workflows/backend-test.yml@main + permissions: + contents: read + secrets: inherit diff --git a/.github/workflows/update-submodules.yml b/.github/workflows/update-submodules.yml new file mode 100644 index 0000000..1608c62 --- /dev/null +++ b/.github/workflows/update-submodules.yml @@ -0,0 +1,11 @@ +name: Update Submodules +on: + schedule: + - cron: "0 15 * * *" + workflow_dispatch: +jobs: + update-submodules: + uses: fun-dotto/way/.github/workflows/update-submodules.yml@main + permissions: + contents: write + pull-requests: write diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..1fe8a39 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "way"] + path = way + url = git@github.com:fun-dotto/way.git diff --git a/.mcp.json b/.mcp.json deleted file mode 100644 index b874e8f..0000000 --- a/.mcp.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "mcpServers": { - "notion": { - "url": "https://mcp.notion.com/mcp", - "type": "http" - }, - "serena": { - "command": "uvx", - "args": [ - "--from", - "git+https://github.com/oraios/serena.git", - "serena-mcp-server" - ] - } - } -} diff --git a/.mcp.json b/.mcp.json new file mode 120000 index 0000000..f62d0e2 --- /dev/null +++ b/.mcp.json @@ -0,0 +1 @@ +./way/settings/backend/.mcp.json \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index f6a2933..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,24 +0,0 @@ -# CLAUDE.md - -このファイルは、Claude Code (claude.ai/code) がこのリポジトリで作業する際のガイダンスを提供します。 - -## ドキュメント - -Notion MCP を使用して Notion を参照 - -## 開発コマンド - -[`Taskfile.yml`](Taskfile.yml) を参照 - -## アーキテクチャ - -Clean Architecture を採用 - -## ルール - -- DRY 原則を遵守する -- SOLID 原則を遵守する -- 機能を新規に実装する・リファクタリングする場合は、[アーキテクチャパターン](https://www.notion.so/fun-dotto/30428560ac7980d5a870e9dc9f5695bd?source=copy_link)に則って実装する -- [ブランチの運用ルール](https://www.notion.so/fun-dotto/Branch-30428560ac79801a9429dd67cf30b7f9?source=copy_link)に従う -- [コミットルール](https://www.notion.so/fun-dotto/Commit-30428560ac798065bb4ecd14baab9e2e?source=copy_link)に従う -- [Pull Request の運用ルール](https://www.notion.so/fun-dotto/Pull-Request-30428560ac7980e98efce3c11d36ebb5?source=copy_link)に従う diff --git a/CLAUDE.md b/CLAUDE.md new file mode 120000 index 0000000..a7a1e83 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +./way/instructing/backend/CLAUDE.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 2363efb..0000000 --- a/Dockerfile +++ /dev/null @@ -1,53 +0,0 @@ -# Build stage -FROM golang:1.25.6-alpine AS builder - -# Install build dependencies -RUN apk add --no-cache git - -# Set working directory -WORKDIR /app - -# Copy go mod files -COPY go.mod go.sum ./ - -# Download dependencies -RUN go mod download - -# Copy source code -COPY . . - -# Build the application -RUN CGO_ENABLED=0 GOOS=linux go build -tags timetzdata -o ./bin/main ./cmd/server/main.go - -# Runtime stage -FROM alpine:3 - -ENV PORT=8080 - -# Install runtime dependencies -RUN apk add --no-cache ca-certificates - -# Create non-root user -RUN addgroup -g 1000 appuser && \ - adduser -D -u 1000 -G appuser appuser - -# Set working directory -WORKDIR /app - -# Copy binary from builder -COPY --from=builder /app/bin/main /app/main - -# Copy OpenAPI spec -COPY --from=builder /app/openapi /app/openapi - -# Change ownership -RUN chown -R appuser:appuser /app - -# Switch to non-root user -USER appuser - -# Expose port -EXPOSE $PORT - -# Run the application -CMD ["/app/main"] diff --git a/Dockerfile b/Dockerfile new file mode 120000 index 0000000..ebdd815 --- /dev/null +++ b/Dockerfile @@ -0,0 +1 @@ +./way/packaging/backend/Dockerfile \ No newline at end of file diff --git a/Taskfile.yaml b/Taskfile.yaml deleted file mode 100644 index c5190c9..0000000 --- a/Taskfile.yaml +++ /dev/null @@ -1,56 +0,0 @@ -version: "3" - -vars: - GO: go - -tasks: - install: - desc: Install dependencies - cmds: - - "{{.GO}} mod tidy" - - generate: - desc: Generate API code from OpenAPI spec - cmds: - - rm -rf ./generated - - mkdir -p ./generated - - "{{.GO}} tool oapi-codegen -config ./openapi/config.yaml ./openapi/openapi.yaml" - - "{{.GO}} tool oapi-codegen -config ./openapi/external/academic_api/config.yaml ./openapi/external/academic_api/openapi.yaml" - - "{{.GO}} tool oapi-codegen -config ./openapi/external/announcement_api/config.yaml ./openapi/external/announcement_api/openapi.yaml" - - "{{.GO}} tool oapi-codegen -config ./openapi/external/funch_api/config.yaml ./openapi/external/funch_api/openapi.yaml" - - "{{.GO}} tool oapi-codegen -config ./openapi/external/user_api/config.yaml ./openapi/external/user_api/openapi.yaml" - - clean: - desc: Clean build artifacts - cmds: - - rm -rf ./bin - - build: - desc: Build the application - deps: - - clean - cmds: - - mkdir -p ./bin - - "{{.GO}} build -tags timetzdata -o ./bin/main ./cmd/server/main.go" - - run: - desc: Run the application - cmds: - - "{{.GO}} run ./cmd/server/main.go" - - build-and-run: - desc: Build and run the application - deps: - - build - cmds: - - ./bin/main - - test: - desc: Run tests - cmds: - - "{{.GO}} test -v ./..." - - default: - desc: Show available tasks - cmds: - - task --list diff --git a/Taskfile.yml b/Taskfile.yml new file mode 120000 index 0000000..71ba9b7 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1 @@ +./way/tooling/backend/Taskfile.yml \ No newline at end of file diff --git a/mise.toml b/mise.toml deleted file mode 100644 index 5086832..0000000 --- a/mise.toml +++ /dev/null @@ -1,3 +0,0 @@ -[tools] -"aqua:go-task/task" = "latest" -go = "1.25.6" diff --git a/mise.toml b/mise.toml new file mode 120000 index 0000000..f20b12d --- /dev/null +++ b/mise.toml @@ -0,0 +1 @@ +./way/tooling/backend/mise.toml \ No newline at end of file diff --git a/way b/way new file mode 160000 index 0000000..2836537 --- /dev/null +++ b/way @@ -0,0 +1 @@ +Subproject commit 28365378a640746fd364103f28b687ee6b2ffab9