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

Fix and re-enable CI tests #54

Merged
merged 13 commits into from
Mar 19, 2024
Merged

Fix and re-enable CI tests #54

merged 13 commits into from
Mar 19, 2024

Conversation

martyngigg
Copy link
Member

@martyngigg martyngigg commented Mar 19, 2024

A few years ago we renamed all of the default branches to main. This basically deactivated the CI tests as they had master explicitly stated as a target branch.

This PR fixes the workflow and overhauls the testing script to make it more flexible to use locally. The script now also accepts arguments to run a subset of the tests.

Testing

  • Check out this branch.
  • If you have a .env file and pgdata directory run bash run_web_tests.sh to use the existing environment
  • To test the script creating new .env files for you
    • rename .env to .env.backup and run bash run_web_tests.sh. It should fail saying you have a pgdata directory.
    • rename pgdata to pgdata.backup and rerun the script. It will create a .env file for the tests and remove both this and the generated pgdata directory at the end. You can restore your files by renaming them back.
  • Try passing arguments to the script, e.g. bash run_web_tests services/ to limit the tests that will run.

Setting the slack hook to an empty string is the easiest
way to disable to hook for testing.
The old script stomped on .env files and did no cleanup.
The new script uses and existing .env/DB if it exists and
generates one a .env file if not. If a .env file and DB did
not exist then they are cleaned at the end.

Services are also only booted if they are not already running.
Arguments are passed directly to python manage.py test command
Set a default DEBUG value to avoid compose warning
A volume is used for this now.
The postgres container chowns the bind mounted directory
and this can then require sudo to remove on the host.
Users will need to remove pgdata by hand if they want to.
This works in the case that we don't own the DB directory.
Copy link
Contributor

@jhaigh0 jhaigh0 left a comment

Choose a reason for hiding this comment

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

Good changes that work as describe. When running the tests without an existing .env or database I got a lot of output since debug was turned on. This can be solved by setting it to false in the env file.

@robertapplin robertapplin merged commit 45957bc into main Mar 19, 2024
2 checks passed
@robertapplin robertapplin deleted the fixing-ci-tests branch March 19, 2024 15:34
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.

None yet

3 participants