Skip to content

Reduce concurrent jobs number for projects #945

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

Merged
merged 23 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
edf4731
Combine projects runs
viktoriia-fomina Sep 16, 2022
0a513a7
Update outputs
viktoriia-fomina Sep 16, 2022
0c03092
Update needed job
viktoriia-fomina Sep 16, 2022
46d3d91
Rename job: framework -> framework-tests
viktoriia-fomina Sep 16, 2022
b8423d2
Using right job id
viktoriia-fomina Sep 16, 2022
a0cab8b
Create combined-projects-matrix.json
viktoriia-fomina Sep 16, 2022
303d14a
Combine utbot-api and utbot-framework-api
viktoriia-fomina Sep 16, 2022
4c019e4
Workflow: combine api and framework-api
viktoriia-fomina Sep 16, 2022
02cf2ea
Merge branch 'main' into victoria/reduce-concurrent-jobs-number
viktoriia-fomina Sep 16, 2022
5959e77
Updates from main
viktoriia-fomina Sep 16, 2022
f4dd95f
Return back changes from main
viktoriia-fomina Sep 16, 2022
0a092db
Return changes from main (2)
viktoriia-fomina Sep 16, 2022
a38a47f
Return back changes from main
viktoriia-fomina Sep 16, 2022
7d0469f
Remove useless tabs
viktoriia-fomina Sep 19, 2022
7ddfcca
Remove tab after run
viktoriia-fomina Sep 19, 2022
708dc10
Remove `echo`
viktoriia-fomina Sep 19, 2022
2945357
Merge branch 'main' into victoria/reduce-concurrent-jobs-number
viktoriia-fomina Sep 19, 2022
4514b93
Remove broking piece with `COMMIT_SHA`
viktoriia-fomina Sep 19, 2022
98c1a81
utbot-framework tests -> utbot-framework-test
viktoriia-fomina Sep 19, 2022
5a0e623
Add `echo`
viktoriia-fomina Sep 19, 2022
38ff09e
Remove thing with `COMMIT_SHA`
viktoriia-fomina Sep 19, 2022
587cef4
Merge branch 'main' into victoria/reduce-concurrent-jobs-number
viktoriia-fomina Sep 20, 2022
32259bf
Merge branch 'main' into victoria/reduce-concurrent-jobs-number
viktoriia-fomina Sep 20, 2022
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
97 changes: 78 additions & 19 deletions .github/workflows/build-and-run-tests-from-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ env:
GRADLE_OPTS: "-XX:MaxHeapSize=2048m -Dorg.gradle.jvmargs='-XX:MaxHeapSize=2048m -XX:MaxPermSize=512m -Dorg.gradle.daemon=false' -Dorg.gradle.daemon=false"

jobs:
prepare-tests-matrix:
prepare-matrices:
runs-on: ubuntu-latest
# Outputs are used for passing data to dependent jobs.
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
framework-tests-matrix: ${{ steps.set-matrices.outputs.framework-tests-matrix }}
combined-projects-matrix: ${{ steps.set-matrices.outputs.combined-projects-matrix }}
steps:
- name: Print environment variables
run: printenv
Expand All @@ -40,24 +41,23 @@ jobs:
git config --global --add safe.directory ${GITHUB_WORKSPACE}
git fetch
git checkout ${{ github.event.inputs.commit_sha }}
- id: set-matrix
name: Read and print config from framework-tests-matrix.json
- id: set-matrices
name: Read and print config from framework-tests-matrix.json and combined-projects-matrix.json
run: |
TASKS=$(echo $(cat .github/workflows/framework-tests-matrix.json))
echo "::set-output name=matrix::$TASKS"
echo $TASKS

framework-test:
# This job does not need to wait for 'prepare-tests-matrix' result.
# GitHub allocates runners portionally. Framework tests are time consuming. That's why we want to force them
# to start execution early.
needs: prepare-tests-matrix
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
FRAMEWORK_TESTS=$(echo $(cat .github/workflows/framework-tests-matrix.json))
COMBINED_PROJECTS=$(echo $(cat .github/workflows/combined-projects-matrix.json))
Copy link
Member

Choose a reason for hiding this comment

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

Maybe echo in this two lines doesn't make sense

echo "::set-output name=framework-tests-matrix::$FRAMEWORK_TESTS"
echo "::set-output name=combined-projects-matrix::$COMBINED_PROJECTS"
echo $FRAMEWORK_TESTS
echo $COMBINED_PROJECTS
framework-tests:
needs: prepare-matrices
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
strategy:
# The option forces to execute all jobs even though some of them have failed.
fail-fast: false
matrix: ${{ fromJson(needs.prepare-tests-matrix.outputs.matrix) }}
matrix: ${{ fromJson(needs.prepare-matrices.outputs.framework-tests-matrix) }}
runs-on: ubuntu-20.04
container: unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc1.7.0
steps:
Expand Down Expand Up @@ -103,16 +103,75 @@ jobs:
name: test_report ${{ matrix.project.PART_NAME }}
path: utbot-framework-test/build/reports/tests/test/*

combined-projects:
# This job does not need to wait for 'prepare-tests-matrix' result.
# GitHub allocates runners portionally. Framework tests are time consuming. That's why we want to force them
# to start execution early.
needs: prepare-matrices
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
strategy:
# The option forces to execute all jobs even though some of them have failed.
fail-fast: false
matrix: ${{ fromJson(needs.prepare-matrices.outputs.combined-projects-matrix) }}
runs-on: ubuntu-20.04
container: unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc1.7.0
steps:
- name: Print environment variables
run: printenv

- name: Checkout repository
uses: actions/checkout@v3

- name: Check out ${{ github.event.inputs.commit_sha }} commit
if: github.event.inputs.commit_sha != ''
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
git fetch
git checkout ${{ github.event.inputs.commit_sha }}

project:
needs: prepare-tests-matrix
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
- name: Run monitoring
run: |
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
chmod +x ./scripts/project/monitoring.sh
./scripts/project/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
- name: Build project ${{ matrix.projects.first }}
id: first-project
run: |
cd ${{ matrix.projects.first }}
gradle build --no-daemon
- name: Build project ${{ matrix.projects.second }}
if: ${{ steps.first-project.outcome != 'cancelled' && steps.first-project.outcome != 'skipped' }}
run: |
cd ${{ matrix.projects.second }}
gradle build --no-daemon
- name: Upload test report if tests have failed
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: test_report ${{ matrix.projects.first }}
path: ${{ matrix.projects.first }}/build/reports/tests/test/*

- name: Upload test report if tests have failed
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: test_report ${{ matrix.projects.second }}
path: ${{ matrix.projects.second }}/build/reports/tests/test/*


single-project:
# This job does not need to wait for 'prepare-tests-matrix' result.
# GitHub allocates runners portionally. Framework tests are time consuming. That's why we want to force them
# to start execution early.
needs: prepare-matrices
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
strategy:
# The option forces to execute all jobs even though some of them have failed.
fail-fast: false
matrix:
project: [utbot-api, utbot-cli, utbot-core, utbot-framework, utbot-framework-api, utbot-fuzzers, utbot-gradle, utbot-instrumentation, utbot-instrumentation-tests, utbot-intellij, utbot-junit-contest, utbot-rd, utbot-sample, utbot-summary, utbot-summary-tests]
project: [utbot-core, utbot-fuzzers, utbot-gradle, utbot-junit-contest, utbot-sample]
runs-on: ubuntu-20.04
container: unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc1.7.0
steps:
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/combined-projects-matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"projects": [
{
"FIRST": "utbot-intellij",
"SECOND": "utbot-cli",
},
{
"FIRST": "utbot-instrumentation",
"SECOND": "utbot-instrumentation-tests",
},
{
"FIRST": "utbot-summary",
"SECOND": "utbot-summary-tests",
},
{
"FIRST": "utbot-api",
"SECOND": "utbot-framework-api",
}
]
}