mirror of
https://gitee.com/pnoker/iot-dc3.git
synced 2026-10-31 18:21:58 +08:00
147 lines
3.6 KiB
YAML
147 lines
3.6 KiB
YAML
name: Test
|
|
|
|
on:
|
|
push:
|
|
branches: [ develop, main ]
|
|
pull_request:
|
|
branches: [ develop, main ]
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: read
|
|
|
|
concurrency:
|
|
group: test-${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
unit:
|
|
name: Unit tests
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 45
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up JDK 21
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: liberica
|
|
java-version: 21
|
|
cache: maven
|
|
cache-dependency-path: "**/pom.xml"
|
|
|
|
- name: Run unit tests
|
|
run: |
|
|
set -euo pipefail
|
|
mvn -U -e -B -Dskip.integration.tests=true test --no-transfer-progress
|
|
|
|
- name: Upload surefire reports
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: surefire-reports
|
|
path: '**/target/surefire-reports/'
|
|
if-no-files-found: ignore
|
|
retention-days: 7
|
|
|
|
- name: Upload jacoco unit data
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: jacoco-unit-exec
|
|
path: '**/target/jacoco.exec'
|
|
if-no-files-found: ignore
|
|
retention-days: 7
|
|
|
|
integration:
|
|
name: Integration tests
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up JDK 21
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: liberica
|
|
java-version: 21
|
|
cache: maven
|
|
cache-dependency-path: "**/pom.xml"
|
|
|
|
- name: Verify docker availability
|
|
run: |
|
|
docker version
|
|
docker info
|
|
|
|
- name: Run integration tests
|
|
env:
|
|
TESTCONTAINERS_REUSE_ENABLE: "true"
|
|
run: |
|
|
set -euo pipefail
|
|
mvn -U -e -B -Dskip.unit.tests=true verify --no-transfer-progress
|
|
|
|
- name: Upload failsafe reports
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: failsafe-reports
|
|
path: '**/target/failsafe-reports/'
|
|
if-no-files-found: ignore
|
|
retention-days: 7
|
|
|
|
- name: Upload jacoco integration data
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: jacoco-it-exec
|
|
path: '**/target/jacoco-it.exec'
|
|
if-no-files-found: ignore
|
|
retention-days: 7
|
|
|
|
coverage:
|
|
name: Aggregated coverage
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
needs:
|
|
- unit
|
|
- integration
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up JDK 21
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: liberica
|
|
java-version: 21
|
|
cache: maven
|
|
cache-dependency-path: "**/pom.xml"
|
|
|
|
- name: Download unit jacoco data
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: jacoco-unit-exec
|
|
path: ./
|
|
|
|
- name: Download integration jacoco data
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: jacoco-it-exec
|
|
path: ./
|
|
|
|
- name: Build aggregate coverage report
|
|
run: |
|
|
set -euo pipefail
|
|
mvn -U -e -B -pl dc3-coverage -am -Dskip.unit.tests=true -Dskip.integration.tests=true verify --no-transfer-progress
|
|
|
|
- name: Upload aggregate report
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: jacoco-aggregate
|
|
path: dc3-coverage/target/site/jacoco-aggregate/
|
|
if-no-files-found: ignore
|
|
retention-days: 14
|