From 23d1f593e6502a2e653ebbb55809b9722cd24958 Mon Sep 17 00:00:00 2001 From: Todd Anderson Date: Tue, 31 Mar 2026 15:30:05 -0400 Subject: [PATCH 1/2] chore: update release please permission and adds CI unit tests to release process --- .github/actions/ci/action.yml | 57 ++++++++++++++++++++++++++++ .github/workflows/ci.yml | 30 ++++----------- .github/workflows/publish.yml | 18 +++++++++ .github/workflows/release-please.yml | 3 ++ 4 files changed, 86 insertions(+), 22 deletions(-) create mode 100644 .github/actions/ci/action.yml diff --git a/.github/actions/ci/action.yml b/.github/actions/ci/action.yml new file mode 100644 index 0000000..dadbe43 --- /dev/null +++ b/.github/actions/ci/action.yml @@ -0,0 +1,57 @@ +name: Shared CI +description: Shared build, style, test, and coverage steps for okhttp-eventsource. +inputs: + java_version: + description: 'Java version to use (e.g. 8, 11, 17).' + required: true + run_tests: + description: 'If true, run unit tests, coverage report, and coverage verification.' + required: false + default: 'true' + run_contract_tests: + description: 'If true, run SSE contract tests (slower; needs network).' + required: false + default: 'false' + +runs: + using: composite + steps: + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: ${{ inputs.java_version }} + + - name: Restore dependencies + shell: bash + run: ./gradlew dependencies + + - name: Build jar + shell: bash + run: ./gradlew jar + + - name: Checkstyle + shell: bash + run: ./gradlew checkstyleMain + + - name: Unit tests + if: ${{ inputs.run_tests == 'true' }} + shell: bash + run: make test + + - name: Generate test coverage report + if: ${{ inputs.run_tests == 'true' }} + shell: bash + run: | + ./gradlew jacocoTestReport + mkdir -p coverage/ + cp -r build/reports/jacoco/test/* ./coverage + + - name: Enforce test coverage + if: ${{ inputs.run_tests == 'true' }} + shell: bash + run: ./gradlew jacocoTestCoverageVerification + + - name: Contract tests + if: ${{ inputs.run_contract_tests == 'true' }} + shell: bash + run: make contract-tests diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index beaf543..58f61bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,30 +15,19 @@ jobs: runs-on: ubuntu-latest strategy: - fail-fast: false + fail-fast: false # false = do not cancel sibling matrix jobs when one leg fails matrix: java-version: ["8", "11", "17"] steps: - uses: actions/checkout@v4 - - uses: actions/setup-java@v4 - with: - distribution: 'temurin' # See 'Supported distributions' for available options - java-version: ${{ matrix.java-version }} - - - run: ./gradlew dependencies - - run: ./gradlew jar - - run: ./gradlew checkstyleMain - - - run: make test - - name: Generate test coverage report - run: | - ./gradlew jacocoTestReport - mkdir -p coverage/ - cp -r build/reports/jacoco/test/* ./coverage - - name: Enforce test coverage - run: ./gradlew jacocoTestCoverageVerification + - name: Shared CI + uses: ./.github/actions/ci + with: + java_version: ${{ matrix.java-version }} + run_tests: true + run_contract_tests: true - name: Save test results run: | @@ -55,9 +44,6 @@ jobs: name: ${{ matrix.java-version }} code coverage path: ./coverage - - name: run contract tests - run: make contract-tests - windows: runs-on: windows-latest @@ -66,7 +52,7 @@ jobs: shell: powershell strategy: - fail-fast: false + fail-fast: false # false = do not cancel sibling matrix jobs when one leg fails matrix: java-version: ["11.0.2.01", "17.0.1"] diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 981a92e..0f52924 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -31,7 +31,25 @@ on: required: true jobs: + ci: + runs-on: ubuntu-latest + strategy: + fail-fast: false # false = do not cancel sibling matrix jobs when one leg fails + matrix: + java-version: ["8", "11", "17"] + steps: + # https://github.com/actions/checkout/releases/tag/v4.3.1 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + + - name: Shared CI + uses: ./.github/actions/ci + with: + java_version: ${{ matrix.java-version }} + run_tests: ${{ inputs.run_tests }} + run_contract_tests: false + build-and-publish: + needs: ci runs-on: ubuntu-latest permissions: id-token: write diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 6a12a7d..14bd0de 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -27,6 +27,9 @@ jobs: call-workflow-publish: needs: release-please + permissions: + id-token: write + contents: write uses: ./.github/workflows/publish.yml if: ${{ needs.release-please.outputs.releases_created == 'true' }} with: From edae3f7d699bad33116027b49452669823404298 Mon Sep 17 00:00:00 2001 From: Todd Anderson Date: Tue, 31 Mar 2026 15:35:00 -0400 Subject: [PATCH 2/2] reverting order of when contract tests runs --- .github/actions/ci/action.yml | 9 --------- .github/workflows/ci.yml | 5 ++++- .github/workflows/publish.yml | 1 - 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/actions/ci/action.yml b/.github/actions/ci/action.yml index dadbe43..c115772 100644 --- a/.github/actions/ci/action.yml +++ b/.github/actions/ci/action.yml @@ -8,10 +8,6 @@ inputs: description: 'If true, run unit tests, coverage report, and coverage verification.' required: false default: 'true' - run_contract_tests: - description: 'If true, run SSE contract tests (slower; needs network).' - required: false - default: 'false' runs: using: composite @@ -50,8 +46,3 @@ runs: if: ${{ inputs.run_tests == 'true' }} shell: bash run: ./gradlew jacocoTestCoverageVerification - - - name: Contract tests - if: ${{ inputs.run_contract_tests == 'true' }} - shell: bash - run: make contract-tests diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58f61bc..6f370ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,6 @@ jobs: with: java_version: ${{ matrix.java-version }} run_tests: true - run_contract_tests: true - name: Save test results run: | @@ -44,6 +43,10 @@ jobs: name: ${{ matrix.java-version }} code coverage path: ./coverage + # After junit/coverage artifacts: contract test failures must not skip uploads above. + - name: Contract tests + run: make contract-tests + windows: runs-on: windows-latest diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0f52924..cb2c8b1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -46,7 +46,6 @@ jobs: with: java_version: ${{ matrix.java-version }} run_tests: ${{ inputs.run_tests }} - run_contract_tests: false build-and-publish: needs: ci