From 5830b092d5f2b2f2a9cba76f15c616c0360ab737 Mon Sep 17 00:00:00 2001 From: Tom Akehurst Date: Wed, 8 Nov 2023 16:39:36 +0000 Subject: [PATCH] Added validate, build test CI actions --- .github/CODEOWNERS | 1 + .github/dependabot.yml | 8 +++ .github/release-drafter.yml | 2 + .github/workflows/build-and-test.yml | 53 +++++++++++++++++++ .github/workflows/changelog-draft.yml | 20 +++++++ .github/workflows/publish-test-results.yml | 37 +++++++++++++ .github/workflows/validate-gradle-wrapper.yml | 19 +++++++ 7 files changed, 140 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/dependabot.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/build-and-test.yml create mode 100644 .github/workflows/changelog-draft.yml create mode 100644 .github/workflows/publish-test-results.yml create mode 100644 .github/workflows/validate-gradle-wrapper.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..bb4979e --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @wiremock/wiremock-java-co-maintainers diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0e6fdc9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: +- package-ecosystem: gradle + directory: "/" + schedule: + interval: daily + time: "04:00" + open-pull-requests-limit: 10 diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..3ac09a2 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,2 @@ +# Use https://github.com/wiremock/.github/blob/main/.github/release_drafter.yml +_extends: .github diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..7773296 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,53 @@ +# This workflow will build a Java project with Gradle +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Build and test + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + jdk: [11, 17] + runs-on: ${{ matrix.os }} + env: + JDK_VERSION: ${{ matrix.jdk }} + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: ${{ matrix.jdk }} + distribution: 'temurin' + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Cache Gradle packages + uses: actions/cache@v1 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + + - name: Test + if: ${{ !(matrix.os == 'ubuntu-latest' && matrix.jdk == 11 && github.event_name == 'push') }} + run: ./gradlew check --stacktrace --no-daemon + + - name: Archive test report - ${{ matrix.os }} JDK ${{ matrix.jdk }} + if: always() + uses: actions/upload-artifact@v2 + with: + name: wiremock-grpc-extension-test-report-${{ matrix.os }} JDK ${{ matrix.jdk }} + path: | + build/reports/tests/test + build/test-results/test diff --git a/.github/workflows/changelog-draft.yml b/.github/workflows/changelog-draft.yml new file mode 100644 index 0000000..868bf47 --- /dev/null +++ b/.github/workflows/changelog-draft.yml @@ -0,0 +1,20 @@ +name: Release Drafter + +on: + push: + branches: + - main + - master + workflow_dispatch: + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + with: + name: next + tag: next + version: next + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish-test-results.yml b/.github/workflows/publish-test-results.yml new file mode 100644 index 0000000..d31c274 --- /dev/null +++ b/.github/workflows/publish-test-results.yml @@ -0,0 +1,37 @@ +name: Publish Test Results + +on: + workflow_run: + workflows: ["CI"] + types: + - completed + +jobs: + unit-test-results: + name: Unit Test Results + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion != 'skipped' + + steps: + - name: Download and Extract Artifacts + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + run: | + mkdir -p artifacts && cd artifacts + + artifacts_url=${{ github.event.workflow_run.artifacts_url }} + + gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact + do + IFS=$'\t' read name url <<< "$artifact" + gh api $url > "$name.zip" + unzip -d "$name" "$name.zip" + done + + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + commit: ${{ github.event.workflow_run.head_sha }} + event_file: artifacts/Event File/event.json + event_name: ${{ github.event.workflow_run.event }} + files: "artifacts/**/*.xml" diff --git a/.github/workflows/validate-gradle-wrapper.yml b/.github/workflows/validate-gradle-wrapper.yml new file mode 100644 index 0000000..f3bd8c6 --- /dev/null +++ b/.github/workflows/validate-gradle-wrapper.yml @@ -0,0 +1,19 @@ +# This workflow will build a Java project with Gradle +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Validate Gradle wrapper + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + validate: + name: Validate Gradle wrapper + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 \ No newline at end of file