forked from baron/baron-sso
126 lines
3.9 KiB
YAML
126 lines
3.9 KiB
YAML
name: Code Check
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- dev
|
|
workflow_dispatch:
|
|
inputs:
|
|
run_lint:
|
|
description: "Run linters for Go and Flutter"
|
|
required: true
|
|
type: boolean
|
|
default: true
|
|
run_backend_tests:
|
|
description: "Run backend Go tests"
|
|
required: true
|
|
type: boolean
|
|
default: true
|
|
run_userfront_tests:
|
|
description: "Run userfront Flutter tests"
|
|
required: true
|
|
type: boolean
|
|
default: true
|
|
|
|
jobs:
|
|
lint:
|
|
if: ${{ github.event_name != 'workflow_dispatch' || inputs.run_lint == true }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "20"
|
|
|
|
- name: i18n resource check
|
|
run: |
|
|
mkdir -p reports
|
|
node tools/i18n-scanner/index.js
|
|
node tools/i18n-scanner/report.js
|
|
cat reports/i18n-report.txt
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.25"
|
|
cache-dependency-path: backend/go.sum
|
|
|
|
- name: Setup Flutter
|
|
uses: subosito/flutter-action@v2
|
|
with:
|
|
channel: "stable"
|
|
cache: true
|
|
|
|
- name: Lint Go backend
|
|
uses: golangci/golangci-lint-action@v6
|
|
with:
|
|
version: v1.59
|
|
working-directory: backend
|
|
args: --enable-only=gofmt,gofumpt
|
|
|
|
- name: Analyze Flutter userfront
|
|
run: |
|
|
cd userfront
|
|
flutter analyze --no-fatal-warnings --no-fatal-infos
|
|
|
|
backend-tests:
|
|
needs: lint
|
|
if: ${{ github.event_name != 'workflow_dispatch' || inputs.run_backend_tests == true }}
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
redis:
|
|
image: redis:7-alpine
|
|
options: >
|
|
--health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
|
|
clickhouse:
|
|
image: clickhouse/clickhouse-server:24.6
|
|
options: >
|
|
--health-cmd "wget -qO- 'http://localhost:8123/ping'" --health-interval 10s --health-timeout 5s --health-retries 5
|
|
|
|
env:
|
|
REDIS_ADDR: redis:6379
|
|
CLICKHOUSE_HOST: clickhouse
|
|
CLICKHOUSE_PORT_NATIVE: 9000
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.25"
|
|
cache-dependency-path: backend/go.sum
|
|
|
|
- name: Run backend tests
|
|
run: |
|
|
cd backend
|
|
go test -v ./...
|
|
|
|
userfront-tests:
|
|
needs: lint
|
|
if: ${{ github.event_name != 'workflow_dispatch' || inputs.run_userfront_tests == true }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Flutter
|
|
uses: subosito/flutter-action@v2
|
|
with:
|
|
channel: "stable"
|
|
cache: true
|
|
|
|
- name: Run userfront tests
|
|
run: |
|
|
cd userfront
|
|
if [ -d test ]; then
|
|
flutter test
|
|
flutter test --platform chrome test/locale_storage_web_test.dart
|
|
else
|
|
echo "No userfront tests: skipping (test/ directory not found)."
|
|
fi
|