add gitub ci support for gradle version (1.x) branch (#58)

This commit is contained in:
A.C.Sukazyo Eyre 2025-05-01 23:01:06 +08:00 committed by GitHub
parent e4853239bd
commit 7ad5ff2311
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 181 additions and 0 deletions

29
.github/workflows/assembly-build.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: "Build Assembly Jar"
on: [workflow_call]
jobs:
assembly:
name: "Build assembly jar"
runs-on: ubuntu-latest
steps:
- name: "Setup cached built project"
uses: actions/cache/restore@v4
with:
path: "./"
key: ${{ runner.os }}-build-${{ github.sha }}
fail-on-cache-miss: 'true'
- name: "Setup Java 21"
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
# - if: steps.check-cache.outputs.cache-hit != 'true'
# name: "Setup Gradle"
# uses: gradle/actions/setup-gradle@v4
- name: "Generate assembly jar"
run: ./gradlew shadowJar --no-daemon
- name: "Publish assembly jar"
uses: actions/upload-artifact@v4
with:
name: 'assembly'
path: ./build/libs/*-fat.jar

36
.github/workflows/assembly-run.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: "Assembly Jar Test Run"
run-name: "Run assembly jar to ensure the target jar can actually runs"
on: [workflow_call]
jobs:
generate-assembly:
name: "Build assembly jar"
uses: ./.github/workflows/assembly-build.yml
run-assembly:
name: "Test run assembly jar"
needs: [generate-assembly]
runs-on: ubuntu-latest
steps:
- name: "Setup assembly jar from artifacts"
uses: actions/download-artifact@v4
with:
name: 'assembly'
path: ./assembles/
- name: "Setup Java 21"
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: "Run assembly jar"
id: assembly-run
shell: bash
run: |
exec 5>&1
outputs=$(java -jar ./assembles/*.jar -q -v | tee >(cat - >&5))
echo '# Assembly Jar Runs' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
echo 'The execution result while running assembly jar:' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$outputs" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

36
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: "Build"
run-name: "Build projects to ensure compiling is successful"
on: [workflow_call]
jobs:
compile:
name: "Compile Project"
runs-on: ubuntu-latest
steps:
- name: "Check if there's already have cache"
id: check-cache
uses: actions/cache/restore@v4
with:
path: "./"
key: ${{ runner.os }}-build-${{ github.sha }}
lookup-only: 'true'
- if: steps.check-cache.outputs.cache-hit != 'true'
uses: actions/checkout@v4
- if: steps.check-cache.outputs.cache-hit != 'true'
name: "Setup Java 21"
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
# - if: steps.check-cache.outputs.cache-hit != 'true'
# name: "Setup Gradle"
# uses: gradle/actions/setup-gradle@v4
- if: steps.check-cache.outputs.cache-hit != 'true'
name: "Compile Project"
run: ./gradlew classes --no-daemon
- if: steps.check-cache.outputs.cache-hit != 'true'
name: "Cache the built project"
uses: actions/cache/save@v4
with:
path: "./"
key: ${{ runner.os }}-build-${{ github.sha }}

66
.github/workflows/unit-test.yml vendored Normal file
View File

@ -0,0 +1,66 @@
name: "Unit Test"
run-name: "Test projects using Unit Test framework to ensure code quality and API stability"
on: [workflow_call]
jobs:
build-tests:
name: "Build project tests"
runs-on: ubuntu-latest
steps:
- name: "Setup cached built project"
uses: actions/cache/restore@v4
with:
path: "./"
key: ${{ runner.os }}-build-${{ github.sha }}
fail-on-cache-miss: 'true'
- name: "Setup Java 21"
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
# - if: steps.check-cache.outputs.cache-hit != 'true'
# name: "Setup Gradle"
# uses: gradle/actions/setup-gradle@v4
- name: "Compile unit tests"
run: ./gradlew testClasses --no-daemon
- name: "Cache compiled unit tests"
uses: actions/cache/save@v4
with:
path: "./"
key: ${{ runner.os }}-build-${{ github.sha }}-withTests
unit-tests-run:
name: "Run unit tests"
needs: [build-tests]
runs-on: ubuntu-latest
steps:
- name: "Setup cached built project"
uses: actions/cache/restore@v4
with:
path: "./"
key: ${{ runner.os }}-build-${{ github.sha }}-withTests
fail-on-cache-miss: 'true'
- name: "Setup Java 21"
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
# - if: steps.check-cache.outputs.cache-hit != 'true'
# name: "Setup Gradle"
# uses: gradle/actions/setup-gradle@v4
- name: "Run unit tests"
continue-on-error: true
run: ./gradlew test --no-daemon
- name: "Upload test reports as artifact"
uses: actions/upload-artifact@v4
continue-on-error: true
with:
name: 'unit-test-report'
path: ./build/test-results/test/*
- name: "Publish test report to summary"
uses: phoenix-actions/test-reporting@v15
with:
output-to: 'step-summary'
name: 'Unit Tests Report'
path: ./build/test-results/test/*.xml
reporter: 'java-junit'

14
.github/workflows/work_test.yml vendored Normal file
View File

@ -0,0 +1,14 @@
name: "Project Test"
on: [push]
jobs:
check-build:
name: "Do project compile"
uses: ./.github/workflows/build.yml
check-unit-tests:
name: "Do unit tests"
needs: [check-build]
uses: ./.github/workflows/unit-test.yml
check-assembly-run:
name: "Generate and test run assembly"
needs: [check-build]
uses: ./.github/workflows/assembly-run.yml