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

Migrate unit and integration tests from TravisCI to GitHub Actions #580

Merged
merged 19 commits into from
Aug 29, 2024

Conversation

mfisher87
Copy link
Member

@mfisher87 mfisher87 commented Aug 21, 2024

Closes #547

This PR migrates the current TravisCI behavior into GitHub Actions.

New feature: Unit tests run on multiple versions of Python.

TODO:

  • @JessicaS11 add credentials currently being used for TravisCI tests to GitHub repository secrets
  • @JessicaS11 make new unit and integration test workflows "required" in GH repository settings
  • @JessicaS11 clean up required Travis check in repository settings
  • @JessicaS11 or @mfisher87 update CI badges on readme (currently point to Travis)

Note

This does not attempt to implement an approval process for PRs from forks. We don't have that now, so we're not losing anything by dropping Travis in this PR. This is challenging. I'll open another draft PR with that stuff, and we can hopefully figure it out.

See #588

Copy link

github-actions bot commented Aug 21, 2024

Binder 👈 Launch a binder notebook on this branch for commit 69dcec3

I will automatically update this comment whenever this PR is modified

Binder 👈 Launch a binder notebook on this branch for commit b98483c

Binder 👈 Launch a binder notebook on this branch for commit cd2f771

Binder 👈 Launch a binder notebook on this branch for commit 8ebabce

Binder 👈 Launch a binder notebook on this branch for commit e5b2610

Binder 👈 Launch a binder notebook on this branch for commit 7aab5bb

Binder 👈 Launch a binder notebook on this branch for commit 434b010

Binder 👈 Launch a binder notebook on this branch for commit 0038615

Binder 👈 Launch a binder notebook on this branch for commit a5b2609

Binder 👈 Launch a binder notebook on this branch for commit 2426af3

Binder 👈 Launch a binder notebook on this branch for commit 33592a5

Binder 👈 Launch a binder notebook on this branch for commit 0daf7ae

Binder 👈 Launch a binder notebook on this branch for commit 88bc5d9

Binder 👈 Launch a binder notebook on this branch for commit 39006bd

Binder 👈 Launch a binder notebook on this branch for commit 098bb98

Binder 👈 Launch a binder notebook on this branch for commit 417238f

Binder 👈 Launch a binder notebook on this branch for commit a950c87

Binder 👈 Launch a binder notebook on this branch for commit 7bb6cb5

Binder 👈 Launch a binder notebook on this branch for commit 3115443

Binder 👈 Launch a binder notebook on this branch for commit 0b82f05

Binder 👈 Launch a binder notebook on this branch for commit 4183ece

Binder 👈 Launch a binder notebook on this branch for commit 4e59c92

Binder 👈 Launch a binder notebook on this branch for commit 403643b

Binder 👈 Launch a binder notebook on this branch for commit 8ee626a

@mfisher87
Copy link
Member Author

mfisher87 commented Aug 23, 2024

I got a bit frustrated trying to get the integration test "secure approval" process working the way I want it to. The event isn't triggering, and I don't know how (of if it's possible) to debug that.

I'm going to spend some time on the Harmony -> ECS work today to give myself a break. I made a post in Openscapes Slack asking if anyone has ideas what's going wrong in the meantime :) Any tips greatly appreciated!

@mfisher87
Copy link
Member Author

I think I'm going to split this PR into two pieces: (1) migrate Travis -> GHA as-is; (2) the approval thing.

(1) alone provides value by reducing the number of unique automation systems we depend on.

@mfisher87 mfisher87 changed the title Migrate unit and integration tests to GitHub Actions Migrate unit and integration tests from TravisCI to GitHub Actions Aug 26, 2024
@mfisher87 mfisher87 marked this pull request as ready for review August 26, 2024 23:06
@mfisher87 mfisher87 added the review::priority This change is preferred for review label Aug 27, 2024
push:
branches:
- "main"
- "development"
Copy link
Member

Choose a reason for hiding this comment

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

Given these are slightly "expensive" tests since they download files (and running them for every commit could ultimately influence the icepyx metrics), what are our options for restricting how often they run for a given PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

These triggers (branches:) would be for every merge, not for every commit on PRs. We can customize the pull_request: triggers. By default, they run on open and synchronize (effectively, when the PR is pushed to, not on every commit). The full list is here: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request

I think the best way we can limit these runs is by adding paths: filters. That would enable e.g. docs changes to not trigger the expensive tests!

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we consider this part of this PR, or create an issue to track the work?

Copy link
Member

Choose a reason for hiding this comment

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

(effectively, when the PR is pushed to, not on every commit).

Right - forgot this subtlety - but a PR can have a lot of pushes too!

Should we consider this part of this PR, or create an issue to track the work?

I would definitely consider it part of this PR. I don't want to have a setup running that will trigger so many runs.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would definitely consider it part of this PR. I don't want to have a setup running that will trigger so many runs.

Don't want to push back too hard, because I am fine doing it however, but I do want to raise that Travis CI behaves this way already:

https://github.com/icesat2py/icepyx/blob/development/.travis.yml#L21-L24

I would lean towards breaking this work into two PRs: (1) migrate Travis -> GH; (2) more efficient. When those PRs are merged into development, they will produce two clearer commits and entries in the changelog. I'm OK with immediately following this PR up with step 2 if you're OK with dividing it!

Copy link
Member Author

@mfisher87 mfisher87 Aug 27, 2024

Choose a reason for hiding this comment

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

Or "approved"? I think this is how I set up the uml diagram action so it only runs once per PR.

There is no approved event type. That workflow checks the current state of the PR after triggering the workflow, and if it's not "approved", it sets the workflow to "skipped":

if: github.event.review.state == 'approved'

If there was an approved event type, then we could avoid the triggering in the first place :(

Since we have other possible triggers we would need something like ${{ github.event.action != "pull_request_review" || github.event.review.state == "approved" }}. Otherwise, integration tests would be skipped on our release PRs until they were approved, and if we want that behavior we can remove the pull_request trigger. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

There is no approved event type.

Guess that was wishful thinking on my part then.

Since we have other possible triggers we would need something like ${{ github.event.action != "pull_request_review" || github.event.review.state == "approved" }}. Otherwise, integration tests would be skipped on our release PRs until they were approved, and if we want that behavior we can remove the pull_request trigger. Thoughts?

I'm happy with the latest edits versus this. I don't think we tend to have a lot of official "reviews" until we're getting pretty close to merging, and it would be great to have the tests run on release PRs right away.

Copy link
Member

Choose a reason for hiding this comment

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

I'm happy with the latest edits versus this. I don't think we tend to have a lot of official "reviews" until we're getting pretty close to merging, and it would be great to have the tests run on release PRs right away.

I might need to rescind this. I'm noticing the integration test is running, which makes me think that GH considers a comment (regardless of approval) to be a "review", thus triggering the action for any comment made on the PR.

Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking the least unpalatable option at this point is your suggestion to remove the PR trigger and add something like ${{ github.event.action != "pull_request_review" || github.event.review.state == "approved" }}.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's try it on for size!

mfisher87 and others added 2 commits August 27, 2024 13:54
Co-authored-by: Jessica Scheick <[email protected]>
Co-authored-by: Jessica Scheick <[email protected]>
Copy link

codecov bot commented Aug 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.45%. Comparing base (a52bc37) to head (8ee626a).
Report is 1 commits behind head on development.

Additional details and impacted files
@@               Coverage Diff               @@
##           development     #580      +/-   ##
===============================================
+ Coverage        65.36%   65.45%   +0.09%     
===============================================
  Files               36       36              
  Lines             3037     3037              
  Branches           531      594      +63     
===============================================
+ Hits              1985     1988       +3     
+ Misses             970      964       -6     
- Partials            82       85       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JessicaS11
Copy link
Member

I got a bit frustrated trying to get the integration test "secure approval" process working the way I want it to. The event isn't triggering, and I don't know how (of if it's possible) to debug that.

Is it possible that it's because the action isn't yet in development?

@mfisher87
Copy link
Member Author

Is it possible that it's because the action isn't yet in development?

I did run in to that initially. I've been testing on my fork, and I did merge into development over there, and still not seeing the events I expected!

@mfisher87
Copy link
Member Author

@JessicaS11 I stealth-edited some TODOs in the description of this PR. Just realized Travis will block merge if it doesn't run :)

image

@mfisher87
Copy link
Member Author

I was confused why the tests weren't passing, and it turns out they also depend on an envvar named $NSIDC_LOGIN. When they are both populated with the password, things go!

README.rst Outdated Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
Copy link
Member

@JessicaS11 JessicaS11 left a comment

Choose a reason for hiding this comment

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

Thanks for all the problem solving and changes on this one! I'm excited to get CI moved onto GH, so thanks for making it happen, Matt.

@mfisher87
Copy link
Member Author

Any time! 🚀

@mfisher87 mfisher87 merged commit bd09d73 into development Aug 29, 2024
10 checks passed
@mfisher87 mfisher87 deleted the test-with-gha branch August 29, 2024 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review::priority This change is preferred for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consolidate CI from Travis -> GitHub Actions
2 participants