diff --git a/.github/workflows/assembly-generate.yml b/.github/workflows/assembly-generate.yml new file mode 100644 index 0000000..424abfa --- /dev/null +++ b/.github/workflows/assembly-generate.yml @@ -0,0 +1,28 @@ +name: assembly-run.yml +on: [workflow_call] +jobs: + build: + uses: ./.github/workflows/build.yml + assembly: + needs: [build] + 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 with SBT" + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + cache: sbt + - name: "Generate assembly jar" + run: sbt assembly + - name: "Publish assembly jar" + uses: actions/upload-artifact@v4 + with: + name: 'assembly-jar' + path: ./morny-coeur/target/*-assembly-*.jar diff --git a/.github/workflows/assembly-run.yml b/.github/workflows/assembly-run.yml new file mode 100644 index 0000000..62a7197 --- /dev/null +++ b/.github/workflows/assembly-run.yml @@ -0,0 +1,33 @@ +name: assembly-run.yml +on: [workflow_call] +jobs: + generate-assembly: + uses: ./.github/workflows/assembly-generate.yml + run-assembly: + needs: [generate-assembly] + runs-on: ubuntu-latest + steps: + - name: "Setup assembly jar from artifacts" + uses: actions/download-artifact@v4 + with: + name: 'assembly-jar' + 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 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f8df18c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,32 @@ +name: "Build" +run-name: "Build projects to ensure compiling is successful" +on: [workflow_call] +jobs: + compile: + 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 with SBT" + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + cache: sbt + - if: steps.check-cache.outputs.cache-hit != 'true' + name: "Compile Project" + run: sbt compile + - 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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e335172 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,11 @@ +name: Tests +on: [push] +jobs: + check-build: + uses: ./.github/workflows/build.yml + check-unit-tests: + needs: [check-build] + uses: ./.github/workflows/unit-test.yml + check-assembly-run: + needs: [check-build] + uses: ./.github/workflows/assembly-run.yml diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 0000000..1b19455 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,39 @@ +name: "Unit Test" +run-name: "Test projects using Unit Test framework to ensure code quality" +on: [workflow_call] +jobs: + build: + uses: ./.github/workflows/build.yml + unit-test: + needs: [build] + 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 with SBT" + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + cache: sbt + - name: "Run unit tests" + id: do-unit-test + run: sbt test + - name: "Upload test reports as artifact" + if: steps.do-unit-test.conclusion == 'failure' || steps.do-unit-test.conclusion == 'success' + uses: actions/upload-artifact@v4 + with: + name: 'unit-test-report' + path: ./*/target/test-reports/* + - name: "Publish test report to summary" + if: steps.do-unit-test.conclusion == 'failure' || steps.do-unit-test.conclusion == 'success' + uses: phoenix-actions/test-reporting@v15 + with: + output-to: 'step-summary' + name: 'Unit Tests Report' + path: ./*/target/test-reports/*.xml + reporter: 'java-junit'