From 4ec38a8606e98272b90517032ff8dfd05657a7bc Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Sun, 25 Jun 2023 00:25:03 +0000 Subject: [PATCH 01/11] adapt act_runner exec in action file Signed-off-by: a1012112796 <1012112796@qq.com> --- .github/workflows/files-changed.yml | 22 +++++++++++++++++++++- .github/workflows/pull-db-tests.yml | 2 +- modules/queue/base_redis_test.go | 4 ++-- modules/storage/minio_test.go | 2 +- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/files-changed.yml b/.github/workflows/files-changed.yml index 0d43e191a3cb7..156b61d974397 100644 --- a/.github/workflows/files-changed.yml +++ b/.github/workflows/files-changed.yml @@ -30,7 +30,8 @@ jobs: steps: - uses: actions/checkout@v3 - uses: dorny/paths-filter@v2 - id: changes + id: changes_check + if: env.ACT_EXEC != 'true' with: filters: | backend: @@ -63,3 +64,22 @@ jobs: - "Dockerfile.rootless" - "docker/**" - "Makefile" + - name: set outputs result + id: changes + run: | + if [ "$ACT_EXEC" == 'true' ]; then + # set default value for 'act_runner exec' + { echo "backend=true" ; \ + echo "frontend=true" ; \ + echo "docs=true" ; \ + echo "actions=true" ; \ + echo "templates=true" ; \ + echo "docker=true" ; } >> "$GITHUB_OUTPUT" + else + { echo "backend=${{ steps.changes_check.outputs.backend }}" ; \ + echo "frontend=${{ steps.changes_check.outputs.frontend }}" ; \ + echo "docs=${{ steps.changes_check.outputs.docs }}" ; \ + echo "actions=${{ steps.changes_check.outputs.actions }}" ; \ + echo "actions=${{ steps.changes_check.outputs.templates }}" ; \ + echo "actions=${{ steps.changes_check.outputs.docker }}" ; } >> "$GITHUB_OUTPUT" + fi diff --git a/.github/workflows/pull-db-tests.yml b/.github/workflows/pull-db-tests.yml index 12e5e64e80763..c73ad3602e5f7 100644 --- a/.github/workflows/pull-db-tests.yml +++ b/.github/workflows/pull-db-tests.yml @@ -128,7 +128,7 @@ jobs: go-version: ">=1.20" 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/modules/queue/base_redis_test.go b/modules/queue/base_redis_test.go index 19fbccbc8fe75..0df0a655462e1 100644 --- a/modules/queue/base_redis_test.go +++ b/modules/queue/base_redis_test.go @@ -54,14 +54,14 @@ 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()) - if !assert.True(t, waitRedisReady("redis://127.0.0.1:6379/0", 5*time.Second), "start redis-server") { + if !assert.True(t, waitRedisReady("redis://redis:6379/0", 5*time.Second), "start redis-server") { return } } diff --git a/modules/storage/minio_test.go b/modules/storage/minio_test.go index af392b7e2215e..8fdf31e6cf52a 100644 --- a/modules/storage/minio_test.go +++ b/modules/storage/minio_test.go @@ -17,7 +17,7 @@ func TestMinioStorageIterator(t *testing.T) { } testStorageIterator(t, setting.MinioStorageType, &setting.Storage{ MinioConfig: setting.MinioStorageConfig{ - Endpoint: "127.0.0.1:9000", + Endpoint: "minio:9000", AccessKeyID: "123456", SecretAccessKey: "12345678", Bucket: "gitea", From a49f20461bff58ff7253c427983dd8c2788ae45f Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Mon, 26 Jun 2023 16:43:21 +0000 Subject: [PATCH 02/11] fix --- modules/queue/base_redis_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/queue/base_redis_test.go b/modules/queue/base_redis_test.go index 0df0a655462e1..a09b561e7a5ce 100644 --- a/modules/queue/base_redis_test.go +++ b/modules/queue/base_redis_test.go @@ -37,7 +37,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, From fcf31008263e16c1be1d663607c107e4da40d428 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Fri, 30 Jun 2023 06:36:23 +0000 Subject: [PATCH 03/11] update Signed-off-by: a1012112796 <1012112796@qq.com> --- .github/workflows/files-changed.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/files-changed.yml b/.github/workflows/files-changed.yml index 3a8f01fc7158c..51e4e039f1482 100644 --- a/.github/workflows/files-changed.yml +++ b/.github/workflows/files-changed.yml @@ -33,9 +33,10 @@ jobs: steps: - uses: actions/checkout@v3 - uses: dorny/paths-filter@v2 - id: changes_check - if: env.ACT_EXEC != 'true' + id: changes with: + # used for `act_runner exec` + # base: HEAD filters: | backend: - "**/*.go" From 3a781c484b2fad5a6e351b1835397c16c54aa1f6 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Fri, 30 Jun 2023 08:49:08 +0000 Subject: [PATCH 04/11] fix Signed-off-by: a1012112796 <1012112796@qq.com> --- modules/queue/base_redis_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/queue/base_redis_test.go b/modules/queue/base_redis_test.go index a09b561e7a5ce..49886de6d9ee3 100644 --- a/modules/queue/base_redis_test.go +++ b/modules/queue/base_redis_test.go @@ -66,6 +66,6 @@ func TestBaseRedis(t *testing.T) { } } - 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) } From 8cb6ee587cf588f8901429c87282eafa5ca22e9a Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 20 Aug 2023 16:12:05 +0200 Subject: [PATCH 05/11] Update .github/workflows/files-changed.yml Co-authored-by: a1012112796 <1012112796@qq.com> --- .github/workflows/files-changed.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/files-changed.yml b/.github/workflows/files-changed.yml index 51e4e039f1482..7a2f5deae0b2f 100644 --- a/.github/workflows/files-changed.yml +++ b/.github/workflows/files-changed.yml @@ -35,7 +35,7 @@ jobs: - uses: dorny/paths-filter@v2 id: changes with: - # used for `act_runner exec` + # should uncomment the next line when using `act_runner exec`. # base: HEAD filters: | backend: From 1976133cb146609406d5380cc4e714b1e41aa547 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 20 Aug 2023 16:15:37 +0200 Subject: [PATCH 06/11] Update .github/workflows/files-changed.yml --- .github/workflows/files-changed.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/files-changed.yml b/.github/workflows/files-changed.yml index 7a2f5deae0b2f..de8bdff83fdc0 100644 --- a/.github/workflows/files-changed.yml +++ b/.github/workflows/files-changed.yml @@ -35,8 +35,8 @@ jobs: - uses: dorny/paths-filter@v2 id: changes with: - # should uncomment the next line when using `act_runner exec`. - # base: HEAD + # needed for `act_runner exec`, is ignored for pull_request event + base: HEAD filters: | backend: - "**/*.go" From 6c92b75adfc5aedb188cae6aa164da5afa270535 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 20 Aug 2023 16:20:05 +0200 Subject: [PATCH 07/11] Update .github/workflows/files-changed.yml --- .github/workflows/files-changed.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/files-changed.yml b/.github/workflows/files-changed.yml index de8bdff83fdc0..8319b6501650c 100644 --- a/.github/workflows/files-changed.yml +++ b/.github/workflows/files-changed.yml @@ -36,7 +36,7 @@ jobs: id: changes with: # needed for `act_runner exec`, is ignored for pull_request event - base: HEAD + # base: HEAD filters: | backend: - "**/*.go" From 80ae79c0613d0080261a13b9f4f9eaa6aeb4eae0 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 20 Aug 2023 16:28:42 +0200 Subject: [PATCH 08/11] try with ref option --- .github/workflows/files-changed.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/files-changed.yml b/.github/workflows/files-changed.yml index 8319b6501650c..80f968d977d86 100644 --- a/.github/workflows/files-changed.yml +++ b/.github/workflows/files-changed.yml @@ -35,8 +35,8 @@ jobs: - uses: dorny/paths-filter@v2 id: changes with: - # needed for `act_runner exec`, is ignored for pull_request event - # base: HEAD + # needed for `act_runner exec` + ref: ${{ env.ACT_EXEC == 'true' && 'HEAD' || env.GITHUB_REF }} filters: | backend: - "**/*.go" From f3423d05a5d5fbcaeb196841087833b476fb9e41 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Mon, 21 Aug 2023 03:33:41 +0000 Subject: [PATCH 09/11] skip `test-check` for `act_exec` also, and try new option Signed-off-by: a1012112796 <1012112796@qq.com> --- .github/workflows/files-changed.yml | 2 +- Makefile | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/files-changed.yml b/.github/workflows/files-changed.yml index 80f968d977d86..0447d4b8835aa 100644 --- a/.github/workflows/files-changed.yml +++ b/.github/workflows/files-changed.yml @@ -36,7 +36,7 @@ jobs: id: changes with: # needed for `act_runner exec` - ref: ${{ env.ACT_EXEC == 'true' && 'HEAD' || env.GITHUB_REF }} + base: ${{ env.ACT_EXEC == 'true' && 'HEAD' || '' }} filters: | backend: - "**/*.go" diff --git a/Makefile b/Makefile index 167f56c6b9266..90debf0c09555 100644 --- a/Makefile +++ b/Makefile @@ -456,7 +456,10 @@ test-frontend: node_modules 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:"; \ echo "$${diff}"; \ echo "You should change the tests to create these files in a temporary directory."; \ From 50ba3580fd0c0970d3e7dc6da10941f5b8d9aa3a Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 21 Aug 2023 16:35:26 +0200 Subject: [PATCH 10/11] Update .github/workflows/files-changed.yml --- .github/workflows/files-changed.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/files-changed.yml b/.github/workflows/files-changed.yml index 0447d4b8835aa..68099c799dd33 100644 --- a/.github/workflows/files-changed.yml +++ b/.github/workflows/files-changed.yml @@ -36,7 +36,8 @@ jobs: id: changes with: # needed for `act_runner exec` - base: ${{ env.ACT_EXEC == 'true' && 'HEAD' || '' }} + base: main + ref: ${{ env.ACT_EXEC == 'true' && 'HEAD' || env.GITHUB_REF }} filters: | backend: - "**/*.go" From 764d20eb0d276b9f99975f69420b084e8c49663b Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Sat, 5 Jul 2025 18:46:13 +0800 Subject: [PATCH 11/11] using var for lint adapt Signed-off-by: a1012112796 <1012112796@qq.com> --- .github/workflows/files-changed.yml | 20 +++++++++----------- .github/workflows/pull-db-tests.yml | 2 +- tests/e2e/README.md | 2 +- tests/integration/README.md | 6 +++--- tests/integration/README_ZH.md | 6 +++--- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.github/workflows/files-changed.yml b/.github/workflows/files-changed.yml index f4326845de56b..ca3831a5883f9 100644 --- a/.github/workflows/files-changed.yml +++ b/.github/workflows/files-changed.yml @@ -25,22 +25,20 @@ 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: - # needed for `act_runner exec` - base: main - ref: ${{ env.ACT_EXEC == 'true' && 'HEAD' || env.GITHUB_REF }} filters: | backend: - "**/*.go" 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/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 数据库进行集成测试