56 lines
1.2 KiB
YAML
56 lines
1.2 KiB
YAML
name: CI Build and Test
|
||
|
||
# 触发条件:推送到 main 分支或创建 Pull Request
|
||
on:
|
||
push:
|
||
branches: [ main, master ]
|
||
pull_request:
|
||
branches: [ main, master ]
|
||
|
||
jobs:
|
||
build:
|
||
runs-on: ubuntu-latest
|
||
|
||
steps:
|
||
# 1. 检出代码
|
||
- name: 检出代码
|
||
uses: actions/checkout@v3
|
||
|
||
# 2. 设置 Java 环境
|
||
- name: 设置 Java 8
|
||
uses: actions/setup-java@v3
|
||
with:
|
||
java-version: '8'
|
||
distribution: 'temurin'
|
||
cache: 'gradle'
|
||
|
||
# 3. 赋予 Gradle wrapper 执行权限
|
||
- name: 赋予 Gradle wrapper 执行权限
|
||
run: chmod +x gradlew
|
||
|
||
# 4. 构建项目(跳过测试)
|
||
- name: 使用 Gradle 构建项目
|
||
run: ./gradlew build -x test
|
||
|
||
# 5. 运行测试
|
||
- name: 运行测试
|
||
run: ./gradlew test
|
||
|
||
# 6. 上传构建产物(JAR 文件)
|
||
- name: 上传 JAR 包
|
||
uses: actions/upload-artifact@v3
|
||
if: success()
|
||
with:
|
||
name: corewing-app
|
||
path: build/libs/*.jar
|
||
retention-days: 7
|
||
|
||
# 7. 上传测试报告
|
||
- name: 上传测试报告
|
||
uses: actions/upload-artifact@v3
|
||
if: always()
|
||
with:
|
||
name: test-reports
|
||
path: build/reports/tests/
|
||
retention-days: 7
|