question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create a JS utility to generate a GitHub comparison URL

See original GitHub issue

If you haven’t already, check out our contributing guidelines for onboarding!


Problem

As part of our new Expensify.cash Deploy & QA process, we’ll need an easy way to view differences between versions. To do so, we’ll generate links to a GitHub comparison.

Why is this important?

This will be an important step for engineers to be able to view changes introduced by a release and track regressions.

Solution

Create a Javascript utility function in expensify-common called generateVersionComparisonURL that takes in:

  1. A repoSlug
  2. A tag (version number)
  3. A semverLevel that’s one of `[‘MAJOR’, ‘MINOR’, ‘PATCH’, ‘BUILD’]

And then:

  1. Fetch the tags of the repo
  2. Search through the results to find the tag of the previous version of the appropriate semverLevel.
  3. Return a URL formatted like: https://github.com/Expensify/Expensify.cash/compare/<previous_version_tag>...<current_version_tag>

Note: If it doesn’t already exist, this function should be stored in a class called GithubUtils that takes in an authenticated octokit client as a parameter to its constructor. This function will be used from the context of Github Actions, where we’ll always have an authenticated client available.

To be considered complete

  • Document testing
  • Provide automated unit tests.

Internal issue Upwork listing

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
roryabrahamcommented, Mar 2, 2021

Whatever the case, a very comprehensive set of automated tests will be the key to success here 👍

1reaction
roryabrahamcommented, Mar 2, 2021

@SombreroElGringo Your proposal here looks good. Just a few comments:

For select the good tag we should slip or use a regex to get the good semverLevel values from the tags received from the API.

You should use the semver library to accomplish this instead of writing your own regexes.

Also, your examples aren’t exactly correct. It should provide a comparison between the highest version of the previous level. Let’s say we have the following tags: 2.2.2-1, 2.2.2, 2.2.1, 2.2.0, 2.1.0-2, 2.1.0-1, 2.1.0, 2.1.2, 2.0.0, 1.1.0 and 1.0.0

generateVersionComparisonURL(“my-repo”, “2.2.2”, “MAJOR”) should return https://github.com/Expensify/Expensify.cash/compare/1.1.0...2.2.2 not 1.0.0...2.2.2

generateVersionComparisonURL(“my-repo”, “2.2.2”, “MINOR”) should return https://github.com/Expensify/Expensify.cash/compare/2.1.2...2.2.2 not 2.1.0

generateVersionComparisonURL(“my-repo”, “2.2.2”, “PATCH”) should return https://github.com/Expensify/Expensify.cash/compare/2.2.1...2.2.2

generateVersionComparisonURL(“my-repo”, “2.2.2-1”, “BUILD”) should return https://github.com/Expensify/Expensify.cash/compare/2.2.2...2.2.2-1 not 2.1.0-2...2.2.2-1

It’s a bit hard to describe with words, but it should provide a comparison between the version passed as a parameter, and the highest version of the previous SEMVER_LEVEL version.

In the case of BUILD, it will always be a comparison with the previous PATCH version. Does that make sense?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Draftable Compare API - Node.js Client Library - GitHub
Node.js client library for the Draftable document comparison API - GitHub ... created: %s", comparison); // Generate a signed viewer URL to access...
Read more >
medialize/URI.js: Javascript URL mutation library - GitHub
Javascript URL mutation library. Contribute to medialize/URI.js development by creating an account on GitHub.
Read more >
About custom actions - GitHub Docs
You can create your own actions, or use and customize actions shared by the GitHub ... You can build Docker container, JavaScript, and...
Read more >
kpdecker/jsdiff: A javascript text differencing implementation.
API. Diff.diffChars(oldStr, newStr[, options]) - diffs two blocks of text, comparing character by character. Returns a list of change objects (See below).
Read more >
SiteDiff CLI - GitHub
SiteDiff makes it easy to see how a website changes. It can compare two similar sites or it can show how a single...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found