-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#2898] Build CI on more realistic combinations (and faster) #3028
Open
undermyumbrella1
wants to merge
10
commits into
mockito:main
Choose a base branch
from
undermyumbrella1:2898/build-once-test-all
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6587433
Fixes #2898 Build once and Test on all Java Versions
eb3681f
Use relative path name for reusable workflow
951f091
Build once on java 11 instead of with diff combination of env variables
a0b6444
Update release job to depend on build job
ad99f01
Test job should include env variables
13d98f3
Update to multiline gradle comment
002092c
Fetch entire commit history in test job
e0498b2
Test job should run createTestResources
e02f279
Build on java 11, include all tasks
29970ed
Remove reusable workflows
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
name: Build and Test Project | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build-1: | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
mock-maker: 'mock-maker-default' | ||
member-accessor: 'member-accessor-default' | ||
|
||
build-2: | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
mock-maker: 'mock-maker-inline' | ||
member-accessor: 'member-accessor-module' | ||
|
||
build-3: | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
mock-maker: 'mock-maker-subclass' | ||
member-accessor: 'member-accessor-module' | ||
|
||
build-4: | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
mock-maker: 'mock-maker-subclass' | ||
member-accessor: 'member-accessor-reflection' | ||
|
||
build-5: | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
mock-maker: 'mock-maker-inline' | ||
member-accessor: 'member-accessor-reflection' | ||
|
||
test-1a: | ||
needs: build-1 | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
mock-maker: 'mock-maker-default' | ||
member-accessor: 'member-accessor-default' | ||
java: 11 | ||
|
||
test-1b: | ||
needs: build-1 | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
mock-maker: 'mock-maker-default' | ||
member-accessor: 'member-accessor-default' | ||
java: 17 | ||
|
||
test-2a: | ||
needs: build-2 | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
mock-maker: 'mock-maker-inline' | ||
member-accessor: 'member-accessor-module' | ||
java: 11 | ||
|
||
test-2b: | ||
needs: build-2 | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
mock-maker: 'mock-maker-inline' | ||
member-accessor: 'member-accessor-module' | ||
java: 17 | ||
|
||
test-3a: | ||
needs: build-3 | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
mock-maker: 'mock-maker-subclass' | ||
member-accessor: 'member-accessor-module' | ||
java: 11 | ||
|
||
test-3b: | ||
needs: build-3 | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
mock-maker: 'mock-maker-subclass' | ||
member-accessor: 'member-accessor-module' | ||
java: 17 | ||
|
||
test-4a: | ||
needs: build-4 | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
mock-maker: 'mock-maker-subclass' | ||
member-accessor: 'member-accessor-reflection' | ||
java: 11 | ||
|
||
test-4b: | ||
needs: build-4 | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
mock-maker: 'mock-maker-subclass' | ||
member-accessor: 'member-accessor-reflection' | ||
java: 17 | ||
|
||
test-5a: | ||
needs: build-5 | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
mock-maker: 'mock-maker-inline' | ||
member-accessor: 'member-accessor-reflection' | ||
java: 11 | ||
|
||
test-5b: | ||
needs: build-5 | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
mock-maker: 'mock-maker-inline' | ||
member-accessor: 'member-accessor-reflection' | ||
java: 17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Main Build Job | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
mock-maker: | ||
required: true | ||
type: string | ||
member-accessor: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
# | ||
# Main build job | ||
# | ||
build: | ||
runs-on: ubuntu-latest | ||
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" | ||
|
||
# All build steps | ||
# SINGLE-JOB means that the step is only performed when default mock maker environment is used | ||
steps: | ||
- name: 1. Check out code | ||
uses: actions/checkout@v3 # https://github.com/actions/checkout | ||
with: | ||
fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci | ||
|
||
- name: 2. Set up Java 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'zulu' | ||
java-version: 11 | ||
|
||
- name: 3. Validate Gradle wrapper (single job only) | ||
if: inputs.mock-maker == 'mock-maker-default' # SINGLE-JOB | ||
uses: gradle/wrapper-validation-action@v1.0.6 # https://github.com/gradle/wrapper-validation-action | ||
|
||
- name: 4. Build and check reproducibility of artifacts (single job only) | ||
if: inputs.mock-maker == 'mock-maker-default' # SINGLE-JOB | ||
run: ./check_reproducibility.sh | ||
|
||
- name: 5. Spotless check (single job only). Run './gradlew spotlessApply' locally if this job fails. | ||
if: inputs.mock-maker == 'mock-maker-default' # SINGLE-JOB | ||
run: ./gradlew spotlessCheck | ||
|
||
- name: 6. Build on Java 11 with ${{ inputs.mock-maker }} and ${{ inputs.member-accessor }} | ||
run: | | ||
./gradlew build idea --scan \ | ||
-x test \ | ||
-x sourcesJar -x javadocJar \ | ||
-x publishJavaLibraryPublicationToMavenLocal | ||
./gradlew :android:build | ||
env: | ||
MOCK_MAKER: ${{ inputs.mock-maker }} | ||
MEMBER_ACCESSOR: ${{ inputs.member-accessor }} | ||
|
||
- name: 7. Upload build artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ inputs.mock-maker }}-${{ inputs.member-accessor }}-build-artifacts | ||
path: | | ||
build | ||
subprojects/*/build | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Main Test Job | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
mock-maker: | ||
required: true | ||
type: string | ||
member-accessor: | ||
required: true | ||
type: string | ||
java: | ||
required: true | ||
type: number | ||
|
||
jobs: | ||
# | ||
# Main test job | ||
# | ||
test: | ||
runs-on: ubuntu-latest | ||
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" | ||
|
||
# All test steps | ||
steps: | ||
- name: 1. Checkout out test code | ||
uses: actions/checkout@v3 | ||
|
||
- name: 2. Download build artifacts with name ${{ inputs.mock-maker }}-${{ inputs.member-accessor }}-build-artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ inputs.mock-maker }}-${{ inputs.member-accessor }}-build-artifacts | ||
|
||
- name: 3. Set up Java ${{ inputs.java }} | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'zulu' | ||
java-version: ${{ inputs.java }} | ||
|
||
- name: 4. Test on Java ${{ inputs.java }} with ${{ inputs.mock-maker }} and ${{ inputs.member-accessor }} | ||
run: | | ||
./gradlew test -x testClasses \ | ||
-x compileTestJava -x compileTestGroovy -x compileTestKotlin -x compileTestBundleJava \ | ||
-x classes -x compileJava -x compileGroovy -x compileKotlin -x compileOtherBundleJava \ | ||
-x processResources -x processOtherBundleResources \ | ||
-x preBuild -x preDebugBuild \ | ||
-x jar | ||
|
||
- name: 5. Upload coverage report | ||
run: | | ||
./gradlew coverageReport -s --scan && cp build/reports/jacoco/mockitoCoverage/mockitoCoverage.xml jacoco.xml | ||
curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import # One-time step | ||
|
||
curl -Os https://uploader.codecov.io/latest/linux/codecov | ||
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM | ||
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig | ||
|
||
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM | ||
shasum -a 256 -c codecov.SHA256SUM | ||
|
||
chmod +x codecov | ||
./codecov |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip: when you have just one command you can do this too:
probably worth keeping the
\
version though for consistency with otherrun:
blocks.