-
Notifications
You must be signed in to change notification settings - Fork 137
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
PR: Reduce test workflow for each PR/commit #1780
Conversation
.github/workflows/test.yml
Outdated
@@ -26,16 +26,59 @@ jobs: | |||
shell: bash | |||
run: make lint | |||
|
|||
prepare-unit-test-matrix: |
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.
Prepares matrix's based on push/pull request vs workflow dispatch. Note: matrix's are the same for unit tests, but defined separately in case changes need to be made in the future.
borg-version: ["1.1.18", "1.2.2", "1.2.4", "2.0.0b5"] | ||
exclude: | ||
- borg-version: "2.0.0b5" | ||
python-version: "3.8" |
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.
Biggest hurdle I ran into with the integration tests is excluding the combination of Borg 2.0.0b5 with python 3.8. Skipped this for now.
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.
Doesn't adding the exclude to the matrix work?
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.
Unfortunately it does not work with the way I'm dynamically creating the matrix, this only works when the matrix is static I believe.
Overall, this works as intended with 2 exceptions:
|
With this matrix, all jobs completed in 7m 57s |
Welp, a few trial and errors later, and I think this is in a good spot. I made a script that generates the matrices for unit and integration tests based on the type of request (PR, push, workflow dispatch) and this script can be changed easily if we want to tinker in the future. Furthermore, I got past the deprecation warning that I was having before. The only remaining issue is that I am unable to find a way to exclude the combination of Borg v2.0.05b with python 3.8 |
.github/scripts/generate-matrix.sh
Outdated
@@ -0,0 +1,10 @@ | |||
event_name="$1" | |||
|
|||
if [[ "$event_name" == "push" ]] || [[ "$event_name" == "pull_request" ]]; then |
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.
For a push to master I would run all tests.
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.
Agree. That would mostly automate it.
- only run a few select tests for PR commits.
- run all tests when merging into master.
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.
Okay, I have updated the matrix script to first check "is it a manual workflow dispatch OR a request from master branch" and if so fun all tests. In all other cases (push/PR/non master) run the subset of tests.
- name: Setup tmate session | ||
uses: mxschmitt/action-tmate@v3 | ||
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} | ||
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }} |
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.
This corrects a serious error I found while testing. Before, the conditional 'debug_enabled' would always evaluate to True
since the call returns a string which is truthy. This was causing a manual workflow to always be ran in debugging mode, even with debugging disabled.
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.
Another thing I found when running in debug mode is that the tests would always timeout (execution time > 20 minutes). Should we consider raising the execution timeout if debug mode is enabled?
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.
I think that's because of the remote shell created. It stops execution and allows you to connect to the box.
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.
Okay, guess the timeout is fine as is then.
Okay, everything now works as expected and without any deprecation warnings. I implemented a new way of doing the "exclude" by creating a step that validates the matrix combinations. Although it may appear slightly clunky now, if we need to add future excluded combinations this step will be easy to edit/maintain. |
.github/scripts/generate-matrix.sh
Outdated
|
||
if [[ "$event_name" == "workflow_dispatch" ]] || [[ "$branch_name" == "master" ]]; then | ||
echo '{"python-version": ["3.8", "3.9", "3.10", "3.11"], "os": ["ubuntu-latest", "macos-latest"], "borg-version": ["1.2.4"]}' > matrix-unit.json | ||
echo '{"python-version": ["3.8", "3.9", "3.10", "3.11"], "os": ["ubuntu-latest", "macos-latest"], "borg-version": ["1.1.18", "1.2.2", "1.2.4", "2.0.0b5"]}' > matrix-integration.json |
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.
Did you write the exclude like that when testing:
echo '{"python-version": ["3.8", "3.9", "3.10", "3.11"], "os": ["ubuntu-latest", "macos-latest"], "borg-version": ["1.1.18", "1.2.2", "1.2.4", "2.0.0b5"]}' > matrix-integration.json | |
echo '{"python-version": ["3.8", "3.9", "3.10", "3.11"], "os": ["ubuntu-latest", "macos-latest"], "borg-version": ["1.1.18", "1.2.2", "1.2.4", "2.0.0b5"], "exclude": [{"borg-version":"2.0.0b5, "python-version":"3.8"}]}' > matrix-integration.json |
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.
@real-yfprojects This worked like a charm :)
Anything missing here before merging? Could we limit the "short" integration tests to Linux only? |
I just made that change to the matrix script, and marked this PR as ready for review. |
Thanks a lot for taking care, @bigtedde . Will merge this and then we see how it goes in practice. |
Description
#1778
#1754
@m3nu , @jetchirag , @real-yfprojects
Types of changes
Checklist:
I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.