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

Add auto-layer-releases flow to deploy flow #1274

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

hmstepanek
Copy link
Contributor

Overview

Move auto-layer-releases flow from lambda to GHA.

@hmstepanek hmstepanek requested a review from a team as a code owner December 16, 2024 20:15
Copy link

github-actions bot commented Dec 16, 2024

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ YAML prettier 1 0 0 0.43s
✅ YAML v8r 1 0 2.69s
✅ YAML yamllint 1 0 0.26s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@codecov-commenter
Copy link

codecov-commenter commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.61%. Comparing base (4c06d26) to head (0988d57).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1274      +/-   ##
==========================================
- Coverage   79.68%   79.61%   -0.07%     
==========================================
  Files         201      201              
  Lines       22174    22174              
  Branches     3519     3519              
==========================================
- Hits        17669    17654      -15     
- Misses       3355     3363       +8     
- Partials     1150     1157       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -0,0 +1,70 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#!/bin/bash
#!/usr/bin/env python3

Comment on lines 19 to 38
# How to use this script:
# Set the following env vars:
# * GH_RELEASE_TOKEN
# * LAMBDA_RUNTIME (optional)
# * INITCONTAINER_RUNTIME (optional)
# * AGENT_VERSION
# * DRY_RUN (optional) set to 1 to run the flow without creating the release tag.
#
# Lambda runtime options:
# nodejs
# python
# ruby
# dotnet
#
# Initcontainer runtime options:
# nodejs
# python
# ruby
# java
# dotnet
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't you make those a constant, so we don't have to set those as env vars? Presumably each repo will have a separate copy of this script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well...I was still thinking of making it shared at this point (even though I realize I haven't done that in this PR). I guess TBD on that.

Comment on lines 59 to 60
tag_name = f"{latest_version}.0_{runtime}"
release_name = f"New Relic {runtime} Agent {latest_version}.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

This originally had logic to have release names and release tags as different strings. For Python the only difference was capitalization, but for Node and .NET it was Node -> nodejs, and .NET -> dotnet.

Why not make constants for TAG_SUFFIX="python" and RUNTIME_NAME="Python". Then maybe use bool constants to toggle on/off the lambda and initcontainer releases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oooh you're totally right! I was trying to simplify those out but they were used for the release name-I'll put those back I guess. Instead of a boolean I was thinking each team could just set the value of those and that way the work flow could be shared across all teams-I need to look into that more though to see if we can do that.

@TimPansino
Copy link
Contributor

As a general thought, is there a reason not to convert this to bash scripting and use the gh CLI? Seems like it would be easier for other teams to manage, and we could then just add the code directly into the release flow as a step.

@hmstepanek
Copy link
Contributor Author

As a general thought, is there a reason not to convert this to bash scripting and use the gh CLI? Seems like it would be easier for other teams to manage, and we could then just add the code directly into the release flow as a step.

I was actually thinking about this after I pushed this up as a Python script. Since we seem to both have had that thought, I'll just go ahead and do that. I agree-it would be easier to maintain that way for each team in the long run.

@hmstepanek hmstepanek force-pushed the add-layers-release-flow-to-gha branch from ad59deb to 30b2816 Compare December 17, 2024 23:12
@hmstepanek hmstepanek force-pushed the add-layers-release-flow-to-gha branch from 690b061 to 9ac223d Compare January 6, 2025 21:53
@@ -182,3 +182,16 @@ jobs:
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}

- name: Create release tags for Lambda and K8s Init Containers
uses: dev-hanz-ops/install-gh-cli-action@c78dbed4be2f8d6133a14a9a597ee12fd4ed5c93 # v3
Copy link
Contributor

Choose a reason for hiding this comment

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

gh should be preinstalled on all runners, I think this 3rd party action is unnecessary.

https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-github-cli-in-workflows

@hmstepanek hmstepanek requested a review from TimPansino January 7, 2025 01:19
Comment on lines +186 to +192
- name: Create release tags for Lambda and K8s Init Containers
run: |
gh auth login --with-token <<< $GH_RELEASE_TOKEN
echo "newrelic/newrelic-lambda-layers - Releasing New Relic Python Agent ${GITHUB_REF}.0 with tag ${GITHUB_REF}.0_python"
gh create release "${GITHUB_REF}.0_python" -t "New Relic Python Agent ${GITHUB_REF}.0" --repo=newrelic/newrelic-lambda-layers
echo "newrelic/newrelic-agent-init-container - Releasing New Relic Python Agent ${GITHUB_REF}.0 with tag ${GITHUB_REF}.0_python"
gh create release "${GITHUB_REF}.0_python" -t "New Relic Python Agent ${GITHUB_REF}.0" --repo=newrelic/newrelic-agent-init-container
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- name: Create release tags for Lambda and K8s Init Containers
run: |
gh auth login --with-token <<< $GH_RELEASE_TOKEN
echo "newrelic/newrelic-lambda-layers - Releasing New Relic Python Agent ${GITHUB_REF}.0 with tag ${GITHUB_REF}.0_python"
gh create release "${GITHUB_REF}.0_python" -t "New Relic Python Agent ${GITHUB_REF}.0" --repo=newrelic/newrelic-lambda-layers
echo "newrelic/newrelic-agent-init-container - Releasing New Relic Python Agent ${GITHUB_REF}.0 with tag ${GITHUB_REF}.0_python"
gh create release "${GITHUB_REF}.0_python" -t "New Relic Python Agent ${GITHUB_REF}.0" --repo=newrelic/newrelic-agent-init-container
- name: Create release tags for Lambda and K8s Init Containers
run: |
RELEASE_TITLE="New Relic Python Agent ${GITHUB_REF}.0"
RELEASE_TAG="${GITHUB_REF}.0_python"
RELEASE_NOTES="Automated release for [Python Agent ${GITHUB_REF}](https://github.com/newrelic/newrelic-python-agent/releases/tag/${GITHUB_REF})"
gh auth login --with-token <<< $GH_RELEASE_TOKEN
echo "newrelic/newrelic-lambda-layers - Releasing ${RELEASE_TITLE} with tag ${RELEASE_TAG}"
gh release create "${RELEASE_TAG}" --title=${RELEASE_TITLE} --repo=newrelic/newrelic-lambda-layers --notes=${RELEASE_NOTES}
echo "newrelic/newrelic-agent-init-container - Releasing ${RELEASE_TITLE} with tag ${RELEASE_TAG}"
gh release create "${RELEASE_TAG}" --title=${RELEASE_TITLE} --repo=newrelic/newrelic-agent-init-container --notes=${RELEASE_NOTES}

I have 3 suggestions here, going to lump them together but if you don't like one of them I can separate it.

  1. You have the subcommands backwards: gh create release -> gh release create
  2. To make this slightly more DRY so it's easier to update for other agents, can we maybe pull these repeated expressions out into constants that are created once and then referenced?
  3. This would be a good opportunity to fix a random issue that annoys me, the release notes that are autogenerated by Github when none are supplied just ends up being the last commit message, which looks really strange and confusing when they have nothing to do with the agent being released. Can we provide a simple release note that just redirects to the original agent release on Github? That way it will always point to both the ref on Github and the actual release notes from that release are either there or linked on our docs site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants