Refactor Redis and MongoDB setup in workflows
- Replace `supercharge/redis-github-action` with a direct Docker command to start Redis in both `pr-test.yml` and `unit-test.yml`, improving control over the Redis instance. - Update MongoDB setup to use a Docker command with environment variables for initialization and include a readiness check to ensure MongoDB is fully operational before proceeding.
This commit is contained in:
parent
b7d026deb1
commit
b9cff8e049
2 changed files with 42 additions and 48 deletions
45
.github/workflows/pr-test.yml
vendored
45
.github/workflows/pr-test.yml
vendored
|
|
@ -321,9 +321,7 @@ jobs:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: Start Redis
|
- name: Start Redis
|
||||||
uses: supercharge/redis-github-action@1.8.0
|
run: docker run --name redis --publish 6379:6379 --detach redis:6
|
||||||
with:
|
|
||||||
redis-version: 6
|
|
||||||
|
|
||||||
- name: Setup Go Tools
|
- name: Setup Go Tools
|
||||||
run: make tools
|
run: make tools
|
||||||
|
|
@ -518,9 +516,7 @@ jobs:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: Start Redis
|
- name: Start Redis
|
||||||
uses: supercharge/redis-github-action@1.8.0
|
run: docker run --name redis --publish 6379:6379 --detach redis:6
|
||||||
with:
|
|
||||||
redis-version: 6
|
|
||||||
|
|
||||||
- name: Setup Go Tools
|
- name: Setup Go Tools
|
||||||
run: make tools
|
run: make tools
|
||||||
|
|
@ -712,9 +708,7 @@ jobs:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: Start Redis
|
- name: Start Redis
|
||||||
uses: supercharge/redis-github-action@1.8.0
|
run: docker run --name redis --publish 6379:6379 --detach redis:6
|
||||||
with:
|
|
||||||
redis-version: 6
|
|
||||||
|
|
||||||
- name: Setup Go Tools
|
- name: Setup Go Tools
|
||||||
run: make tools
|
run: make tools
|
||||||
|
|
@ -878,9 +872,7 @@ jobs:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: Start Redis
|
- name: Start Redis
|
||||||
uses: supercharge/redis-github-action@1.8.0
|
run: docker run --name redis --publish 6379:6379 --detach redis:6
|
||||||
with:
|
|
||||||
redis-version: 6
|
|
||||||
|
|
||||||
- name: Setup Go Tools
|
- name: Setup Go Tools
|
||||||
run: make tools
|
run: make tools
|
||||||
|
|
@ -1049,9 +1041,7 @@ jobs:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: Start Redis
|
- name: Start Redis
|
||||||
uses: supercharge/redis-github-action@1.8.0
|
run: docker run --name redis --publish 6379:6379 --detach redis:6
|
||||||
with:
|
|
||||||
redis-version: 6
|
|
||||||
|
|
||||||
- name: Setup Go Tools
|
- name: Setup Go Tools
|
||||||
run: make tools
|
run: make tools
|
||||||
|
|
@ -1245,9 +1235,7 @@ jobs:
|
||||||
echo "${{ secrets.APPLE_PRIVATE_KEY_USER }}" > ../app/openapi/certs/apple/signin_client_secret_key.p8
|
echo "${{ secrets.APPLE_PRIVATE_KEY_USER }}" > ../app/openapi/certs/apple/signin_client_secret_key.p8
|
||||||
|
|
||||||
- name: Start Redis
|
- name: Start Redis
|
||||||
uses: supercharge/redis-github-action@1.8.0
|
run: docker run --name redis --publish 6379:6379 --detach redis:${{ matrix.redis }}
|
||||||
with:
|
|
||||||
redis-version: ${{ matrix.redis }}
|
|
||||||
|
|
||||||
- name: Setup Go ${{ matrix.go }}
|
- name: Setup Go ${{ matrix.go }}
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
|
|
@ -1277,12 +1265,21 @@ jobs:
|
||||||
convert -version
|
convert -version
|
||||||
|
|
||||||
- name: Start MongoDB
|
- name: Start MongoDB
|
||||||
uses: supercharge/mongodb-github-action@1.11.0
|
run: |
|
||||||
with:
|
docker run --name mongodb --publish 27017:27017 \
|
||||||
mongodb-version: ${{ matrix.mongo }}
|
-e MONGO_INITDB_DATABASE=test \
|
||||||
mongodb-username: root
|
-e MONGO_INITDB_ROOT_USERNAME=root \
|
||||||
mongodb-password: 123456
|
-e MONGO_INITDB_ROOT_PASSWORD=123456 \
|
||||||
mongodb-db: test
|
--detach mongo:${{ matrix.mongo }}
|
||||||
|
# Wait for MongoDB to be ready
|
||||||
|
for i in $(seq 1 20); do
|
||||||
|
if docker exec mongodb mongosh --quiet --port 27017 --username root --password 123456 --eval "db.serverStatus()" > /dev/null 2>&1; then
|
||||||
|
echo "MongoDB is ready"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "Waiting for MongoDB... ($i)"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
- name: Setup MySQL8.0 (connector)
|
- name: Setup MySQL8.0 (connector)
|
||||||
uses: ./.github/actions/setup-db
|
uses: ./.github/actions/setup-db
|
||||||
|
|
|
||||||
45
.github/workflows/unit-test.yml
vendored
45
.github/workflows/unit-test.yml
vendored
|
|
@ -277,9 +277,7 @@ jobs:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: Start Redis
|
- name: Start Redis
|
||||||
uses: supercharge/redis-github-action@1.8.0
|
run: docker run --name redis --publish 6379:6379 --detach redis:6
|
||||||
with:
|
|
||||||
redis-version: 6
|
|
||||||
|
|
||||||
- name: Setup Go Tools
|
- name: Setup Go Tools
|
||||||
run: make tools
|
run: make tools
|
||||||
|
|
@ -412,9 +410,7 @@ jobs:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: Start Redis
|
- name: Start Redis
|
||||||
uses: supercharge/redis-github-action@1.8.0
|
run: docker run --name redis --publish 6379:6379 --detach redis:6
|
||||||
with:
|
|
||||||
redis-version: 6
|
|
||||||
|
|
||||||
- name: Setup Go Tools
|
- name: Setup Go Tools
|
||||||
run: make tools
|
run: make tools
|
||||||
|
|
@ -544,9 +540,7 @@ jobs:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: Start Redis
|
- name: Start Redis
|
||||||
uses: supercharge/redis-github-action@1.8.0
|
run: docker run --name redis --publish 6379:6379 --detach redis:6
|
||||||
with:
|
|
||||||
redis-version: 6
|
|
||||||
|
|
||||||
- name: Setup Go Tools
|
- name: Setup Go Tools
|
||||||
run: make tools
|
run: make tools
|
||||||
|
|
@ -648,9 +642,7 @@ jobs:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: Start Redis
|
- name: Start Redis
|
||||||
uses: supercharge/redis-github-action@1.8.0
|
run: docker run --name redis --publish 6379:6379 --detach redis:6
|
||||||
with:
|
|
||||||
redis-version: 6
|
|
||||||
|
|
||||||
- name: Setup Go Tools
|
- name: Setup Go Tools
|
||||||
run: make tools
|
run: make tools
|
||||||
|
|
@ -771,9 +763,7 @@ jobs:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: Start Redis
|
- name: Start Redis
|
||||||
uses: supercharge/redis-github-action@1.8.0
|
run: docker run --name redis --publish 6379:6379 --detach redis:6
|
||||||
with:
|
|
||||||
redis-version: 6
|
|
||||||
|
|
||||||
- name: Setup Go Tools
|
- name: Setup Go Tools
|
||||||
run: make tools
|
run: make tools
|
||||||
|
|
@ -944,17 +934,24 @@ jobs:
|
||||||
convert -version
|
convert -version
|
||||||
|
|
||||||
- name: Start Redis
|
- name: Start Redis
|
||||||
uses: supercharge/redis-github-action@1.8.0
|
run: docker run --name redis --publish 6379:6379 --detach redis:${{ matrix.redis }}
|
||||||
with:
|
|
||||||
redis-version: ${{ matrix.redis }}
|
|
||||||
|
|
||||||
- name: Start MongoDB
|
- name: Start MongoDB
|
||||||
uses: supercharge/mongodb-github-action@1.11.0
|
run: |
|
||||||
with:
|
docker run --name mongodb --publish 27017:27017 \
|
||||||
mongodb-version: ${{ matrix.mongo }}
|
-e MONGO_INITDB_DATABASE=test \
|
||||||
mongodb-username: root
|
-e MONGO_INITDB_ROOT_USERNAME=root \
|
||||||
mongodb-password: 123456
|
-e MONGO_INITDB_ROOT_PASSWORD=123456 \
|
||||||
mongodb-db: test
|
--detach mongo:${{ matrix.mongo }}
|
||||||
|
# Wait for MongoDB to be ready
|
||||||
|
for i in $(seq 1 20); do
|
||||||
|
if docker exec mongodb mongosh --quiet --port 27017 --username root --password 123456 --eval "db.serverStatus()" > /dev/null 2>&1; then
|
||||||
|
echo "MongoDB is ready"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "Waiting for MongoDB... ($i)"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
- name: Setup MySQL8.0 (connector)
|
- name: Setup MySQL8.0 (connector)
|
||||||
uses: ./.github/actions/setup-db
|
uses: ./.github/actions/setup-db
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue