opengist/.github/workflows/go.yml

118 lines
2.6 KiB
YAML
Raw Normal View History

2023-09-17 00:55:17 +00:00
name: "Go CI"
2023-04-26 21:20:06 +00:00
on:
push:
2024-09-22 21:21:30 +00:00
branches:
- master
- 'dev-*'
workflow_dispatch:
2023-04-26 21:20:06 +00:00
pull_request:
2024-01-05 03:36:05 +00:00
paths-ignore:
- '**.yml'
2024-09-22 21:21:30 +00:00
- '**.md'
2023-04-26 21:20:06 +00:00
jobs:
2023-09-17 00:55:17 +00:00
lint:
name: Lint
2023-09-17 00:55:17 +00:00
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
2024-05-04 22:38:06 +00:00
- name: Set up Go 1.22
2023-09-17 00:55:17 +00:00
uses: actions/setup-go@v4
with:
2024-05-04 22:38:06 +00:00
go-version: "1.22"
2023-09-17 00:55:17 +00:00
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
skip-pkg-cache: true
args: --out-format=colored-line-number --timeout=20m
- name: Format
run: make fmt check_changes
check:
name: Check
2023-09-17 00:55:17 +00:00
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
2024-05-04 22:38:06 +00:00
- name: Set up Go 1.22
2023-09-17 00:55:17 +00:00
uses: actions/setup-go@v4
with:
2024-05-04 22:38:06 +00:00
go-version: "1.22"
2023-09-17 00:55:17 +00:00
2024-05-11 19:02:57 +00:00
- name: Check Go modules
2023-09-17 00:55:17 +00:00
run: make go_mod check_changes
2024-05-11 19:02:57 +00:00
- name: Check translations
run: make check-tr
test-db:
name: Test
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
go: ["1.22"]
database: [postgres, mysql]
include:
- database: postgres
image: postgres:16
port: 5432:5432
- database: mysql
image: mysql:8
port: 3306:3306
runs-on: ${{ matrix.os }}
services:
database:
image: ${{ matrix.image }}
ports:
- ${{ matrix.port }}
env:
POSTGRES_PASSWORD: opengist
POSTGRES_DB: opengist_test
MYSQL_ROOT_PASSWORD: opengist
MYSQL_DATABASE: opengist_test
options: >-
--health-cmd ${{ matrix.database == 'postgres' && 'pg_isready' || '"mysqladmin ping"' }}
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- name: Run tests
run: make test TEST_DB_TYPE=${{ matrix.database }}
2023-09-17 00:55:17 +00:00
test:
name: Test
2023-04-26 21:20:06 +00:00
strategy:
fail-fast: false
matrix:
2023-09-17 00:55:17 +00:00
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
2024-05-04 22:38:06 +00:00
go: ["1.22"]
database: ["sqlite"]
2023-04-26 21:20:06 +00:00
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
2023-04-26 21:55:37 +00:00
uses: actions/checkout@v3
2023-04-26 21:20:06 +00:00
- name: Set up Go ${{ matrix.go }}
2023-09-17 00:55:17 +00:00
uses: actions/setup-go@v4
2023-04-26 21:20:06 +00:00
with:
go-version: ${{ matrix.go }}
2023-09-17 00:55:17 +00:00
- name: Run tests
run: make test TEST_DB_TYPE=${{ matrix.database }}