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: create release workflow #45

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

CI: create release workflow #45

wants to merge 2 commits into from

Conversation

lalver1
Copy link
Member

@lalver1 lalver1 commented Dec 10, 2024

Closes #11

This release workflow is triggered by pushing a calver formatted tag. The workflow:

  • runs tests, builds the app container image, and pushes to GHCR
  • for a release tag, it makes a GitHub release

@lalver1 lalver1 self-assigned this Dec 10, 2024
Copy link

Coverage report

This PR does not seem to contain any modification to coverable code.

@lalver1 lalver1 force-pushed the ci/release-workflow branch from e57be64 to d314ea4 Compare December 10, 2024 21:54
"ci": {
"numberOfRuns": 3,
"settings": {
"preset": "mobile"
Copy link
Member

Choose a reason for hiding this comment

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

I like that you added a lighthouse config + CI test 👍

But I don't think we need to worry about mobile as much for this website. It is decidedly not mobile-first 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah that's true! I'll change it to "desktop" since that's what we actually want to test.

# pre-release tag
- "202[3-9].[0-9][0-9].[0-9]+-rc[0-9]+"
# release tags
- "202[3-9].[0-9][0-9].[0-9]+"
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick but we could start these in 2024, we won't be making a 2023 release 😁

pipdeptree >> pems/static/requirements.txt
- name: Write commit SHA to file
run: echo "${{ github.sha }}" >> pems/static/sha.txt
Copy link
Member

Choose a reason for hiding this comment

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

I'd also like to write the tag to a file like pems/static/version.txt -- can we do that here?

Copy link
Member Author

@lalver1 lalver1 Dec 10, 2024

Choose a reason for hiding this comment

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

I think so, looks like github.ref_name will give us the tag (shortname). So, for example, we could get 2024.12.1 in version.txt

context: .
file: appcontainer/Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
Copy link
Member

@thekaveman thekaveman Dec 10, 2024

Choose a reason for hiding this comment

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

Can we try and tag the Docker image with the git tag as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, since it looks like github.ref_name is what we need, would this tag format (sha-version) work for us?

tags: ghcr.io/${{ github.repository }}:${{ github.sha }}-${{ github.ref_name }}

Copy link
Member

Choose a reason for hiding this comment

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

I was actually suggesting the git tag in addition to the SHA (i.e. keeping them distinct). I think you can do:

tags: |
  ghcr.io/${{ github.repository }}:${{ github.ref_name }}
  ghcr.io/${{ github.repository }}:${{ github.sha }}

Copy link
Member

Choose a reason for hiding this comment

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

Check out these docs referencing the docker/metadata-action -- that seems useful?

- name: Run Lighthouse tests for a11y
uses: treosh/[email protected]
with:
urls: http://localhost:8000
Copy link
Member

Choose a reason for hiding this comment

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

Glad you saw the issue with /help 😁

The other issue is, it isn't certain that 8000 will be the port on localhost.

We may need to introduce an environment variable like DJANGO_LOCAL_PORT, and use that in the compose service (with a default value) to ensure we have a known port binding.

Related, I added DJANGO_DEBUG=true as default in the environment file, but maybe this shouldn't be in there at all. We want the lighthouse tests to run on the non-debug / real app.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, I had overlooked the /help url 😅

Thanks, I modified ports in the compose file (following the way we do it in Benefits) so that we use DJANGO_LOCAL_PORT on localhost if it's available, and if it's not, it defaults to 8000.

Right, I removed DJANGO_DEBUG=true from the environment file. I think this shouldn't be a problems since (at least until now) we only use DJANGO_DEBUG when starting a debugger (and we already set it in the debugger configuration) and in settings.py (and it gets a default value of False so that's ok). If the user wants to set it to True, they can override it in their .env file.

@thekaveman thekaveman added this to the Initial project setup milestone Dec 11, 2024
- pushing a calver formatted tag kicks off a release
- run tests, build app container image, push to GHCR
- for a release tag, make a GitHub release
so that lighthouse tests run on the non-debug / real app
@lalver1 lalver1 force-pushed the ci/release-workflow branch from d314ea4 to 79e1ec3 Compare December 11, 2024 14:55
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.

Create release workflow
2 participants