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

Use the precompiled 'gotip' on the xk6 workflow #4072

Merged
merged 5 commits into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/workflows/xk6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,26 @@ jobs:
matrix:
go: [stable, tip]
platform: [ubuntu-latest, windows-2019, macos-latest]
runs-on: ubuntu-latest
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like we weren't using matrix.platform, so actually all the jobs were being executed on the same platform 😅

I realized it, because when I tried to use the precompiled Go tip, it complained because the binary wasn't in the expected platform (e.g. a binary built for Windows, trying to be executed on Ubuntu, in this case haha)

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch!

runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
if: matrix.go != 'tip'
uses: actions/setup-go@v5
with:
go-version: 1.23.x
check-latest: true
- name: Download Go tip
if: matrix.go == 'tip'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download ${{ matrix.platform }} --repo grafana/gotip --pattern 'go.zip'
- name: Install Go tip
if: matrix.go == 'tip'
run: |
go install golang.org/dl/gotip@latest
gotip download
unzip go.zip -d $HOME/sdk
echo "GOROOT=$HOME/sdk/gotip" >> "$GITHUB_ENV"
echo "GOPATH=$HOME/go" >> "$GITHUB_ENV"
echo "$HOME/go/bin" >> "$GITHUB_PATH"
Expand All @@ -54,6 +60,13 @@ jobs:
"${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
export XK6_K6_REPO="github.com/${{ github.event.pull_request.head.repo.full_name }}"
fi
# The following is a workaround for Windows, cause when using 'shell: bash', the PATH is expressed
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something I learned along the way, while working on this PR 💡

# with ':' as separator, but Go code, running on a Windows OS, expects ';' as separator.
XPATH="$PATH"
if [[ "${{ matrix.platform }}" == "windows-latest" || "${{ matrix.platform }}" == "windows-2019" ]]; then
XPATH="$HOME/sdk/gotip/bin;$XPATH"
fi
PATH="$XPATH" \
GOPRIVATE="go.k6.io/k6" xk6 build "$COMMIT_ID" \
--output ./k6ext \
--with github.com/grafana/xk6-js-test="$(pwd)/xk6-js-test" \
Expand Down