mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-19 16:18:11 +00:00
Integration test processes now get their own work directory, config file and random ports, so several runs can execute in parallel on one machine. The slowest tests also lose fixed sleeps and needlessly expensive setup, with their assertions kept. - Batch PostgreSQL sequence resets, the main per-test fixture cost there - Cheap hashing params in hash and OAuth2 fixture tests, full-cost vectors stay - Single fetch for negative Actions runner assertions instead of 1s polls - Queue flushes and backdated timestamps instead of sleeps - In-memory SQLite test journal, tmpfs for PostgreSQL in CI - E2E instance writes SSH keys into its work directory instead of `~/.ssh/authorized_keys`
252 lines
8.9 KiB
YAML
252 lines
8.9 KiB
YAML
name: db-tests
|
|
|
|
on:
|
|
pull_request:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
files-changed:
|
|
uses: ./.github/workflows/files-changed.yml
|
|
|
|
test-pgsql-shard-1:
|
|
if: needs.files-changed.outputs.backend == 'true'
|
|
needs: files-changed
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 50
|
|
services:
|
|
pgsql:
|
|
image: postgres:14@sha256:156f0b253fd61366d5fc2107ad45955027d5612f695a8436ce20167f3fa79bff
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: postgres
|
|
options: >-
|
|
--mount type=tmpfs,destination=/var/lib/postgresql/data
|
|
ports:
|
|
- "5432:5432"
|
|
ldap:
|
|
image: gitea/test-openldap:latest@sha256:4ac633b01d684e6b2a458cc0c8530c92f9b3702f6e040ce5f365607df34fbda0
|
|
ports:
|
|
- "389:389"
|
|
- "636:636"
|
|
minio:
|
|
# as github actions doesn't support "entrypoint", we need to use a non-official image
|
|
# that has a custom entrypoint set to "minio server /data"
|
|
image: bitnamilegacy/minio:2025.7.23@sha256:8935e75fa5d11295c17171e4aa49efe390a1193cd7f12e4d21b92af9ffef09d7
|
|
env:
|
|
MINIO_ROOT_USER: 123456
|
|
MINIO_ROOT_PASSWORD: 12345678
|
|
ports:
|
|
- "9000:9000"
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
- uses: ./.github/actions/go-setup
|
|
- uses: ./.github/actions/pgsql-shard
|
|
with:
|
|
shard: 1
|
|
total-shards: 2
|
|
run-migration: "true"
|
|
|
|
test-pgsql-shard-2:
|
|
if: needs.files-changed.outputs.backend == 'true'
|
|
needs: files-changed
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 50
|
|
services:
|
|
pgsql:
|
|
image: postgres:14@sha256:156f0b253fd61366d5fc2107ad45955027d5612f695a8436ce20167f3fa79bff
|
|
env:
|
|
POSTGRES_DB: test
|
|
POSTGRES_PASSWORD: postgres
|
|
options: >-
|
|
--mount type=tmpfs,destination=/var/lib/postgresql/data
|
|
ports:
|
|
- "5432:5432"
|
|
ldap:
|
|
image: gitea/test-openldap:latest@sha256:4ac633b01d684e6b2a458cc0c8530c92f9b3702f6e040ce5f365607df34fbda0
|
|
ports:
|
|
- "389:389"
|
|
- "636:636"
|
|
minio:
|
|
# as github actions doesn't support "entrypoint", we need to use a non-official image
|
|
# that has a custom entrypoint set to "minio server /data"
|
|
image: bitnamilegacy/minio:2025.7.23@sha256:8935e75fa5d11295c17171e4aa49efe390a1193cd7f12e4d21b92af9ffef09d7
|
|
env:
|
|
MINIO_ROOT_USER: 123456
|
|
MINIO_ROOT_PASSWORD: 12345678
|
|
ports:
|
|
- "9000:9000"
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
- uses: ./.github/actions/go-setup
|
|
- uses: ./.github/actions/pgsql-shard
|
|
with:
|
|
shard: 2
|
|
total-shards: 2
|
|
|
|
test-sqlite:
|
|
if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
|
|
needs: files-changed
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
- uses: ./.github/actions/go-setup
|
|
- run: make deps-backend
|
|
- run: make backend
|
|
env:
|
|
TAGS: bindata
|
|
- run: GITEA_TEST_DATABASE=sqlite make test-migration
|
|
env:
|
|
TAGS: bindata
|
|
- name: run tests
|
|
run: GITEA_TEST_DATABASE=sqlite make test-integration
|
|
timeout-minutes: 50
|
|
env:
|
|
# sqlite driver can contain large amount of Golang code, so don't use race detector for it, otherwise, extremely slow
|
|
GOTEST_FLAGS: -timeout=40m
|
|
TAGS: bindata
|
|
|
|
test-unit:
|
|
if: needs.files-changed.outputs.backend == 'true'
|
|
needs: files-changed
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
elasticsearch:
|
|
image: elasticsearch:8.19.23@sha256:8b1751877c984f3e4f59bafb15fc890e01969a744255fd5f6860c060b62cff36
|
|
env:
|
|
discovery.type: single-node
|
|
xpack.security.enabled: false
|
|
xpack.ml.enabled: false
|
|
ingest.geoip.downloader.enabled: false
|
|
ES_JAVA_OPTS: "-Xms1g -Xmx1g"
|
|
ports:
|
|
- "9200:9200"
|
|
meilisearch:
|
|
image: getmeili/meilisearch:v1@sha256:c94e58ca09662dd6e65e8f1b0fd145767be3da7d5422a863a27b8d2b68e090c9
|
|
env:
|
|
MEILI_ENV: development # disable auth
|
|
ports:
|
|
- "7700:7700"
|
|
redis:
|
|
image: redis:8@sha256:298e5b3bc566bade82f46ad5511777a4a07a294097ce16ada2f6a42be5239df5
|
|
options: >- # wait until redis has started
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 5s
|
|
--health-timeout 3s
|
|
--health-retries 10
|
|
ports:
|
|
- 6379:6379
|
|
minio:
|
|
image: bitnamilegacy/minio:2025.7.23@sha256:8935e75fa5d11295c17171e4aa49efe390a1193cd7f12e4d21b92af9ffef09d7
|
|
env:
|
|
MINIO_ROOT_USER: 123456
|
|
MINIO_ROOT_PASSWORD: 12345678
|
|
ports:
|
|
- "9000:9000"
|
|
devstoreaccount1.azurite.local: # https://github.com/Azure/Azurite/issues/1583
|
|
image: mcr.microsoft.com/azure-storage/azurite:latest@sha256:f9791d0a0613e93057c06ae31f7ac0c0222f0530590e67e020b0986c66a36fa6
|
|
ports:
|
|
- 10000:10000
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
- uses: ./.github/actions/go-setup
|
|
- name: Add hosts to /etc/hosts
|
|
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 minio devstoreaccount1.azurite.local mysql elasticsearch meilisearch smtpimap" | sudo tee -a /etc/hosts'
|
|
- run: make deps-backend
|
|
- run: make generate-go
|
|
env:
|
|
TAGS: bindata
|
|
- name: unit-tests
|
|
run: make test-backend
|
|
env:
|
|
GOTEST_FLAGS: -race -timeout=20m
|
|
TAGS: bindata
|
|
GITHUB_READ_TOKEN: ${{ secrets.GITHUB_READ_TOKEN }}
|
|
- run: make test-check
|
|
|
|
test-mysql:
|
|
if: needs.files-changed.outputs.backend == 'true'
|
|
needs: files-changed
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
mysql:
|
|
# the bitnami mysql image has more options than the official one, it's easier to customize
|
|
image: bitnamilegacy/mysql:8.4@sha256:7089d796fc9b4629a628bd445e4afabe607351ee665444c3197bdeaed812ea65
|
|
env:
|
|
ALLOW_EMPTY_PASSWORD: true
|
|
MYSQL_DATABASE: testgitea
|
|
ports:
|
|
- "3306:3306"
|
|
options: >-
|
|
--mount type=tmpfs,destination=/bitnami/mysql/data
|
|
elasticsearch:
|
|
image: elasticsearch:8.19.23@sha256:8b1751877c984f3e4f59bafb15fc890e01969a744255fd5f6860c060b62cff36
|
|
env:
|
|
discovery.type: single-node
|
|
xpack.security.enabled: false
|
|
xpack.ml.enabled: false
|
|
ingest.geoip.downloader.enabled: false
|
|
ES_JAVA_OPTS: "-Xms1g -Xmx1g"
|
|
ports:
|
|
- "9200:9200"
|
|
smtpimap:
|
|
image: tabascoterrier/docker-imap-devel:latest@sha256:3fb7cf50b47693e7b80f6f74abea2def4d7386016931d61359864de8a0aba551
|
|
ports:
|
|
- "25:25"
|
|
- "143:143"
|
|
- "587:587"
|
|
- "993:993"
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
- uses: ./.github/actions/go-setup
|
|
- name: Add hosts to /etc/hosts
|
|
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mysql elasticsearch smtpimap" | sudo tee -a /etc/hosts'
|
|
- run: make deps-backend
|
|
- run: make backend
|
|
env:
|
|
TAGS: bindata
|
|
- run: GITEA_TEST_DATABASE=mysql make test-migration
|
|
- name: run tests
|
|
run: GITEA_TEST_DATABASE=mysql make test-integration
|
|
env:
|
|
TAGS: bindata
|
|
TEST_INDEXER_CODE_ES_URL: "http://elastic:changeme@elasticsearch:9200"
|
|
|
|
test-mssql:
|
|
if: needs.files-changed.outputs.backend == 'true'
|
|
needs: files-changed
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
mssql:
|
|
image: mcr.microsoft.com/mssql/server:2019-latest@sha256:ef0b8db33970ecd01bed49c3a84a1d083c435a9891718df619298b67b352e74a
|
|
env:
|
|
ACCEPT_EULA: Y
|
|
MSSQL_PID: Standard
|
|
SA_PASSWORD: MwantsaSecurePassword1
|
|
ports:
|
|
- "1433:1433"
|
|
devstoreaccount1.azurite.local: # https://github.com/Azure/Azurite/issues/1583
|
|
image: mcr.microsoft.com/azure-storage/azurite:latest@sha256:f9791d0a0613e93057c06ae31f7ac0c0222f0530590e67e020b0986c66a36fa6
|
|
ports:
|
|
- 10000:10000
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
- uses: ./.github/actions/go-setup
|
|
- name: Add hosts to /etc/hosts
|
|
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mssql devstoreaccount1.azurite.local" | sudo tee -a /etc/hosts'
|
|
- run: make deps-backend
|
|
- run: make backend
|
|
env:
|
|
TAGS: bindata
|
|
- run: GITEA_TEST_DATABASE=mssql make test-migration
|
|
- name: run tests
|
|
run: GITEA_TEST_DATABASE=mssql make test-integration
|
|
timeout-minutes: 50
|
|
env:
|
|
TAGS: bindata
|