Skip to content

Commit

Permalink
[Chore] #7 Add CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
miyamo2 committed Mar 16, 2024
1 parent 6e553b3 commit 4dc5837
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: ci

on:
push:
branches:
- "feat/**"
- "refactor/**"
- "fix/**"
pull_request:
branches:
- "main"
workflow_call:

permissions: write-all

jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
goversion: [ ">=1.21.0"]

steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.goversion }}
cache: true
cache-dependency-path: go.sum

- name: Setup mockgen
run: |
go install go.uber.org/mock/mockgen@latest
- name: Go Generate
run: |
go mod tidy
go generate ./...
git diff --exit-code
- name: Setup reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest

- name: Setup staticcheck
run: |
go install honnef.co/go/tools/cmd/staticcheck@latest
- name: staticcheck with reviewdog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
staticcheck ./... | reviewdog -f=staticcheck -reporter=github-pr-check -level warning
- name: Go Test
run: |
go test ./... -v
51 changes: 51 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: release

on:
push:
tags:
- "v*"

permissions: write-all

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ">=1.21.0"
cache: true
cache-dependency-path: go.sum

- name: Setup mockgen
run: |
go install go.uber.org/mock/mockgen@latest
- name: Go Generate
run: |
go mod tidy
go generate ./...
git diff --exit-code
- name: Go Test
run: |
TARGET=$(go list ./... | grep -v "mock")
go test $TARGET -v -coverpkg=$TARGET -coverprofile=coverage.out
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out
fail_ci_if_error: false
verbose: true

- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ github.ref_name }}
generate_release_notes: true

0 comments on commit 4dc5837

Please sign in to comment.