Skip to content
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

Merged
merged 7 commits into from
Aug 21, 2023
Merged

Conversation

bigtedde
Copy link
Collaborator

@bigtedde bigtedde commented Aug 17, 2023

Description

#1778
#1754
@m3nu , @jetchirag , @real-yfprojects

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the CONTRIBUTING guide.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.

@bigtedde bigtedde marked this pull request as draft August 17, 2023 23:38
@@ -26,16 +26,59 @@ jobs:
shell: bash
run: make lint

prepare-unit-test-matrix:
Copy link
Collaborator Author

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"
Copy link
Collaborator Author

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.

Copy link
Collaborator

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?

Copy link
Collaborator Author

@bigtedde bigtedde Aug 19, 2023

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.

@bigtedde
Copy link
Collaborator Author

Overall, this works as intended with 2 exceptions:

  1. excluding combination of Borg 2.0.0b5 with python 3.8
  2. received a deprecation warning:
The `set-output` command is deprecated and will be disabled soon. 
Please upgrade to using Environment Files. 
For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

@bigtedde
Copy link
Collaborator Author

With this matrix, all jobs completed in 7m 57s

.github/workflows/test.yml Outdated Show resolved Hide resolved
@bigtedde
Copy link
Collaborator Author

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

@@ -0,0 +1,10 @@
event_name="$1"

if [[ "$event_name" == "push" ]] || [[ "$event_name" == "pull_request" ]]; then
Copy link
Collaborator

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.

Copy link
Contributor

@m3nu m3nu Aug 19, 2023

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.

Copy link
Collaborator Author

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' }}
Copy link
Collaborator Author

@bigtedde bigtedde Aug 19, 2023

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.

Copy link
Collaborator Author

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?

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

@bigtedde
Copy link
Collaborator Author

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.


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
Copy link
Collaborator

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:

Suggested change
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

Copy link
Collaborator Author

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 :)

@m3nu
Copy link
Contributor

m3nu commented Aug 21, 2023

Anything missing here before merging? Could we limit the "short" integration tests to Linux only?

@bigtedde bigtedde marked this pull request as ready for review August 21, 2023 17:40
@bigtedde
Copy link
Collaborator Author

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.

@m3nu
Copy link
Contributor

m3nu commented Aug 21, 2023

Thanks a lot for taking care, @bigtedde . Will merge this and then we see how it goes in practice.

@m3nu m3nu merged commit 567a354 into borgbase:master Aug 21, 2023
@bigtedde bigtedde deleted the ci branch August 21, 2023 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants