Merge pull request #1210 from traPtitech/dependabot/docker/golang-1.2… #1675
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- 'main' | |
- 'develop' | |
pull_request: | |
env: | |
TZ: Asia/Tokyo | |
jobs: | |
mod: | |
name: Mod | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
- uses: actions/checkout@v4 | |
- uses: actions/[email protected] | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }} | |
- run: go mod download | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
needs: [mod] | |
env: | |
GOCACHE: "/tmp/go/cache" | |
steps: | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
- uses: actions/checkout@v4 | |
- uses: actions/[email protected] | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-gomod- | |
- uses: actions/[email protected] | |
with: | |
path: /tmp/go/cache | |
key: ${{ runner.os }}-go-build-${{ github.ref }}-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-go-build-${{ github.ref }}- | |
${{ runner.os }}-go-build- | |
- run: go build -o anke-to | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: anke-to | |
path: anke-to | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
needs: [mod] | |
services: | |
mysql: | |
image: mariadb:10.3.9 | |
ports: | |
- 3306:3306 | |
env: | |
MYSQL_ROOT_PASSWORD: password | |
MYSQL_DATABASE: anke-to | |
steps: | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
- uses: actions/checkout@v4 | |
- uses: actions/[email protected] | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-gomod- | |
- run: go install github.com/golang/mock/[email protected] | |
- run: go generate ./... | |
- run: go test ./model ./router -v -coverprofile=coverage.txt -race -vet=off | |
env: | |
MARIADB_USERNAME: root | |
MARIADB_PASSWORD: password | |
MARIADB_HOSTNAME: 127.0.0.1 | |
MARIADB_DATABASE: anke-to | |
- name: Upload coverage data | |
uses: codecov/[email protected] | |
with: | |
file: ./coverage.txt | |
yml: ./codecov.yml | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: coverage.txt | |
path: coverage.txt | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
- uses: actions/checkout@v4 | |
- name: golangci-lint | |
uses: reviewdog/[email protected] | |
with: | |
reporter: github-pr-check | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
fail_on_error: true | |
spectral: | |
name: Spectral | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Spectral checks | |
uses: stoplightio/[email protected] | |
with: | |
file_glob: docs/swagger/*.yaml | |
repo_token: ${{ secrets.GITHUB_TOKEN }} |