0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-11-02 00:27:24 +01:00

Merge 09b854a4f7d0d11477052f7403a8f93f787bd27f into 3ab8ae5807775a81069005a5abbd20bacfa0a15f

This commit is contained in:
a1012112796 2025-10-30 10:28:12 +08:00 committed by GitHub
commit 4c5506d879
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 26 additions and 22 deletions

View File

@ -25,18 +25,19 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 3
outputs:
backend: ${{ steps.changes.outputs.backend }}
frontend: ${{ steps.changes.outputs.frontend }}
docs: ${{ steps.changes.outputs.docs }}
actions: ${{ steps.changes.outputs.actions }}
templates: ${{ steps.changes.outputs.templates }}
docker: ${{ steps.changes.outputs.docker }}
swagger: ${{ steps.changes.outputs.swagger }}
yaml: ${{ steps.changes.outputs.yaml }}
backend: ${{ vars.ACT_EXEC == 'true' && true || steps.changes.outputs.backend }}
frontend: ${{ vars.ACT_EXEC == 'true' && true || steps.changes.outputs.frontend }}
docs: ${{ vars.ACT_EXEC == 'true' && true || steps.changes.outputs.docs }}
actions: ${{ vars.ACT_EXEC == 'true' && true || steps.changes.outputs.actions }}
templates: ${{ vars.ACT_EXEC == 'true' && true || steps.changes.outputs.templates }}
docker: ${{ vars.ACT_EXEC == 'true' && true || steps.changes.outputs.docker }}
swagger: ${{ vars.ACT_EXEC == 'true' && true || steps.changes.outputs.swagger }}
yaml: ${{ vars.ACT_EXEC == 'true' && true || steps.changes.outputs.yaml }}
steps:
- uses: actions/checkout@v5
- uses: dorny/paths-filter@v3
id: changes
if: ${{ vars.ACT_EXEC != 'true'}}
with:
filters: |
backend:

View File

@ -183,7 +183,7 @@ jobs:
go-version-file: go.mod
check-latest: true
- 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: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mysql elasticsearch smtpimap redis minio" | sudo tee -a /etc/hosts'
- run: make deps-backend
- run: make backend
env:

View File

@ -455,7 +455,10 @@ test-frontend: node_modules ## test frontend files
test-check:
@echo "Running test-check...";
@diff=$$(git status -s); \
if [ -n "$$diff" ]; then \
if [ "$(ACT_EXEC)" = "true" ]; then \
echo "skip 'test-check' when using 'act_runner exec', please check it manually!"; \
exit 0; \
elif [ -n "$$diff" ]; then \
echo "make test-backend has changed files in the source tree:"; \
printf "%s" "$${diff}"; \
echo "You should change the tests to create these files in a temporary directory."; \

View File

@ -38,7 +38,7 @@ func redisServerCmd(t *testing.T) *exec.Cmd {
}
c := &exec.Cmd{
Path: redisServerProg,
Args: []string{redisServerProg, "--bind", "127.0.0.1", "--port", "6379"},
Args: []string{redisServerProg, "--bind", "redis", "--port", "6379"},
Dir: t.TempDir(),
Stdin: os.Stdin,
Stdout: os.Stdout,
@ -55,16 +55,16 @@ func TestBaseRedis(t *testing.T) {
_ = redisServer.Wait()
}
}()
if !waitRedisReady("redis://127.0.0.1:6379/0", 0) {
if !waitRedisReady("redis://redis:6379/0", 0) {
redisServer = redisServerCmd(t)
if redisServer == nil && os.Getenv("CI") == "" {
t.Skip("redis-server not found")
return
}
assert.NoError(t, redisServer.Start())
require.True(t, waitRedisReady("redis://127.0.0.1:6379/0", 5*time.Second), "start redis-server")
require.True(t, waitRedisReady("redis://redis:6379/0", 5*time.Second), "start redis-server")
}
testQueueBasic(t, newBaseRedisSimple, toBaseConfig("baseRedis", setting.QueueSettings{Length: 10}), false)
testQueueBasic(t, newBaseRedisUnique, toBaseConfig("baseRedisUnique", setting.QueueSettings{Length: 10}), true)
testQueueBasic(t, newBaseRedisSimple, toBaseConfig("baseRedis", setting.QueueSettings{Length: 10, ConnStr: "redis://redis:6379/0"}), false)
testQueueBasic(t, newBaseRedisUnique, toBaseConfig("baseRedisUnique", setting.QueueSettings{Length: 10, ConnStr: "redis://redis:6379/0"}), true)
}

View File

@ -23,7 +23,7 @@ npx playwright install-deps
## Run all tests via local act_runner
```
act_runner exec -W ./.github/workflows/pull-e2e-tests.yml --event=pull_request --default-actions-url="https://github.com" -i catthehacker/ubuntu:runner-latest
act_runner exec -W ./.github/workflows/pull-e2e-tests.yml --event=pull_request --default-actions-url="https://github.com" --var ACT_EXEC=true -i catthehacker/ubuntu:runner-latest
```
## Run sqlite e2e tests

View File

@ -19,7 +19,7 @@ make clean build
### Run all jobs
```
act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" -i catthehacker/ubuntu:runner-latest
act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" --var ACT_EXEC=true -i catthehacker/ubuntu:runner-latest
```
Warning: This file defines many jobs, so it will be resource-intensive and therefor not recommended.
@ -27,13 +27,13 @@ Warning: This file defines many jobs, so it will be resource-intensive and there
### Run single job
```SHELL
act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" -i catthehacker/ubuntu:runner-latest -j <job_name>
act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" --var ACT_EXEC=true -i catthehacker/ubuntu:runner-latest -j <job_name>
```
You can list all job names via:
```SHELL
act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" -i catthehacker/ubuntu:runner-latest -l
act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" --var ACT_EXEC=true -i catthehacker/ubuntu:runner-latest -l
```
## Run sqlite integration tests

View File

@ -17,7 +17,7 @@ make clean build
### 运行所有任务
```
act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" -i catthehacker/ubuntu:runner-latest
act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" --var ACT_EXEC=true -i catthehacker/ubuntu:runner-latest
```
警告:由于在此文件中定义了许多任务因此此操作将花费太多的CPU和内存来运行。所以不建议这样做。
@ -25,12 +25,12 @@ act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --
### 运行单个任务
```SHELL
act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" -i catthehacker/ubuntu:runner-latest -j <job_name>
act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" --var ACT_EXEC=true -i catthehacker/ubuntu:runner-latest -j <job_name>
```
您可以通过以下方式列出所有任务名称:
```SHELL
act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" -i catthehacker/ubuntu:runner-latest -l
act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" --var ACT_EXEC=true -i catthehacker/ubuntu:runner-latest -l
```
## 如何使用 sqlite 数据库进行集成测试