diff --git a/.github/workflows/files-changed.yml b/.github/workflows/files-changed.yml index be27537924336..ca3831a5883f9 100644 --- a/.github/workflows/files-changed.yml +++ b/.github/workflows/files-changed.yml @@ -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@v4 - uses: dorny/paths-filter@v3 id: changes + if: ${{ vars.ACT_EXEC != 'true'}} with: filters: | backend: diff --git a/.github/workflows/pull-db-tests.yml b/.github/workflows/pull-db-tests.yml index 55c2d2bf5e30e..12812ae766b3e 100644 --- a/.github/workflows/pull-db-tests.yml +++ b/.github/workflows/pull-db-tests.yml @@ -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: diff --git a/Makefile b/Makefile index 6a3fa60e495ce..84d89bd1fabd4 100644 --- a/Makefile +++ b/Makefile @@ -428,7 +428,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."; \ diff --git a/modules/queue/base_redis_test.go b/modules/queue/base_redis_test.go index 6478988d7fd01..973b0219bb686 100644 --- a/modules/queue/base_redis_test.go +++ b/modules/queue/base_redis_test.go @@ -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) } diff --git a/tests/e2e/README.md b/tests/e2e/README.md index db083793d8b59..9955ebbc49326 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -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 diff --git a/tests/integration/README.md b/tests/integration/README.md index 3b44cfaaf06b9..4a1598031f2c8 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -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 +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 ``` 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 diff --git a/tests/integration/README_ZH.md b/tests/integration/README_ZH.md index a6768fd0f3c50..2948de42d668f 100644 --- a/tests/integration/README_ZH.md +++ b/tests/integration/README_ZH.md @@ -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 +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 ``` 您可以通过以下方式列出所有任务名称: ```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 数据库进行集成测试