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

#4163 | Speed-up CI by using published UI artifacts #4251

Merged
merged 6 commits into from
Mar 7, 2023

Conversation

shubbham1215
Copy link
Contributor

@shubbham1215 shubbham1215 commented Feb 22, 2023

Which problem is this PR solving?

Resolves #4163

Short description of the changes

  • Attempt to download UI assets from GitHub release, fall back to regular manual build

@shubbham1215 shubbham1215 changed the title Speed-up CI by using published UI artifacts https://github.com/jaegertracing/jaeger/issues/4163 #4163 | Speed-up CI by using published UI artifacts Feb 22, 2023
@codecov
Copy link

codecov bot commented Feb 22, 2023

Codecov Report

Patch coverage has no change and project coverage change: +0.02 🎉

Comparison is base (29d5688) 97.08% compared to head (af13a21) 97.10%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4251      +/-   ##
==========================================
+ Coverage   97.08%   97.10%   +0.02%     
==========================================
  Files         302      302              
  Lines       17685    17685              
==========================================
+ Hits        17169    17173       +4     
+ Misses        415      412       -3     
+ Partials      101      100       -1     
Flag Coverage Δ
unittests 97.10% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
plugin/storage/integration/integration.go 76.33% <0.00%> (+0.38%) ⬆️
pkg/config/tlscfg/cert_watcher.go 94.81% <0.00%> (+2.22%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

Please explain how the change was tested

Makefile Outdated
cd jaeger-ui && yarn install --frozen-lockfile && cd packages/jaeger-ui && yarn build
cd jaeger-ui

if git describe --exact-match --tags $(git rev-parse HEAD) >/dev/null 2>&1; then
Copy link
Member

Choose a reason for hiding this comment

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

Makefiles don't work with such multi-line scripts, unless you escape them. It may be easier to move all logic into scripts/rebuild-ui.sh

Makefile Outdated
if curl --output /dev/null --silent --head --fail "$release_url"; then
# Download the file and unzip it into packages/build/

curl -L -o assets.tar.gz "$release_url"
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer we use a temp file

tmpfile=$(mktemp)
trap rm tmpfile EXIT

@shubbham1215
Copy link
Contributor Author

@yurishkuro This is still WIP and I need to rework on this. I'll take your suggestions and make the necessary changes.

@shubbham1215
Copy link
Contributor Author

shubbham1215 commented Mar 1, 2023

@yurishkuro I have made some commits on this. I am not exactly sure how to get the version of the head commit. The command $ (git describe --exact-match --tags $(git rev-parse HEAD)) gives me the Hash associated with the latest commit but not the version. Can you look into the commit once?

@yurishkuro
Copy link
Member

This seems to work:

# when on release tag
$ cd jaeger-ui
$ git describe --exact-match --tags
v1.27.3

# when on a commit without release tag
$ git checkout HEAD^1
$ git describe --exact-match --tags
fatal: no tag exactly matches '9b1ee69fa04482fa6e31e186f0ec790f21f28322'
# above also returns with an error code


cd ../jaeger-ui

if git describe --exact-match --tags $(git rev-parse HEAD) >/dev/null 2>&1; then
Copy link
Member

Choose a reason for hiding this comment

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

don't think you need $(git rev-parse HEAD), by default it gives you current commit

if git describe --exact-match --tags $(git rev-parse HEAD) >/dev/null 2>&1; then

# Get the release version from the tag
release_version = $(git describe --exact-match --tags $(git rev-parse HEAD))
Copy link
Member

Choose a reason for hiding this comment

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

no reason to run the same git command twice, read it into a var once



# Check if the corresponding UI release has the assets.tar.gz file uploaded
release_url="https://github.com/jaegertracing/jaeger-ui/releases/download/${release_version}/assets.tar.gz"
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't recommend using the output from git directly like that. Instead, match it against the release tag patter (vN.M.m) and only then use in the URL

if curl --output /dev/null --silent --head --fail "$release_url"; then
curl --location --output "$temp_file" "$release_url"
tar -zxvf "$temp_file" -C packages/jaeger_ui/build/
rm -f "$temp_file"
Copy link
Member

Choose a reason for hiding this comment

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

it's safer to use a trap right after you defined the var

scripts/rebuild-ui.sh Show resolved Hide resolved

# Download the file to the temporary file and extract it into packages/build/
if curl --output /dev/null --silent --head --fail "$release_url"; then
curl --location --output "$temp_file" "$release_url"
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need to check for --head first instead of trying to download right away? I assume it would still return an error exit code if the URL is invalid.

tar -zxvf "$temp_file" -C packages/jaeger_ui/build/
rm -f "$temp_file"

else
Copy link
Member

Choose a reason for hiding this comment

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

rather than having two duplicate else, just call exit 0 here. Something like:

tag=$(git describe ...)
if tag matches pattern; then
    temp_file=$(mktemp)
    trap "rm -f ${temp_file}" EXIT
    if curl ... ; then
        untar
        exit 0
    fi
fi

# do a regular full build
yarn install --frozen-lockfile && cd packages/jaeger-ui && yarn build

@shubbham1215
Copy link
Contributor Author

I have added more commits.

1)Currently the $(git describe --exact-match --tags) command returns v1.27.3. Then it matches it with release tag patter(vN.M.m) and then tries the download it right away. As the assets file does not exist for this version, it fails with an exit code 0 and stops the execution. Do I need to make a change such that if it fails we perform a full build?

  1. I tried to hardcode the tag variable with "v1.27.4" and then running the make run-all-in-one command. It was able to download the assets file and unzip it but later the build failed with the error
    {"level":"panic","ts":1677953320.4700572,"caller":"app/static_handler.go:58","msg":"Could not create static assets handler","error":"cannot load index.html: cannot open index.html: open actual/index.html.gz: file does not exist"

Is this only because the current backend version is not compatible with the assets file that was downloaded or are there more changes required?

@yurishkuro
Copy link
Member

you can bump your local Jaeger repo to v1.27.4 of the UI:

$ pwd
.../dev/jaegertracing/jaeger
$ cd jaeger-ui
$ git checkout v1.27.4

to restore it back

$ pwd
.../dev/jaegertracing/jaeger
$ git submodule update

@yurishkuro
Copy link
Member

The error seems to suggest that your build did not place the assets in the right place where they could be picked up by the UI build.

Makefile Outdated
@@ -214,7 +214,9 @@ jaeger-ui/packages/jaeger-ui/build/index.html:

.PHONY: rebuild-ui
rebuild-ui:
cd jaeger-ui && yarn install --frozen-lockfile && cd packages/jaeger-ui && yarn build
cd scripts && ./rebuild-ui.sh
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cd scripts && ./rebuild-ui.sh
./scripts/rebuild-ui.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah -C flag was creating packages/jaeger-ui/build/ again. Have fixed this with the latest commit

@shubbham1215
Copy link
Contributor Author

shubbham1215 commented Mar 4, 2023

The build succeeds after we bump the UI version to v1.27.4. But fails for the version v1.27.3 as it tries to download right away and does not find the assets file and it exits after that. @yurishkuro Do I need to change this? The tests that have failed are because this issue.
Also please review Makefile changes again. I added one line in it to give permission for rebuild-ui.sh script.It works but not sure if it is the right way.

@shubbham1215 shubbham1215 reopened this Mar 6, 2023
Makefile Outdated
Comment on lines 217 to 218
chmod u+x scripts/rebuild-ui.sh && ./scripts/rebuild-ui.sh
Copy link
Member

Choose a reason for hiding this comment

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

just call it with bash

Suggested change
chmod u+x scripts/rebuild-ui.sh && ./scripts/rebuild-ui.sh
bash ./scripts/rebuild-ui.sh

@yurishkuro
Copy link
Member

I am going to merge #4282 soon so that v1.27.4 becomes the current version on main, then you can rebase and we'll see if the tests run

@shubbham1215 shubbham1215 marked this pull request as ready for review March 6, 2023 21:18
@shubbham1215 shubbham1215 requested a review from a team as a code owner March 6, 2023 21:18
trap "rm -f ${temp_file}" EXIT
release_url="https://github.com/jaegertracing/jaeger-ui/releases/download/${tag}/assets.tar.gz"

if curl -O "$release_url"; then
Copy link
Member

Choose a reason for hiding this comment

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

when I ran this, I got assets.tar.gz in the local dir. Why do you need to call curl twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess it was part of some earlier commit wherein I was first checking if the file exists instead of downloading right away. I have fixed this.

scripts/rebuild-ui.sh Outdated Show resolved Hide resolved
Signed-off-by: Yuri Shkuro <[email protected]>
@yurishkuro yurishkuro enabled auto-merge (squash) March 7, 2023 03:42
@yurishkuro yurishkuro disabled auto-merge March 7, 2023 03:44
@yurishkuro yurishkuro enabled auto-merge (squash) March 7, 2023 03:44
@yurishkuro yurishkuro merged commit 579b24b into jaegertracing:main Mar 7, 2023
@yurishkuro
Copy link
Member

Thank you!

@shubbham1215 shubbham1215 deleted the softwarearchitecture branch March 7, 2023 10:48
@shubbham1215 shubbham1215 restored the softwarearchitecture branch March 18, 2023 17:50
yurishkuro added a commit that referenced this pull request Mar 19, 2023
Which problem is this PR solving?

Resolves #4163


Short description of the changes

Issues raised by the previous pull request at
#4251

---------

Signed-off-by: shubbham1215 <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]>
@bobrik
Copy link
Contributor

bobrik commented Jun 26, 2023

This broke our internal build where we have some patches for jaeger-ui applied. Perhaps we should check for a clean git tree before downloading the jaeger-ui archive from GitHub.

bobrik added a commit to bobrik/jaeger that referenced this pull request Jun 26, 2023
The previous behavior resulted in the prebuild upstream package
being downloaded, even if the local tree has any changes,
whether they are commited or not. This broke our internal
build that has some patches applied. See:

* jaegertracing#4251 (comment)

Let's use a more strict approach and only use the prebuild package
if the tag is exact and does not contain any extra changes.
@bobrik
Copy link
Contributor

bobrik commented Jun 26, 2023

I made #4553 to rectify this.

bobrik added a commit to bobrik/jaeger that referenced this pull request Jun 26, 2023
The previous behavior resulted in the prebuild upstream package
being downloaded, even if the local tree has any changes,
whether they are commited or not. This broke our internal
build that has some patches applied. See:

* jaegertracing#4251 (comment)

Let's use a more strict approach and only use the prebuild package
if the tag is exact and does not contain any extra changes.

Signed-off-by: Ivan Babrou <[email protected]>
bobrik added a commit to bobrik/jaeger that referenced this pull request Jun 26, 2023
The previous behavior resulted in the prebuild upstream package
being downloaded, even if the local tree has any changes,
whether they are commited or not. This broke our internal
build that has some patches applied. See:

* jaegertracing#4251 (comment)

Let's use a more strict approach and only use the prebuild package
if the tag is exact and does not contain any extra changes.

Signed-off-by: Ivan Babrou <[email protected]>
yurishkuro pushed a commit that referenced this pull request Jun 29, 2023
The previous behavior resulted in the prebuild upstream package being
downloaded, even if the local tree has any changes, whether they are
commited or not. This broke our internal build that has some patches
applied. See:

*
#4251 (comment)

Let's use a more strict approach and only use the prebuild package if
the tag is exact and does not contain any extra changes.

Signed-off-by: Ivan Babrou <[email protected]>
kjschnei001 pushed a commit to kjschnei001/jaeger that referenced this pull request Jun 29, 2023
…racing#4553)

The previous behavior resulted in the prebuild upstream package being
downloaded, even if the local tree has any changes, whether they are
commited or not. This broke our internal build that has some patches
applied. See:

*
jaegertracing#4251 (comment)

Let's use a more strict approach and only use the prebuild package if
the tag is exact and does not contain any extra changes.

Signed-off-by: Ivan Babrou <[email protected]>
Signed-off-by: KevinSchneider <[email protected]>
afzal442 pushed a commit to Cloud-Hacks/jaeger that referenced this pull request Jul 10, 2023
…racing#4553)

The previous behavior resulted in the prebuild upstream package being
downloaded, even if the local tree has any changes, whether they are
commited or not. This broke our internal build that has some patches
applied. See:

*
jaegertracing#4251 (comment)

Let's use a more strict approach and only use the prebuild package if
the tag is exact and does not contain any extra changes.

Signed-off-by: Ivan Babrou <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
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.

Speed-up CI by using published UI artifacts
3 participants