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

Better build and release #1873

Merged
merged 6 commits into from
Aug 14, 2024
Merged

Better build and release #1873

merged 6 commits into from
Aug 14, 2024

Conversation

nickstenning
Copy link
Member

@nickstenning nickstenning commented Aug 13, 2024

This PR contains several changes which attempt to improve how we build and release Cog.

  1. When building cog's Go binary, we embed the wheel with the full path generated by build. This makes it clearer what version of cog's Python package is being injected by any given cog binary at runtime.
  2. Omit test files from the built wheel.
  3. Run tests against the cog package installed from the built wheel, not against an editable installation from the local directory.
  4. Use goreleaser to build cog so we have only one way of building the cog binary, not two.
  5. Make Python and Go "dev" versions aligned -- if the most recent tag is v1.2.3, a build on an untagged commit should now be 1.2.4-dev+g1234abcd by default. The Python version will differ slightly as it is a PEP440 version, not a semver version, but the generated versions should now be largely comparable.

@nickstenning nickstenning force-pushed the better-build-and-release branch 9 times, most recently from d937436 to e660f80 Compare August 13, 2024 15:20
@nickstenning nickstenning requested a review from a team August 13, 2024 17:56
@nickstenning
Copy link
Member Author

There's more I want to do here, specifically to replace the release.yaml workflow, but this is more than enough for one PR so I'm stopping here.

@nickstenning nickstenning force-pushed the better-build-and-release branch 2 times, most recently from 9283484 to fc7f760 Compare August 13, 2024 18:16
.github/workflows/ci.yaml Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
pkg/dockerfile/generator.go Show resolved Hide resolved
This changes the Go build to use a wheel with the full version
identifier in its filename. In addition to making it clearer which
version of Cog is being embedded while building, this also allows us to
supply a pre-built wheel in CI.
This slims down our wheel from about 100K to about 56K.

In a followup commit, we'll run the tests against the `cog` package
installed from the built wheel, so we're testing the code exactly as it
will be installed in a consumer environment.
@nickstenning nickstenning force-pushed the better-build-and-release branch 2 times, most recently from 9090595 to 07ffaff Compare August 13, 2024 20:53
This splits the building of the Python package into its own job, and
then runs the tests against the built package. This gives us the
greatest chance of testing exactly the code we run in a consumer
environment.

It will also allow us to build and push the PyPI package in a separate
workflow, knowing that the package we build from the same source ref
will be identical.
This is required by recent versions of goreleaser so we might as well
bump this here.
@nickstenning nickstenning force-pushed the better-build-and-release branch 2 times, most recently from cd887f2 to 92b6f17 Compare August 13, 2024 21:28
We use goreleaser to build cog for releases, so to minimise differences
between dev and release, we should also use it to build cog in
development.

This commit updates the build steps in the Makefile to call `goreleaser
build`.
@nickstenning nickstenning force-pushed the better-build-and-release branch from 92b6f17 to 3417f75 Compare August 13, 2024 21:30
@nickstenning nickstenning force-pushed the better-build-and-release branch from 3417f75 to 7572375 Compare August 13, 2024 21:37
@nickstenning nickstenning merged commit 8e5f3fc into main Aug 14, 2024
12 checks passed
@nickstenning nickstenning deleted the better-build-and-release branch August 14, 2024 07:51
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