Skip to content

GameCreator関係のAPIとDBスキーマ定義 #2471

GameCreator関係のAPIとDBスキーマ定義

GameCreator関係のAPIとDBスキーマ定義 #2471

Workflow file for this run

name: CI
on:
push:
branches:
- "main"
pull_request:
permissions:
contents: read
pull-requests: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: go.mod
- run: go build -o collection
test:
name: Test
runs-on: ubuntu-latest
needs: build
if: ${{ always() }}
services:
dind:
image: docker:23.0-rc-dind-rootless
ports:
- 2375:2375
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: go.mod
- name: Setup Atlas
uses: ariga/setup-atlas@4240bd74ba9f13319a21de2b6e497f2b6d184d76 # v0
- run: go generate ./...
- run: mkdir -p /tmp/coverage
- name: Run test
run: go test ./src/... -v -coverprofile=/tmp/coverage/coverage.txt -race -vet=off
- name: Upload coverage data
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
with:
files: /tmp/coverage/coverage.txt
token: ${{ secrets.CODECOV_TOKEN }}
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: coverage.txt
path: /tmp/coverage/coverage.txt
lint:
name: Lint
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
# go generate用に、golangci-lintの前にGoのinstallをする
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: go.mod
- run: go generate ./...
- name: golangci-lint
uses: reviewdog/action-golangci-lint@f9bba13753278f6a73b27a56a3ffb1bfda90ed71 # v2.8.0
with:
go_version_file: go.mod
reporter: ${{ github.event_name == 'pull_request' && 'github-pr-review' || 'github-check' }}
github_token: ${{ secrets.GITHUB_TOKEN }}
fail_level: any
migrate-lint:
name: Migrate Lint
runs-on: ubuntu-latest
# botによるPRのときは実行しない
if: "${{ github.event.sender.type != 'Bot' }}"
services:
db:
image: mariadb:10
env:
MYSQL_ROOT_PASSWORD: pass
MYSQL_DATABASE: trap_collection
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
fetch-depth: 0
- name: Setup Atlas community edition
run: |
curl -sSf https://atlasgo.sh | sh -s -- --community --yes
shell: bash
- name: Atlas Lint
run: |
set +e
LINT_OUTPUT="$(atlas migrate lint --config file://atlas.ci.hcl --env ci 2>&1)"
LINT_EXIT_CODE=$?
if [ "$LINT_EXIT_CODE" -eq 0 ]; then
STATUS_ICON="✅"
else
STATUS_ICON="✘"
fi
{
echo "Migrate lint ${STATUS_ICON}"
echo "<details>"
echo "<summary>Lint output</summary>"
echo
echo '```text'
printf '%s\n' "$LINT_OUTPUT"
echo '```'
echo
echo "</details>"
} > body.txt
# Exit early when not a pull_request event (e.g., push) since we cannot comment on a PR
if [ "${{ github.event_name }}" != "pull_request" ]; then
exit $LINT_EXIT_CODE
fi
gh pr comment ${{ github.event.pull_request.number }} \
--edit-last --create-if-none \
--body-file body.txt
GH_COMMENT_EXIT=$?
if [ $GH_COMMENT_EXIT -ne 0 ]; then
echo "Failed to post PR comment" >&2
exit 1
fi
exit $LINT_EXIT_CODE
shell: bash
env:
GH_TOKEN: ${{ github.token }}
spectral:
name: Spectral
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
- name: Spectral checks
uses: stoplightio/spectral-action@6416fd018ae38e60136775066eb3e98172143141 # v0.8.13
with:
file_glob: docs/openapi/*.yaml
repo_token: ${{ secrets.GITHUB_TOKEN }}
tbls:
name: tbls
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
- name: Run tbls
run: docker compose -f docker/tbls/compose.yaml up --build --abort-on-container-exit
- name: Check diff
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "tbls diff detected. Please generate and commit the new docs. (task tbls)"
exit 1
fi
shell: bash