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: bundle latest k6 on build #357

Merged
merged 7 commits into from
Nov 21, 2024
Merged

feat: bundle latest k6 on build #357

merged 7 commits into from
Nov 21, 2024

Conversation

Llandy3d
Copy link
Member

Description

The binaries for k6 have been removed and now the specified version of k6 is retrieved from the k6 github repository during the release ci process. The version is specified by a repository variable called K6_VERSION.

Due to this, the binary is also missing in dev so the npm install has been augmented with a script to retrieve the binary if it's missing.

note: The version for dev is specified inside of the install-k6.js file at this time, so the version is specified in 2 places.

How to Test

  • Clone the repository and npm install making sure you have k6 installed after it.
  • Trigger a manual release from this branch and test that it includes k6.

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (npm run lint) and all checks pass.
  • I have run tests locally (npm test) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Screenshots (if appropriate):

Related PR(s)/Issue(s)

Closes #327

@Llandy3d Llandy3d requested a review from a team as a code owner November 20, 2024 23:54
@Llandy3d Llandy3d requested review from going-confetti and cristianoventura and removed request for a team November 20, 2024 23:54
@@ -18,6 +18,43 @@ jobs:
steps:
- uses: actions/checkout@v4

# get k6 binaries macos
- name: get latest k6 binary macos
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we run the install-k6 script here so that the code isn't duplicated?

Copy link
Member Author

Choose a reason for hiding this comment

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

Great suggestion!
I built them in the opposite order so I didn't think about it, but if it works in the action and both locally for windows as well we might be able to just use the single script 👀

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with running node install-k6.js instead to remove duplication.

Copy link
Collaborator

@cristianoventura cristianoventura left a comment

Choose a reason for hiding this comment

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

We need some adjustments on Windows but it's looking good so far!

Comment on lines +85 to +86
getWindowsK6Binary()
console.log('k6 binary download completed')
Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed a race condition between downloading the binaries and showing the success message while it was still in progress. We can solve this by making executeCommand resolve or reject a Promise or, we can move the success message inside the exec callback.

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Noticed this one as well!
I'm now making use of execSync instead of exec and that fixes the message issue as well 🙌

install-k6.js Outdated

# move to resource folder
Move-Item -Path "${K6_PATH_WIN_AMD}\\k6.exe" -Destination resources\\win\\x86_64
`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed the temp files were still there after the download was complete (they were also showing up in git status). We can add a clean up function here similar to what we have for macOS

Suggested change
`
# clean up
del k6-windows-amd64.zip
Remove-Item -Recurse -Force ${K6_PATH_WIN_AMD}
`

install-k6.js Outdated
const K6_PATH_WIN_AMD = `k6-${K6_VERSION}-windows-amd64`

const existsK6 = (os, arch) => {
return existsSync(`resources/${os}/${arch}/k6`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't working on Windows because of the missing extension (.exe) 😞 We may have to do the os check inside this function instead.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can remove this function now that we are using existsSync directly.

@@ -18,6 +18,43 @@ jobs:
steps:
- uses: actions/checkout@v4

# get k6 binaries macos
- name: get latest k6 binary macos
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with running node install-k6.js instead to remove duplication.

Copy link
Collaborator

@cristianoventura cristianoventura left a comment

Choose a reason for hiding this comment

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

It looks good on both Mac and Windows 🚀 Just one minor thing left.

install-k6.js Outdated
const K6_PATH_WIN_AMD = `k6-${K6_VERSION}-windows-amd64`

const existsK6 = (os, arch) => {
return existsSync(`resources/${os}/${arch}/k6`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can remove this function now that we are using existsSync directly.

@Llandy3d Llandy3d merged commit c10e9f4 into main Nov 21, 2024
2 checks passed
@Llandy3d Llandy3d deleted the k6-binary-automation branch November 21, 2024 19:04
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.

bundle latest k6 version on build
3 participants