ci: fix test workflow #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Spring Boot Test | |
on: [ push, pull_request ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'liberica' | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
# 在 GitHub Actions 时使用官方源 | |
# 将 Redis 的 host 替换为 127.0.0.1 | |
- name: Replace Gradle Wrapper Distribution Url | |
run: | | |
sed -i 's#mirrors.cloud.tencent.com/gradle#services.gradle.org/distributions#g' gradle/wrapper/gradle-wrapper.properties | |
sed -i 's#host: redis#host: 127.0.0.1#' src/main/resources/application-test.yaml | |
- name: Cache Gradle packages | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: "${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}" | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Build with Gradle | |
run: ./gradlew build --no-daemon -x test --warning-mode all | |
- name: Test with Gradle | |
run: ./gradlew test --no-daemon --warning-mode all |