Skip to content

fix

fix #6

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
GIN_MODE: release
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Build
run: go build -v ./...
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Test coverage
run: |
go test -v ./... -cover -covermode=count -coverprofile=coverage.out | tee test_output.txt
go tool cover -func=coverage.out | bash scripts/coverage.sh > coverage.txt
go tool cover -html=coverage.out -o coverage.html
- name: Comment Coverage
uses: actions/github-script@v6
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const coverage = fs.readFileSync('coverage.txt', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: coverage
});
update_deps:
runs-on: ubuntu-latest
needs: test
if: ${{ github.event_name == 'push' }}
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Set Up git
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Update dependencies
run: go mod tidy
- name: Commit changes
continue-on-error: true
run: |
git add go.mod go.sum
git commit -m "Update dependencies" || exit
git push
update_openapi:
runs-on: ubuntu-latest
needs: test
if: ${{ github.event_name == 'push' }}
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Set Up git
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Install dependencies
run: |
go mod download
go install github.com/swaggo/swag/cmd/swag@latest
- name: Update OpenAPI
run: swag init ./main.go
- name: Commit changes
continue-on-error: true
run: |
git add docs/swagger.yaml
git commit -m "Update OpenAPI" || exit
git push