Skip to content

Commit d57d063

Browse files
silverwindclaudewxiaoguang
authored
Refactor integration tests infrastructure (#37462)
Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 parent 9262803 commit d57d063

26 files changed

Lines changed: 311 additions & 524 deletions

.dockerignore

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ cpu.out
4040
*.log
4141

4242
/gitea
43-
/gitea-vet
4443
/debug
45-
/integrations.test
4644

4745
/bin
4846
/dist
@@ -54,12 +52,6 @@ cpu.out
5452
/indexers
5553
/log
5654
/tests/integration/gitea-integration-*
57-
/tests/integration/indexers-*
58-
/tests/e2e/gitea-e2e-*
59-
/tests/e2e/indexers-*
60-
/tests/e2e/reports
61-
/tests/e2e/test-artifacts
62-
/tests/e2e/test-snapshots
6355
/tests/*.ini
6456
/node_modules
6557
/yarn.lock

.github/workflows/cache-seeder.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
include:
5858
- { job: lint-backend, tags: "bindata sqlite sqlite_unlock_notify", target: "lint-backend" }
5959
- { job: lint-go-windows, tags: "bindata sqlite sqlite_unlock_notify", target: "lint-go-windows" }
60-
- { job: lint-go-gogit, tags: "bindata sqlite sqlite_unlock_notify gogit", target: "lint-go" }
60+
- { job: lint-go-gogit, tags: "bindata gogit sqlite sqlite_unlock_notify", target: "lint-go" }
6161
steps:
6262
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6363
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Reusable workflow that performs the container build steps for a single platform.
2+
# Used by `pull-docker-dryrun.yml` to run builds in parallel per-platform.
3+
on:
4+
workflow_call:
5+
inputs:
6+
platform:
7+
description: 'The target platform(s) to build for (e.g. linux/amd64)'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
build-dryrun:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
steps:
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
- uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
19+
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
20+
- name: Build rootful image
21+
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
22+
with:
23+
context: .
24+
platforms: ${{ inputs.platform }}
25+
push: false
26+
file: Dockerfile
27+
cache-from: type=registry,ref=ghcr.io/go-gitea/gitea:buildcache-rootful
28+
- name: Build rootless image
29+
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
30+
with:
31+
context: .
32+
platforms: ${{ inputs.platform }}
33+
push: false
34+
file: Dockerfile.rootless
35+
cache-from: type=registry,ref=ghcr.io/go-gitea/gitea:buildcache-rootless

.github/workflows/pull-db-tests.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,12 @@ jobs:
5858
env:
5959
TAGS: bindata
6060
- name: run migration tests
61-
run: make test-pgsql-migration
61+
run: GITEA_TEST_DATABASE=pgsql make test-migration
6262
- name: run tests
63-
run: make test-pgsql
63+
run: GITEA_TEST_DATABASE=pgsql make test-integration
6464
timeout-minutes: 50
6565
env:
6666
TAGS: bindata gogit
67-
TEST_TAGS: gogit
6867
TEST_LDAP: 1
6968

7069
test-sqlite:
@@ -84,18 +83,21 @@ jobs:
8483
with:
8584
cache-name: sqlite
8685
- run: make deps-backend
87-
- run: GOEXPERIMENT='' make backend
86+
- run: make backend
8887
env:
8988
TAGS: bindata gogit sqlite sqlite_unlock_notify
89+
GOEXPERIMENT:
9090
- name: run migration tests
91-
run: make test-sqlite-migration
91+
run: GITEA_TEST_DATABASE=sqlite make test-migration
92+
env:
93+
TAGS: bindata gogit
9294
- name: run tests
93-
run: GOEXPERIMENT='' make test-sqlite
95+
run: GITEA_TEST_DATABASE=sqlite make test-integration
9496
timeout-minutes: 50
9597
env:
96-
TAGS: bindata gogit sqlite sqlite_unlock_notify
97-
RACE_ENABLED: true
98-
TEST_TAGS: gogit sqlite sqlite_unlock_notify
98+
TAGS: bindata gogit
99+
GOEXPERIMENT:
100+
GOTEST_FLAGS: -race -timeout=40m
99101

100102
test-unit:
101103
if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
@@ -156,16 +158,15 @@ jobs:
156158
- name: unit-tests
157159
run: make test-backend test-check
158160
env:
159-
TAGS: bindata
160-
RACE_ENABLED: true
161-
GOTESTFLAGS: -timeout=20m
161+
TAGS: bindata sqlite sqlite_unlock_notify
162+
GOTEST_FLAGS: -race -timeout=20m
162163
GITHUB_READ_TOKEN: ${{ secrets.GITHUB_READ_TOKEN }}
163164
- name: unit-tests-gogit
164-
run: GOEXPERIMENT='' make test-backend test-check
165+
run: make test-backend test-check
165166
env:
166-
TAGS: bindata gogit
167-
RACE_ENABLED: true
168-
GOTESTFLAGS: -timeout=20m
167+
TAGS: bindata gogit sqlite sqlite_unlock_notify
168+
GOEXPERIMENT:
169+
GOTEST_FLAGS: -race -timeout=20m
169170
GITHUB_READ_TOKEN: ${{ secrets.GITHUB_READ_TOKEN }}
170171

171172
test-mysql:
@@ -215,10 +216,9 @@ jobs:
215216
env:
216217
TAGS: bindata
217218
- name: run migration tests
218-
run: make test-mysql-migration
219+
run: GITEA_TEST_DATABASE=mysql make test-migration
219220
- name: run tests
220-
# run: make integration-test-coverage (at the moment, no coverage is really handled)
221-
run: make test-mysql
221+
run: GITEA_TEST_DATABASE=mysql make test-integration
222222
env:
223223
TAGS: bindata
224224
TEST_INDEXER_CODE_ES_URL: "http://elastic:changeme@elasticsearch:9200"
@@ -258,9 +258,9 @@ jobs:
258258
- run: make backend
259259
env:
260260
TAGS: bindata
261-
- run: make test-mssql-migration
261+
- run: GITEA_TEST_DATABASE=mssql make test-migration
262262
- name: run tests
263-
run: make test-mssql
263+
run: GITEA_TEST_DATABASE=mssql make test-integration
264264
timeout-minutes: 50
265265
env:
266266
TAGS: bindata

.github/workflows/pull-docker-dryrun.yml

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,33 @@ concurrency:
77
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
88
cancel-in-progress: true
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
1114
files-changed:
1215
uses: ./.github/workflows/files-changed.yml
1316
permissions:
1417
contents: read
1518

16-
container:
19+
# dryrun build is slow, so run them in parallel per-platform
20+
container-amd64:
1721
if: needs.files-changed.outputs.docker == 'true'
18-
needs: files-changed
19-
runs-on: ubuntu-latest
20-
permissions:
21-
contents: read
22-
steps:
23-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24-
- uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
25-
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
26-
- name: Build regular container image
27-
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
28-
with:
29-
context: .
30-
platforms: linux/amd64,linux/arm64,linux/riscv64
31-
push: false
32-
cache-from: type=registry,ref=ghcr.io/go-gitea/gitea:buildcache-rootful
33-
- name: Build rootless container image
34-
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
35-
with:
36-
context: .
37-
push: false
38-
platforms: linux/amd64,linux/arm64,linux/riscv64
39-
file: Dockerfile.rootless
40-
cache-from: type=registry,ref=ghcr.io/go-gitea/gitea:buildcache-rootless
22+
needs: [files-changed]
23+
uses: ./.github/workflows/part-docker-dryrun.yml
24+
with:
25+
platform: linux/amd64
26+
27+
container-arm64:
28+
if: needs.files-changed.outputs.docker == 'true'
29+
needs: [files-changed]
30+
uses: ./.github/workflows/part-docker-dryrun.yml
31+
with:
32+
platform: linux/arm64
33+
34+
container-riscv64:
35+
if: needs.files-changed.outputs.docker == 'true'
36+
needs: [files-changed]
37+
uses: ./.github/workflows/part-docker-dryrun.yml
38+
with:
39+
platform: linux/riscv64

.github/workflows/pull-e2e-tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ jobs:
3939
- run: make deps-frontend
4040
- run: make frontend
4141
- run: make deps-backend
42-
- run: make gitea-e2e
42+
- run: make backend
43+
env:
44+
TAGS: bindata sqlite sqlite_unlock_notify
4345
- run: make playwright
4446
- run: make test-e2e
4547
timeout-minutes: 10
4648
env:
49+
TAGS: bindata sqlite sqlite_unlock_notify
4750
FORCE_COLOR: 1
4851
GITEA_TEST_E2E_DEBUG: 1

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ cpu.out
5555
*.log.*.gz
5656

5757
/gitea
58-
/gitea-e2e
59-
/gitea-vet
6058
/debug
61-
/integrations.test
6259

6360
/bin
6461
/dist
@@ -68,7 +65,6 @@ cpu.out
6865
/indexers
6966
/log
7067
/public/assets/img/avatar
71-
/tests/e2e-output
7268
/tests/integration/gitea-integration-*
7369
/tests/integration/indexers-*
7470
/tests/*.ini

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ Here's how to run the test suite:
139139

140140
- run tests (we suggest running them on Linux)
141141

142-
| Command | Action | |
143-
| :------------------------------------------ | :------------------------------------------------------- | ------------------------------------------- |
144-
|``make test[\#SpecificTestName]`` | run unit test(s) | |
145-
|``make test-sqlite[\#SpecificTestName]`` | run [integration](tests/integration) test(s) for SQLite | [More details](tests/integration/README.md) |
146-
|``make test-e2e`` | run [end-to-end](tests/e2e) test(s) using Playwright | |
142+
| Command | Action | |
143+
|:----------------------------------------------|:-----------------------------------------------------| ------------------------------------------- |
144+
| ``make test-backend[\#SpecificTestName]`` | run unit test(s) | |
145+
| ``make test-integration[\#SpecificTestName]`` | run [integration](tests/integration) test(s) | [More details](tests/integration/README.md) |
146+
| ``make test-e2e`` | run [end-to-end](tests/e2e) test(s) using Playwright | |
147147

148148
- E2E test environment variables
149149

0 commit comments

Comments
 (0)