Skip to content

ci: fix test workflow #3

ci: fix test workflow

ci: fix test workflow #3

Workflow file for this run

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 Some Configurations
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 --scan
- name: Test with Gradle
run: ./gradlew test --no-daemon --warning-mode all
- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-results
path: build/test-results