Skip to content

adapt act_runner exec in action file #25524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .github/workflows/files-changed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-db-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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."; \
Expand Down
10 changes: 5 additions & 5 deletions modules/queue/base_redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
}
2 changes: 1 addition & 1 deletion tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ 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.

### 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
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ 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和内存来运行。所以不建议这样做。

### 运行单个任务

```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 数据库进行集成测试
Expand Down
Loading