Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/actions/ci/action.yml

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release please was not running CI, so this is to commonize regular PR CI and release CI.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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'

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
29 changes: 9 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,18 @@ 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

- name: Save test results
run: |
Expand All @@ -55,7 +43,8 @@ jobs:
name: ${{ matrix.java-version }} code coverage
path: ./coverage

- name: run contract tests
# After junit/coverage artifacts: contract test failures must not skip uploads above.
- name: Contract tests
run: make contract-tests

windows:
Expand All @@ -66,7 +55,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"]

Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,24 @@ 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 }}

build-and-publish:
needs: ci
runs-on: ubuntu-latest
permissions:
id-token: write
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:

call-workflow-publish:
needs: release-please
permissions:
id-token: write
contents: write

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intended permission change

uses: ./.github/workflows/publish.yml
if: ${{ needs.release-please.outputs.releases_created == 'true' }}
with:
Expand Down
Loading