Skip to content

ci

ci #94

Workflow file for this run

name: ci
permissions: {} # no need any permissions
on:
push:
branches: [main]
merge_group:
pull_request:
branches: [main]
schedule:
- cron: "0 10 * * 1" # run "At 10:00 on Monday"
workflow_call:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check:
name: Check
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "stable"
check-latest: true
- name: Checkout code
uses: actions/checkout@v4
- name: Go Format
run: gofmt -s -w . && git diff --exit-code
- name: Go Tidy
run: go mod tidy && git diff --exit-code
- name: Go Vet
run: go vet ./...
- name: Go Download
run: go mod download
- name: Go Mod Verify
run: go mod verify
- uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: "1.22.0"
- name: Install deps
run: |
go install goa.design/goa/v3/cmd/goa@v3
go install github.com/rjeczalik/interfaces/cmd/interfacer@latest
go install go.uber.org/mock/mockgen@latest
go install github.com/onsi/ginkgo/v2/ginkgo@latest
- name: Generate
run: |
make generate
go mod tidy # Running go mod tidy because goa's dependency will generate undesired changes
git diff --exit-code
- name: Go Build
run: make build
test:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
go: ["1.21"]
# Disabling 1.20 because I'm using slices and maybe slog and don't really want to wait.
# go: ['1.20', '1.21']
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
check-latest: true
- run: go version
- name: Go Build
run: make build
- name: Go Test
run: make test
- name: Upload Coverage
uses: codecov/codecov-action@v3
continue-on-error: true
with:
token: ${{secrets.CODECOV_TOKEN}}
file: ./cover.profile
fail_ci_if_error: false
- name: Test Summary
uses: test-summary/action@v2
with:
paths: |
report.xml
if: always()
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "stable"
check-latest: true
- name: Checkout code
uses: actions/checkout@v4
- name: Lint
uses: golangci/[email protected]
with:
version: latest
args: --timeout 5m
db:
name: Sqlc
runs-on: ubuntu-latest
services:
postgres:
image: "postgres:14"
env:
POSTGRES_USER: rotabot
POSTGRES_PASSWORD: ""
POSTGRES_DB: rotabot
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: setup-sqlc
uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: "1.22.0"
- name: Run db migrations
run: |
make migrations/up DB_DSN=rotabot:postgres@localhost:5432/rotabot?sslmode=disable
- run: sqlc diff
- run: sqlc vet
migrations:
name: Migrations
runs-on: ubuntu-latest
services:
postgres:
image: "postgres:14"
env:
POSTGRES_USER: rotabot
POSTGRES_PASSWORD: ""
POSTGRES_DB: rotabot
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: DB Schema Diff
run: make migrations/test && git diff --exit-code
vuln:
name: Vuln
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "stable"
check-latest: true
- name: Checkout
uses: actions/checkout@v4
- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest
- name: Run govulncheck
run: govulncheck -test ./...