feat(环境): 使用 package 替换单元测试 #35
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: Checker | |
on: | |
push: | |
pull_request: | |
branches: [ "dev" ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java: [ '8', '11', '17' ] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK ${{ matrix.java }} | |
uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ matrix.java }} | |
distribution: 'temurin' | |
cache: maven | |
- name: Check Code Style | |
run: ./mvnw checkstyle:check | |
- name: Check Spotbugs | |
run: ./mvnw spotbugs:check | |
- name: Build with Maven | |
run: ./mvnw -B clean package | |
# 收集所有模块的测试报告 | |
- name: Publish Test Results | |
uses: dorny/test-reporter@v1 | |
if: always() | |
with: | |
name: JUnit Tests (${{ matrix.java }}) | |
path: '**/target/surefire-reports/TEST-*.xml' | |
reporter: java-junit | |
fail-on-error: false | |
# 上传所有模块的测试结果 | |
- name: Upload Test Results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-results-${{ matrix.java }} | |
path: | | |
**/target/surefire-reports/ | |
**/target/site/surefire-report.html | |
# 收集所有模块的覆盖率报告 | |
- name: Generate Test Coverage Report | |
run: ./mvnw -B jacoco:report | |
- name: Upload Coverage Report | |
if: matrix.java == '8' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: | | |
**/target/site/jacoco/ | |
**/target/site/jacoco/jacoco.xml | |
- name: Report Coverage to Codecov | |
if: matrix.java == '8' | |
uses: codecov/codecov-action@v3 | |
with: | |
files: '**/target/site/jacoco/jacoco.xml' | |
dependency-check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '8' | |
distribution: 'temurin' | |
cache: maven | |
- name: Run Dependency Check | |
run: ./mvnw org.owasp:dependency-check-maven:check | |
- name: Upload Dependency Check Results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dependency-check-report | |
path: '**/target/dependency-check-report.html' |