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

Run multiple versions of PostgreSQL in CI build matrix #6

Merged
merged 7 commits into from
Feb 13, 2024

Conversation

meshy
Copy link
Contributor

@meshy meshy commented Feb 13, 2024

This changes CI to run the tests against multiple versions of PostgreSQL.

To keep the build matrix low, and reduce CI time, we test all Python version at once with tox.

@meshy meshy force-pushed the postgres-ci-matrix branch from a9a2628 to 87e275e Compare February 13, 2024 13:39
@meshy meshy marked this pull request as ready for review February 13, 2024 13:48
@meshy meshy force-pushed the postgres-ci-matrix branch from e855901 to 2f5a097 Compare February 13, 2024 13:52
Copy link
Contributor

@samueljsb samueljsb left a comment

Choose a reason for hiding this comment

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

I'd like more of an explanation of why we're doing a matrix for Postgres but putting all of the pythons in one job. I'm happy to believe you that it's faster, but a bit more detail would be reassuring

Comment on lines +17 to +22
postgres-image:
- "postgres:12"
- "postgres:13"
- "postgres:14"
- "postgres:15"
- "postgres:16"
Copy link
Contributor

Choose a reason for hiding this comment

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

(nitpick) why two different syntaxes for arrays?

Copy link
Contributor Author

@meshy meshy Feb 13, 2024

Choose a reason for hiding this comment

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

I've removed the other array syntax (assuming you're asking about the old one-line python-version). I prefer this one because diffs will be clearer when we change the supported versions.

If you're referring to the new multi-line definition for the python-version, that's a different data structure. I'm not sure which, tbh. I copied it from the docs.

Ref: https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#specifying-multiple-pythonpypy-versions

@@ -9,6 +9,7 @@ This package is tested against:

- Python 3.10, 3.11, or 3.12.
- Django 4.1, 4.2, or 5.0.
Copy link
Contributor

Choose a reason for hiding this comment

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

(out of scope) should we add Django to the matrix, too?

Copy link
Contributor Author

@meshy meshy Feb 13, 2024

Choose a reason for hiding this comment

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

Django is in the tox matrix already.

Comment on lines +43 to +46
python-version: |
3.12
3.11
3.10
Copy link
Contributor

Choose a reason for hiding this comment

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

Why all in one job rather than a job for each?

Copy link
Contributor Author

@meshy meshy Feb 13, 2024

Choose a reason for hiding this comment

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

When we do one job per python per postgres, the billable GHA time is 41 minutes.

When combining these and running them in parallel, it's just 15 minutes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update: my latest commit avoids installing unused requirements, and gets that down to 12 minutes.

@meshy
Copy link
Contributor Author

meshy commented Feb 13, 2024

I'd like more of an explanation of why we're doing a matrix for Postgres but putting all of the pythons in one job. I'm happy to believe you that it's faster, but a bit more detail would be reassuring

Tox is good at managing the different versions of Python and Django, so I'm happy to let it do that. Using it also allows us to run the tests in parallel, both locally and in CI.

Tox wouldn't be great for running multiple versions of Postgres, so I've delegated that to GitHub Actions. I don't think it's going to be important (or convenient) for local development to run against a matrix of Postgres versions, so I don't think it's a significant loss.

Before this change, we installed all the requirements used to run the
tests, when we only needed tox. Tox would then install those same
requirements in each of the virtual environments it created.

This change installs only tox in CI, trusting that it's the only package
required to run the tests.
@meshy meshy merged commit 7fadd85 into main Feb 13, 2024
6 checks passed
@meshy meshy deleted the postgres-ci-matrix branch February 13, 2024 18:23
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.

2 participants