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

Update python_unit_test.yaml #28

Merged
merged 63 commits into from
May 31, 2023
Merged

Update python_unit_test.yaml #28

merged 63 commits into from
May 31, 2023

Conversation

AidanHilt
Copy link
Contributor

@AidanHilt AidanHilt commented Sep 23, 2022

This PR adds a reusable workflow that we can use to run unit tests for Python. It supports having a script passed as an argument for custom set up, testing multiple modules, and running multiple sets of tests. It also provides a built-in postgres database, for services that require one.

.github/workflows/python_unit_test.yaml Outdated Show resolved Hide resolved
@@ -7,6 +7,10 @@ on:
description: 'A URL identifying a Bash script that can run commands needed for service-specific test setup'
Copy link
Collaborator

Choose a reason for hiding this comment

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

imo this repo-specific test file should be stored in the repo, not here

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there should be anything repo-specific. The whole idea was to make a configurable standard workflow. Install poetry, poetry install, run pytest. Maybe configure whether postgres is needed, maybe configure pytest command 🤷‍♂️

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe also optionally configure the working dir, for example in gen3authz the poetry files and tests files are in a subdir: https://github.com/uc-cdis/gen3authz/blob/dcef644/.travis.yml#L10

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I think there will be repo-specific steps for all users of this, just because the tests are all set up slightly differently across services. That's what the dependency-file-location argument is meant to enable. That being said, I wasn't sure on whether storing those here or in the repo makes more sense, so if you think putting that in the service repo will be a better idea, that sounds good to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have made this an optional item so you can add an input variable to a setup script but if it's not needed then we just skip.

Copy link
Contributor

Choose a reason for hiding this comment

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

I also made Postgresql a optional input boolean.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this URL will work reliably for the setup script on branches? Or I guess the person writing the workflow that uses this template will need to make sure the URL is dynamic based on where the PR is coming from

@AidanHilt
Copy link
Contributor Author

@Avantol13 @paulineribeyre I've updated based on your feedback. The changes to Fence to get the tests working are in this PR: uc-cdis/fence#1046. Could someone please take a look when they get the chance?

Copy link
Collaborator

@paulineribeyre paulineribeyre left a comment

Choose a reason for hiding this comment

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

this looks good for fence, but i think we'll need more flexibility in configuration for other repos, as mentioned in this thread, such as:

  • configure whether postgres is needed
  • configure the working directory
  • configure the pytest command so we can support coverage reports

.github/workflows/python_unit_test.yaml Show resolved Hide resolved
.github/workflows/python_unit_test.yaml Outdated Show resolved Hide resolved
.github/workflows/python_unit_test.yaml Outdated Show resolved Hide resolved
@@ -0,0 +1 @@
echo "No special setup needed! Continuing..."
Copy link
Collaborator

Choose a reason for hiding this comment

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

this file can be deleted

.github/workflows/python_unit_test.yaml Outdated Show resolved Hide resolved
.github/workflows/python_unit_test.yaml Outdated Show resolved Hide resolved
.github/workflows/python_unit_test.yaml Outdated Show resolved Hide resolved
.github/workflows/python_unit_test.yaml Outdated Show resolved Hide resolved
bash ${{ inputs.setup-script }}
else
echo "Setup script ${{ inputs.setup-script }} not found."
fi
- name: Run test
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- name: Run test
- name: Run tests

@AidanHilt AidanHilt merged commit b6f9ce9 into master May 31, 2023
@AidanHilt AidanHilt deleted the feat/reusable-unit-tests branch May 31, 2023 14:17
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.

4 participants