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

feat: Release tools #93

Merged
merged 22 commits into from
Oct 31, 2023
Merged

feat: Release tools #93

merged 22 commits into from
Oct 31, 2023

Conversation

fmarek-kindred
Copy link
Contributor

  • The shell script to bump versions and tag the project
  • The workflow to catch a new tag and publish crates
  • Work also contains the rename of dependency metrics to talos_metrics

@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (800228e) 57.36% compared to head (ffd5d31) 57.35%.

❗ Current head ffd5d31 differs from pull request most recent head 93150cd. Consider uploading reports for the commit 93150cd to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #93      +/-   ##
==========================================
- Coverage   57.36%   57.35%   -0.01%     
==========================================
  Files         115      113       -2     
  Lines        5747     5666      -81     
==========================================
- Hits         3297     3250      -47     
+ Misses       2450     2416      -34     
Files Coverage Δ
packages/cohort_banking/src/metrics.rs 0.00% <ø> (ø)
packages/talos_certifier/src/config.rs 84.33% <100.00%> (ø)
.../src/bin/histogram_decision_timeline_from_kafka.rs 0.66% <ø> (ø)
packages/talos_metrics/src/lib.rs 100.00% <ø> (ø)
packages/talos_metrics/src/model.rs 0.00% <ø> (ø)
.../talos_metrics/src/opentel/aggregation_selector.rs 0.00% <ø> (ø)
packages/talos_metrics/src/opentel/model.rs 0.00% <ø> (ø)
packages/talos_metrics/src/opentel/printer.rs 0.00% <ø> (ø)
packages/talos_metrics/src/opentel/scaling.rs 0.00% <ø> (ø)

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

@@ -22,3 +22,7 @@ serde_json = "1.0"
# Async
tokio = { version = "1", features = ["full", "test-util"] }
async-trait = "0.1"

[workspace.metadata.release]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This section is being read by cargo-release utility.

exit 1
fi

NEXT_VERSION=$(echo $ANSWER | sed 's/-dev//')-dev
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we creating and tagging a dev version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are not tagging dev version.
Why we are creating was explained on Thu in our meeting. In short, the previous version was already tagged, we everything what happens with sources (like development and testing of additional commits) after that does not belong to tagged version any more. Its a standard process.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not really a standard practice I have seen, that is why I would like to understand more on this.

Looking at the script, between the tagging of NEW_VERSION and NEXT_VERSION the only commit inserted is this one here:-

git commit -a -m "chore(npm): Release npm $NEW_VERSION" --no-verify

There is really no need to have NEXT_VERSION, We can always look at the last tag and interpret everything from then is not published.

You can look at tokio, serde or other popular packages, not just in rust but js/other languages as well, there are subsequent commits in master since the last release, but the version is not changed to some alpha, beta, dev..etc.

If something version needs to be tested as alpha, beta..etc, that is only when we create those tags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the script, between the tagging of NEW_VERSION and NEXT_VERSION the only commit inserted is this one here

There is also cargo release line which invokes cargo-release tool. This tool is changing versions in all Cargo.toml files and committing that change. Obviously it cannot do it for NPM modules, so we do it ourselves using the line you copied in your comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is really no need to have NEXT_VERSION

Properly written apps include version number into bundled build. For example, a website may have an invisible watermark in the footer section saying current version is vXYZ, or sent into Google Analytics and etc. The API server may include http header with x-app-version: vXYZ. This info is also used when tagging log lines which are sent to observability aggregator. This information is taken from metadata included in the executable. That metadata typically comes from package.json or from Cargo.toml or from build.gradle (in Java) and etc. When we are running the app which is built after TAG we want to show the true version. If package.json was not updated then app would display NEW_VERSION, but it may be incorrect if between TAG and now there are commits.

I don't understand why in the meeting you had no problems with it, but after I spent time implementing now it seems you are agains a simple version bump with -dev suffix? What harm does it do?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I probably didn't understand the usage of the NEXT_VERSION well, till I actually looked into the implementation.

I agree on having the dev or beta etc tag is helpful, but I just feel we shouldn't make it strict/mandatory to have the second tag, on the release commit, but only have it on need basis. I think this is the part I must have not understood in the last meeting.

echo "Otherwise type version number, for example, type '2.0.0' the tag name will be v2.0.0"
unset ANSWER
read ANSWER
if [ "${ANSWER}" == "a" ] || [ "${ANSWER}" == "" ];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not pass the tag via arguments?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This way we could later plug it as an action in github if required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We create a tag first and then execute publish action. What action do you refer to?

Copy link
Collaborator

Choose a reason for hiding this comment

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

  • I tried earlier today to run the script, and although I ran into some other error related to napi, this led me to think, everytime I run the script and there are errors, when I re-run it, it's pretty cumbersome to repeat the inputs vs just using arguments

  • I think this script is doing too much. This should be run as a pre-publish step with just the below lines

echo """
Bumping versions of all crates to $NEW_VERSION
  
Bumping versions of the following NPMs:
  - cohort_sdk_client         $NEW_VERSION
  - packages/cohort_sdk_js    $NEW_VERSION
"""

currentDir=$(pwd)
cd cohort_sdk_client
npm version $NEW_VERSION
cd $currentDir
cd packages/cohort_sdk_js
npm version $NEW_VERSION
cd $currentDir
git add --all
git commit -a -m "chore(npm): Release npm $NEW_VERSION" --no-verify

# This will update version in Cargo.toml files and in dependencies, then commit
cargo release --workspace --no-confirm --no-tag --no-publish --no-push -x $NEW_VERSION

returnStatus=$(($?+0))

We shouldn't control through the script how the versions are created, we don't need to. Any one should be able to use standard git tag command and create a tag and push.

The publish github action should get the versions ready for publishing to npm and cargo via the above lines of code.

And finally publish.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry you have to explain it in details. The way you described will not work, because git tag is not the only step here.

Lets me say that using of script is optional and all can be done manually. With script it is easier as it makes sure that there are no mistakes in "releasing" from dirty woking tree, or from non-master branch, unless person specifies it explicitly with argument. With script tag annotation and commit annotations become standard, without typos. Version bumps are automated and committed. In the end of the day the release script is bumping versions, committing and tagging. Tag push is manual step of course.

Do you have another release process in mind?

Copy link
Collaborator

@gk-kindred gk-kindred Oct 31, 2023

Choose a reason for hiding this comment

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

No, the script is very useful. But what I am suggesting is we shouldn't enforce creating the tags only using this script.

So right now, this script is responsible for

  • NEW VERSION
    • Getting the version from user
    • Bumping versions in package.json
    • Bumping versions in Cargo.toml
    • Create a release commit
    • Tagging the repo
      -NEXT VERSION
    • Getting the version from user
    • Bumping versions in package.json
    • Bumping versions in Cargo.toml
    • Create a release commit

What I was suggesting was:

  • NEW VERSION
    • Getting the version from user
    • Bumping versions in package.json
    • Bumping versions in Cargo.toml
    • Create a release commit
    • Tagging the repo
  • NEXT VERSION
    • Bumping versions in package.json
    • Bumping versions in Cargo.toml
    • Create a release commit
  • Push the commit and tag to remote.

This way, we can use the script in as part of github actions in publish.yaml as the first step before the publishing step.

if [ "${ANSWER}" != "y" ];
then
echo "Your answer was '${ANSWER}'"
exit 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be exit 0 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be 1 to indicate error. Don't we use usually use != 0 as indicator of abort in shell?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is related to my understanding of not really needing NEW_VERSION tag, that is why it is safe to exit with 0

@fmarek-kindred fmarek-kindred merged commit 4e540d9 into master Oct 31, 2023
2 checks passed
@fmarek-kindred fmarek-kindred deleted the feature/release_tools branch October 31, 2023 23:40
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