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

NH-55892 upload workflow #1

Merged
merged 8 commits into from
Dec 6, 2023
Merged

NH-55892 upload workflow #1

merged 8 commits into from
Dec 6, 2023

Conversation

xuan-cao-swi
Copy link

No description provided.

@xuan-cao-swi xuan-cao-swi requested a review from a team November 30, 2023 18:07
Copy link

@cheempz cheempz left a comment

Choose a reason for hiding this comment

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

Thanks @xuan-cao-swi! I left some comments, and similar to the PR for apm-ruby let's use the automatic GITHUB_TOKEN for this workflow too.

Another question is: do you intend to merge our changes directly to main, or create a long-lived "solarwinds" branch that would hold our custom code? The latter would require more branch management but allow us better control on what upstream pieces to merge in, visibility and code review of our changes (for example add a CODEOWNERS file for our branch).

description: 'The path that package you want to publish (should include /)'
# metrics_sdk/
# metrics_api/
# exporter/otlp/
Copy link

Choose a reason for hiding this comment

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

Instead of needing an input, we should be able to determine the path to the package based on the gem we want to publish, right? Taking a look at how upstream OTel Ruby does releases, it uses a toys gem which may not suit our needs since it seems to only support releasing to rubygems, but it does have a defined mapping of gems and paths which IMHO is a good idea.

Choose a reason for hiding this comment

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

@xuan-cao-swi have you tried the defined mapping approach that @cheempz suggested here?

IIUC, the sw_build_and_push_gem.sh script finds the correct path given GEM_NAME and now exits with 1 if it cannot be found. I'm wondering if a defined mapping could save on errors from typos.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I looked into the toys library but unfortunately, if I want to use toy, then I have to make modification on upstream files, which may cause file conflicts in the future when I pull from upstream. That's why I choose to explore the shell script approach. Plus, the pre-defined mapping only works for existing GEM_NAME, if I want to introduce a new gem, then in that case I have to change the mapping again.

.github/workflows/push-package-solarwinds.yml Outdated Show resolved Hide resolved
description: 'The name that package you want to publish'
# opentelemetry-metrics-sdk
# opentelemetry-metrics-api
# opentelemetry-exporter-otlp
Copy link

Choose a reason for hiding this comment

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

Can you put in an actual gem name from our fork that we'd publish in the suggestion above, and remove these comments which don't apply to this repo?

.github/workflows/push-package-solarwinds.yml Outdated Show resolved Hide resolved
echo -e "---\n:github: Bearer $GITHUB_SECRET_TOKEN" >> ~/.gem/credentials
chmod 0600 ~/.gem/credentials
env:
GITHUB_SECRET_TOKEN: ${{ secrets.GH_PACKAGE_TOKEN }}
Copy link

Choose a reason for hiding this comment

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

Let's change this to use GITHUB_TOKEN.

xuan-cao-swi and others added 3 commits December 4, 2023 11:47
@xuan-cao-swi
Copy link
Author

Another question is: do you intend to merge our changes directly to main, or create a long-lived "solarwinds" branch that would hold our custom code? The latter would require more branch management but allow us better control on what upstream pieces to merge in, visibility and code review of our changes (for example add a CODEOWNERS file for our branch).

Yes, I intend to merge to main.
To update with upstream, we just need to pull, and since these workflow files are new, so there won't be any file conflict.
For every new feature we have, I can create gem based on separate branches (these branches certainly will be up-to-dated with upstream)

- name: Setup secrets
run: |
mkdir ~/.gem
echo -e "---\n:github: Bearer $GITHUB_SECRET_TOKEN" >> ~/.gem/credentials

Choose a reason for hiding this comment

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

I think this file could be shortened by not setting env below and directly using secrets.GITHUB_TOKEN

Copy link
Author

Choose a reason for hiding this comment

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

I don't think that will work. Do you have any reference that I can take look?

Choose a reason for hiding this comment

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

Ah ok. We can keep it that way.


GEM_NAME="$1"

cd "instrumentation/$GEM_NAME"

Choose a reason for hiding this comment

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

I recommend running this script through shellcheck to lint the bash.

Copy link
Author

Choose a reason for hiding this comment

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

updated with lint for shell

Choose a reason for hiding this comment

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

Thanks!

@@ -0,0 +1,37 @@
# Copyright (c) 2023 SolarWinds, LLC.

Choose a reason for hiding this comment

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

Is there a reason for having this header instead of the full Apache license? Same for the other file.

Copy link
Author

Choose a reason for hiding this comment

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

No particular reason. Just realized there is no header for all workflows so I removed it. Other files are out of my hand since they are from upstream.

gem_version=$(grep -E "VERSION\s*=\s*'[^']+'" "$found_file" | awk -F "'" '{print $2}')

# build and push gem
gem build "opentelemetry-instrumentation-$GEM_NAME.gemspec"

Choose a reason for hiding this comment

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

What happens with gem build if there is a typo in the input gem name?

Copy link
Author

@xuan-cao-swi xuan-cao-swi Dec 5, 2023

Choose a reason for hiding this comment

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

actually, if there is a typo of the gem name, then it won't find the correct path, and based on the linted line 5 (cd "instrumentation/$GEM_NAME" || exit), it will exit from shell script (kind remind me to give an exit status code)

Choose a reason for hiding this comment

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

Nice!

@xuan-cao-swi xuan-cao-swi merged commit 3ef783e into main Dec 6, 2023
46 checks passed
@xuan-cao-swi xuan-cao-swi deleted the package-workflow branch December 6, 2023 19:01
@cheempz cheempz changed the title upload workflow NH-55892 upload workflow Dec 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants