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

CI: Add test workflow for action #27

Merged
merged 1 commit into from
Aug 9, 2023

Conversation

matthewfeickert
Copy link
Member

@matthewfeickert matthewfeickert commented Jul 19, 2023

Resolves #15

jobs:
steps:
...
- name: Upload wheel
uses: scientific-python/upload-nightly-action@8f0394fd2aa0c85d7364a9958652e8994e06b23c # 0.1.0
with:
artifacts_path: dist
anaconda_nightly_upload_token: ${{secrets.UPLOAD_TOKEN}}

@matthewfeickert matthewfeickert self-assigned this Jul 19, 2023

on:
push:
# branches: [ main ]
Copy link
Member Author

Choose a reason for hiding this comment

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

Using for debugging. Make sure to revert comment before merge.

@matthewfeickert
Copy link
Member Author

matthewfeickert commented Jul 21, 2023

Note to reviewers: The CI fails because GitHub Actions is using my fork's credentials to try to run this (as this workflow doesn't exist on the main repo yet) (c.f. https://github.com/scientific-python/upload-nightly-action/pull/27/files#r1270228235). I pushed this branch under a different name as a test to the main repo and it was able to run and upload test-package correctly: https://anaconda.org/scientific-python-nightly-wheels/test-package

So this is working as I would expect, and so is ready for your reviews. 👍

@matthewfeickert
Copy link
Member Author

Gentle ping for review when people have time.

Copy link
Member

@MridulS MridulS left a comment

Choose a reason for hiding this comment

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

LGTM!

Maybe we should link this test action from the root README file too?
For example for networkx, we just build and upload. Maybe we should add the verification and debugging steps too 😅

branches: [ main ]
# Run daily at 1:23 UTC
schedule:
- cron: '23 1 * * *'
Copy link
Member

Choose a reason for hiding this comment

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

Does this really have to run daily? Weekly, or biweekly should be enough for such a repo.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why not?

Copy link
Member

Choose a reason for hiding this comment

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

Because we don't expect fast pace breakings here, as we practically have very few dependencies, and it's totally unnecessary use of resource.

In fact, as I see all versions are pinned, so then there is zero sense in running the cron.

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact, as I see all versions are pinned, so then there is zero sense in running the cron.

No, the action isn't fully specified (that requires a lock file, which is an upcoming PR), and the ci workflow uses unpinned versions of other actions that you want to know about. So testing on CRON is a good idea. The resource use is trivial IMO, but if it is really offensive we can move it to weekly.

uses: ./
with:
artifacts_path: dist
anaconda_nightly_upload_token: ${{ secrets.UPLOAD_TOKEN }}
Copy link
Member

Choose a reason for hiding this comment

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

So where would this test package end up being uploaded? Is there any cleanup planned once the upload is successful?

Copy link
Member Author

@matthewfeickert matthewfeickert Aug 1, 2023

Choose a reason for hiding this comment

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

So where would this test package end up being uploaded?

https://anaconda.org/scientific-python-nightly-wheels/test-package

(c.f. #27 (comment))

Is there any cleanup planned once the upload is successful?

No, but does there need to be?

Copy link
Member

Choose a reason for hiding this comment

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

Yes. I would definitely like to avoid polluting the user deployed space with testing artifacts.

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 like to avoid polluting the user deployed space with testing artifacts.

Can you elaborate as to why this matters? Also please suggest an alternative location.

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 not suggesting another location, but to do a cleanup. Easy and simple and the pollution will be only present when there is a problem.

@matthewfeickert
Copy link
Member Author

Maybe we should link this test action from the root README file too? For example for networkx, we just build and upload. Maybe we should add the verification and debugging steps too

@MridulS We could do that, but I would suggest not using this GHA workflow but creating a template that anyone in the org could use, as this workflow is focused on just testing the test package. There are already other projects and Actions that do this and more, like https://github.com/hynek/build-and-inspect-python-package, but I could understand the interest in an action template that would be more specific to a minimum set of verification stages that people can then extend if they want. This would be a separate project though IMO.

While I have personally found benefits in pyhf from having these verification steps I don't think that anyone not using them now should feel bad. Though I agree if we can make adoption even easier that's great.

Comment on lines 8 to 10
# Run weekly at 1:23 UTC
schedule:
- cron: '23 1 * * 7'
Copy link
Member Author

Choose a reason for hiding this comment

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

CRON is now weekly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh this is apparently non-standard CRON syntax? Let me fix this. :(

Copy link
Member Author

Choose a reason for hiding this comment

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

'23 1 * * 7' is nonstandard because of the 7 so I swapped this to 0.

Comment on lines 56 to 78
cleanup:
runs-on: ubuntu-latest
needs: [test]
# Set required workflow secrets in the environment for additional security
# https://github.com/scientific-python/upload-nightly-action/settings/environments
environment:
name: remove-old-wheels

steps:
- name: Install micromamba and anaconda-client
uses: mamba-org/setup-micromamba@v1
with:
environment-name: remove-wheels
create-args: >-
python=3.11
anaconda-client

- name: Remove test package upload
run: |
anaconda --token ${{ secrets.ANACONDA_TOKEN }} remove \
--force \
"scientific-python-nightly-wheels/test-package"
Copy link
Member Author

Choose a reason for hiding this comment

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

This should now remove the test-package package that gets uploaded just previously in the test job.

* Add simplest example package to tests so that it can be built for
  upload to Anaconda cloud as a test of the action.
   - Use setuptools as the build backend over something more obvious like
   hatchling given the simple nature of the test-package given that
   anaconda-client v1.12.0 doesn't understand valid metadata from PEP 518
   build backends other than setuptools.
   c.f. anaconda/anaconda-client#676
* Add CI GitHub Action workflow to test the functionality of the action
  as shown in the README.
anaconda-client

- name: Remove test package upload
shell: bash -l {0}
Copy link
Member Author

@matthewfeickert matthewfeickert Aug 1, 2023

Choose a reason for hiding this comment

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

Okay final burst of noise (sorry) to add in this shell line so that conda works in Actions. This works as expected (just tested on a debug branch on the main project).

@matthewfeickert
Copy link
Member Author

matthewfeickert commented Aug 3, 2023

👋 @bsipocz if you get time before the end of the week can you review if the changes I made given your original comments address them?

@matthewfeickert matthewfeickert requested review from bsipocz and removed request for bsipocz August 9, 2023 19:00
@bsipocz
Copy link
Member

bsipocz commented Aug 9, 2023

if you get time before the end of the week can you review if the changes I made given your original comments address them?

it would be super nice to allow a quick re-review if commits made after the review were not squashed into the original one. We do squash on merge anyway, so squashing in the PR has no actual benefits.

@matthewfeickert
Copy link
Member Author

it would be super nice to allow a quick re-review if commits made after the review were not squashed into the original one.

@bsipocz see #27 (review)

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

OK, I can't spot any more issues, let's try and see it indeed passes after merge.

@bsipocz bsipocz merged commit b4720c6 into scientific-python:main Aug 9, 2023
1 of 2 checks passed
@matthewfeickert matthewfeickert deleted the ci/add-tests branch August 11, 2023 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests and CI
4 participants