diff --git a/.github/actions/publish-report/action.yml b/.github/actions/publish-report/action.yml new file mode 100644 index 0000000..a5811e4 --- /dev/null +++ b/.github/actions/publish-report/action.yml @@ -0,0 +1,35 @@ +name: Publish JUnit Report (Short Names) +description: Normalize JUnit XML report names and publish a summary-only test report. +inputs: + token: + description: GitHub token for creating the check run. + required: true + report-name: + description: Name shown for the test report. + required: false + default: Summary of JUnit Tests + +runs: + using: composite + steps: + - name: Normalize JUnit report names + shell: bash + run: | + mkdir -p junit-short + shopt -s globstar nullglob + for f in **/target/*-reports/TEST-*.xml; do + base="$(basename "$f")" + short="${base#TEST-}" + short="${short%.xml}" + cp "$f" "junit-short/${short}" + done + + - name: Publish Test Report + uses: dorny/test-reporter@v2 + with: + token: ${{ inputs.token }} + name: ${{ inputs.report-name }} + path: "*" + reporter: java-junit + only-summary: true + working-directory: "junit-short" diff --git a/.github/actions/setup-java-maven/action.yml b/.github/actions/setup-java-maven/action.yml new file mode 100644 index 0000000..06dbe9f --- /dev/null +++ b/.github/actions/setup-java-maven/action.yml @@ -0,0 +1,43 @@ +name: "Setup Maven with GitHub Packages" + +description: "Sets up JDK, caches Maven dependencies, and configures GitHub Packages for Maven repositories." + +inputs: + java-version: + description: "Java version to install" + default: "17" + required: true + java-distribution: + description: "Java distribution to use" + default: "corretto" + +runs: + using: "composite" + steps: + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: ${{ inputs.java-distribution }} + java-version: ${{ inputs.java-version }} + + - name: Cache Maven Repository + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Set up Maven with GitHub Packages + run: | + echo " + + + github-cloudflaredns + th-schwarz + ${{ secrets.GITHUB_TOKEN }} + + + " > ~/.m2/settings.xml + shell: + bash \ No newline at end of file diff --git a/.github/workflow/build-and-analyse.yml b/.github/workflow/build-and-analyse.yml new file mode 100644 index 0000000..c9598a6 --- /dev/null +++ b/.github/workflow/build-and-analyse.yml @@ -0,0 +1,55 @@ +name: Build and Analyse + +on: + push: + branches: + - develop + - feature* + pull_request: + types: [ opened, synchronize, reopened ] + +defaults: + run: + shell: bash + +jobs: + + build-and-analyse: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + + - name: Setup Java and Maven + uses: ./.github/actions/setup-java-maven + + - name: Set up Maven with GitHub Packages + run: | + mkdir -p ~/.m2 + cat > ~/.m2/settings.xml << 'EOF' + + + + github-cloudflaredns + th-schwarz + ${{ secrets.GITHUB_TOKEN }} + + + + EOF + + - name: Build and analyze with SonarCloud + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }} + run: mvn -B -DtestClasspath=src/test/ verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=th-schwarz_DynDRest + + - name: Publish Test Report + uses: ./.github/actions/publish-report/ + if: ${{ always() }} + with: + token: ${{ secrets.GITHUB_TOKEN }} + report-name: Summary of JUnit Tests diff --git a/pom.xml b/pom.xml index 7bc7faf..037f23e 100644 --- a/pom.xml +++ b/pom.xml @@ -42,6 +42,15 @@ 5.14.2 5.21.0 + + th-schwarz + https://sonarcloud.io + ${file.encoding} + th-schwarz_CloudflareDNS-java + CloudflareDNS-java + develop + src/test/java/**/* + 1.18.20.0 @@ -273,7 +282,6 @@ -