ci: Improve CI with proper test configuration
Some checks failed
Build and Release / Lint (push) Failing after 7s
Build and Release / Build Binaries (amd64, darwin) (push) Has been skipped
Build and Release / Build Binaries (amd64, linux) (push) Has been skipped
Build and Release / Build Binaries (amd64, windows) (push) Has been skipped
Build and Release / Build Binaries (arm64, darwin) (push) Has been skipped
Build and Release / Build Binaries (arm64, linux) (push) Has been skipped
Build and Release / Integration Tests (PostgreSQL) (push) Failing after 6s
Build and Release / Unit Tests (push) Failing after 2m43s
Some checks failed
Build and Release / Lint (push) Failing after 7s
Build and Release / Build Binaries (amd64, darwin) (push) Has been skipped
Build and Release / Build Binaries (amd64, linux) (push) Has been skipped
Build and Release / Build Binaries (amd64, windows) (push) Has been skipped
Build and Release / Build Binaries (arm64, darwin) (push) Has been skipped
Build and Release / Build Binaries (arm64, linux) (push) Has been skipped
Build and Release / Integration Tests (PostgreSQL) (push) Failing after 6s
Build and Release / Unit Tests (push) Failing after 2m43s
- Split into separate lint, unit-test, and integration-test jobs - Add PostgreSQL service for integration tests - Run unit tests on modules/... and services/... with SQLite tags - Remove unnecessary version checks (let actions install tools) - Fix Go version to 1.24 (matches go.mod) - Build only depends on lint passing (tests run in parallel) - Keep continue-on-error on integration tests (may fail in CI) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
75ee700ff2
commit
badc4e4be3
@ -15,82 +15,137 @@ env:
|
|||||||
GOPROXY: https://proxy.golang.org,direct
|
GOPROXY: https://proxy.golang.org,direct
|
||||||
GOPRIVATE: git.marketally.com
|
GOPRIVATE: git.marketally.com
|
||||||
GONOSUMDB: git.marketally.com
|
GONOSUMDB: git.marketally.com
|
||||||
GO_VERSION: "1.25"
|
GO_VERSION: "1.24"
|
||||||
NODE_VERSION: "22"
|
NODE_VERSION: "22"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Lint and test job
|
# Lint job - must pass
|
||||||
lint-test:
|
lint:
|
||||||
name: Lint and Test
|
name: Lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Check for existing Go
|
|
||||||
id: go-check
|
|
||||||
run: |
|
|
||||||
if command -v go &> /dev/null; then
|
|
||||||
GO_VER=$(go version | grep -oP 'go\d+\.\d+' | head -1)
|
|
||||||
echo "version=$GO_VER" >> $GITHUB_OUTPUT
|
|
||||||
echo "Found Go: $(go version)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
if: steps.go-check.outputs.version == ''
|
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
cache: false
|
cache: false
|
||||||
|
|
||||||
- name: Check for existing Node.js
|
|
||||||
id: node-check
|
|
||||||
run: |
|
|
||||||
if command -v node &> /dev/null; then
|
|
||||||
NODE_VER=$(node --version)
|
|
||||||
echo "version=$NODE_VER" >> $GITHUB_OUTPUT
|
|
||||||
echo "Found Node.js: $NODE_VER"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
if: steps.node-check.outputs.version == ''
|
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Check for existing pnpm
|
|
||||||
id: pnpm-check
|
|
||||||
run: |
|
|
||||||
if command -v pnpm &> /dev/null; then
|
|
||||||
PNPM_VER=$(pnpm --version)
|
|
||||||
echo "version=$PNPM_VER" >> $GITHUB_OUTPUT
|
|
||||||
echo "Found pnpm: $PNPM_VER"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
if: steps.pnpm-check.outputs.version == ''
|
|
||||||
run: npm install -g pnpm
|
run: npm install -g pnpm
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: make deps-frontend deps-backend
|
run: make deps-frontend deps-backend
|
||||||
|
|
||||||
- name: Run linters
|
- name: Run Go linter
|
||||||
run: make lint-go lint-frontend
|
run: make lint-go
|
||||||
|
|
||||||
|
- name: Run frontend linter
|
||||||
|
run: make lint-frontend
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Run tests
|
# Unit tests with SQLite (no external database needed)
|
||||||
run: make test
|
test-unit:
|
||||||
|
name: Unit Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
cache: false
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: go mod download
|
||||||
|
|
||||||
|
- name: Run unit tests
|
||||||
|
run: |
|
||||||
|
go test -tags="sqlite sqlite_unlock_notify" -race -v \
|
||||||
|
./modules/... \
|
||||||
|
./services/...
|
||||||
|
env:
|
||||||
|
GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT: true
|
||||||
|
|
||||||
|
# Integration tests with PostgreSQL
|
||||||
|
test-pgsql:
|
||||||
|
name: Integration Tests (PostgreSQL)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
pgsql:
|
||||||
|
image: postgres:15
|
||||||
|
env:
|
||||||
|
POSTGRES_DB: testgitea
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
options: >-
|
||||||
|
--health-cmd pg_isready
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 5
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
cache: false
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Install pnpm
|
||||||
|
run: npm install -g pnpm
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: make deps-frontend deps-backend
|
||||||
|
|
||||||
|
- name: Build test binary
|
||||||
|
run: |
|
||||||
|
go build -tags="bindata sqlite sqlite_unlock_notify" -o gitea .
|
||||||
|
|
||||||
|
- name: Generate test config
|
||||||
|
run: |
|
||||||
|
make generate-ini-pgsql
|
||||||
|
env:
|
||||||
|
TEST_PGSQL_HOST: localhost:5432
|
||||||
|
TEST_PGSQL_DBNAME: testgitea
|
||||||
|
TEST_PGSQL_USERNAME: postgres
|
||||||
|
TEST_PGSQL_PASSWORD: postgres
|
||||||
|
TEST_PGSQL_SCHEMA: gtestschema
|
||||||
|
|
||||||
|
- name: Run PostgreSQL integration tests
|
||||||
|
run: |
|
||||||
|
make test-pgsql
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
env:
|
env:
|
||||||
|
TEST_PGSQL_HOST: localhost:5432
|
||||||
|
TEST_PGSQL_DBNAME: testgitea
|
||||||
|
TEST_PGSQL_USERNAME: postgres
|
||||||
|
TEST_PGSQL_PASSWORD: postgres
|
||||||
|
TEST_PGSQL_SCHEMA: gtestschema
|
||||||
GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT: true
|
GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT: true
|
||||||
|
|
||||||
# Build job for binaries
|
# Build job for binaries
|
||||||
build:
|
build:
|
||||||
name: Build Binaries
|
name: Build Binaries
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: lint-test
|
needs: [lint]
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
@ -110,48 +165,18 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Check for existing Go
|
|
||||||
id: go-check
|
|
||||||
run: |
|
|
||||||
if command -v go &> /dev/null; then
|
|
||||||
GO_VER=$(go version | grep -oP 'go\d+\.\d+' | head -1)
|
|
||||||
echo "version=$GO_VER" >> $GITHUB_OUTPUT
|
|
||||||
echo "Found Go: $(go version)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
if: steps.go-check.outputs.version == ''
|
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
cache: false
|
cache: false
|
||||||
|
|
||||||
- name: Check for existing Node.js
|
|
||||||
id: node-check
|
|
||||||
run: |
|
|
||||||
if command -v node &> /dev/null; then
|
|
||||||
NODE_VER=$(node --version)
|
|
||||||
echo "version=$NODE_VER" >> $GITHUB_OUTPUT
|
|
||||||
echo "Found Node.js: $NODE_VER"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
if: steps.node-check.outputs.version == ''
|
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Check for existing pnpm
|
|
||||||
id: pnpm-check
|
|
||||||
run: |
|
|
||||||
if command -v pnpm &> /dev/null; then
|
|
||||||
PNPM_VER=$(pnpm --version)
|
|
||||||
echo "version=$PNPM_VER" >> $GITHUB_OUTPUT
|
|
||||||
echo "Found pnpm: $PNPM_VER"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
if: steps.pnpm-check.outputs.version == ''
|
|
||||||
run: npm install -g pnpm
|
run: npm install -g pnpm
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
@ -206,7 +231,7 @@ jobs:
|
|||||||
RESPONSE=$(curl -s -X POST \
|
RESPONSE=$(curl -s -X POST \
|
||||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"tag_name":"'"$TAG"'","name":"Gitea '"$TAG"'","body":"Official release.","draft":false,"prerelease":false}' \
|
-d '{"tag_name":"'"$TAG"'","name":"GitCaddy '"$TAG"'","body":"Official release.","draft":false,"prerelease":false}' \
|
||||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases")
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases")
|
||||||
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
||||||
echo "Created release: $RELEASE_ID"
|
echo "Created release: $RELEASE_ID"
|
||||||
|
|||||||
@ -10,60 +10,30 @@ env:
|
|||||||
GOPROXY: https://proxy.golang.org,direct
|
GOPROXY: https://proxy.golang.org,direct
|
||||||
GOPRIVATE: git.marketally.com
|
GOPRIVATE: git.marketally.com
|
||||||
GONOSUMDB: git.marketally.com
|
GONOSUMDB: git.marketally.com
|
||||||
GO_VERSION: "1.25"
|
GO_VERSION: "1.24"
|
||||||
NODE_VERSION: "22"
|
NODE_VERSION: "22"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Quick checks for PRs
|
# Quick lint checks - must pass
|
||||||
checks:
|
lint:
|
||||||
name: Code Quality Checks
|
name: Lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Check for existing Go
|
|
||||||
id: go-check
|
|
||||||
run: |
|
|
||||||
if command -v go &> /dev/null; then
|
|
||||||
GO_VER=$(go version | grep -oP 'go\d+\.\d+' | head -1)
|
|
||||||
echo "version=$GO_VER" >> $GITHUB_OUTPUT
|
|
||||||
echo "Found Go: $(go version)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
if: steps.go-check.outputs.version == ''
|
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
cache: false
|
cache: false
|
||||||
|
|
||||||
- name: Check for existing Node.js
|
|
||||||
id: node-check
|
|
||||||
run: |
|
|
||||||
if command -v node &> /dev/null; then
|
|
||||||
NODE_VER=$(node --version)
|
|
||||||
echo "version=$NODE_VER" >> $GITHUB_OUTPUT
|
|
||||||
echo "Found Node.js: $NODE_VER"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
if: steps.node-check.outputs.version == ''
|
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Check for existing pnpm
|
|
||||||
id: pnpm-check
|
|
||||||
run: |
|
|
||||||
if command -v pnpm &> /dev/null; then
|
|
||||||
PNPM_VER=$(pnpm --version)
|
|
||||||
echo "version=$PNPM_VER" >> $GITHUB_OUTPUT
|
|
||||||
echo "Found pnpm: $PNPM_VER"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
if: steps.pnpm-check.outputs.version == ''
|
|
||||||
run: npm install -g pnpm
|
run: npm install -g pnpm
|
||||||
|
|
||||||
- name: Install Go dependencies
|
- name: Install Go dependencies
|
||||||
@ -80,44 +50,37 @@ jobs:
|
|||||||
- name: Go vet
|
- name: Go vet
|
||||||
run: go vet ./...
|
run: go vet ./...
|
||||||
|
|
||||||
|
- name: Go linter
|
||||||
|
run: |
|
||||||
|
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.2 run
|
||||||
|
|
||||||
- name: Check for build errors
|
- name: Check for build errors
|
||||||
run: go build -v ./...
|
run: go build -v ./...
|
||||||
|
|
||||||
# Unit tests
|
# Unit tests
|
||||||
unit-tests:
|
test-unit:
|
||||||
name: Unit Tests
|
name: Unit Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Check for existing Go
|
|
||||||
id: go-check
|
|
||||||
run: |
|
|
||||||
if command -v go &> /dev/null; then
|
|
||||||
GO_VER=$(go version | grep -oP 'go\d+\.\d+' | head -1)
|
|
||||||
echo "version=$GO_VER" >> $GITHUB_OUTPUT
|
|
||||||
echo "Found Go: $(go version)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
if: steps.go-check.outputs.version == ''
|
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
cache: false
|
cache: false
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: go mod download
|
||||||
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: |
|
run: |
|
||||||
go test -v -race -coverprofile=coverage.out ./...
|
go test -tags="sqlite sqlite_unlock_notify" -race \
|
||||||
continue-on-error: true
|
./modules/... \
|
||||||
|
./services/...
|
||||||
- name: Upload coverage
|
env:
|
||||||
uses: actions/upload-artifact@v3
|
GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT: true
|
||||||
with:
|
|
||||||
name: coverage
|
|
||||||
path: coverage.out
|
|
||||||
retention-days: 7
|
|
||||||
|
|
||||||
# Frontend checks
|
# Frontend checks
|
||||||
frontend:
|
frontend:
|
||||||
@ -127,32 +90,12 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Check for existing Node.js
|
|
||||||
id: node-check
|
|
||||||
run: |
|
|
||||||
if command -v node &> /dev/null; then
|
|
||||||
NODE_VER=$(node --version)
|
|
||||||
echo "version=$NODE_VER" >> $GITHUB_OUTPUT
|
|
||||||
echo "Found Node.js: $NODE_VER"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
if: steps.node-check.outputs.version == ''
|
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Check for existing pnpm
|
|
||||||
id: pnpm-check
|
|
||||||
run: |
|
|
||||||
if command -v pnpm &> /dev/null; then
|
|
||||||
PNPM_VER=$(pnpm --version)
|
|
||||||
echo "version=$PNPM_VER" >> $GITHUB_OUTPUT
|
|
||||||
echo "Found pnpm: $PNPM_VER"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
if: steps.pnpm-check.outputs.version == ''
|
|
||||||
run: npm install -g pnpm
|
run: npm install -g pnpm
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user