Skip to content

Add updatecli condition#186

Merged
reakaleek merged 3 commits intoelastic:mainfrom
reakaleek:feature/add-updatecli-condition
May 15, 2023
Merged

Add updatecli condition#186
reakaleek merged 3 commits intoelastic:mainfrom
reakaleek:feature/add-updatecli-condition

Conversation

@reakaleek
Copy link
Copy Markdown
Member

@reakaleek reakaleek commented May 15, 2023

Details

The workflow https://github.com/elastic/opbeans-ruby/actions/runs/4968635143 is failing with "nothing to commit"

Adding a condition should stop the updatecli pipeline to continue if the given version is already installed.

@reakaleek reakaleek self-assigned this May 15, 2023
@reakaleek reakaleek requested a review from a team May 15, 2023 08:20
@reakaleek reakaleek marked this pull request as ready for review May 15, 2023 08:20
Comment thread .ci/bump-opbeans-ruby.yml Outdated
Comment on lines +56 to +57
environments:
- name: PATH
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

unrequired?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The shell script won't be able to use grep, head, awk or any other command if the PATH is not added.

when I add the following lines to the script:

which grep
which head
which awk
which test
echo $version

this is the output without PATH:

checkIfVersionDiffers
---------------------
The shell 🐚 command "bash .ci/scripts/test-version.sh 4.6.2" exited on error (exit code 1) with the following output:
----
----

command stderr output was:
----
----
         => expected condition result false, got false

this is the output with PATH:

checkIfVersionDiffers
---------------------
The shell 🐚 command "bash .ci/scripts/test-version.sh 4.6.2" exited on error (exit code 1) with the following output:
----
/usr/bin/grep
/usr/bin/head
/usr/bin/awk
/bin/test
4.6.2
----

command stderr output was:
----
----
         => expected condition result false, got false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It works in my end:

$ gh pr checkout 186 
$ vim .ci/bump-opbeans-ruby.yml
$ git --no-pager diff
diff --git a/.ci/bump-opbeans-ruby.yml b/.ci/bump-opbeans-ruby.yml
index 84cfd42..15cdefe 100644
--- a/.ci/bump-opbeans-ruby.yml
+++ b/.ci/bump-opbeans-ruby.yml
@@ -53,8 +53,6 @@ conditions:
     sourceid: elastic-apm-agent-ruby
     spec:
       command: bash .ci/scripts/test-version.sh
-      environments:
-        - name: PATH

$ GIT_USER=foo GIT_EMAIL=bar GITHUB_TOKEN=$GITHUB_TOKEN updatecli diff --config .ci/bump-opbeans-ruby.yml  

...
CONDITIONS:
===========

checkIfVersionDiffers
---------------------
The shell 🐚 command "/bin/sh /var/folders/hn/j6gds1qx1f5bysfn0qp0t03c0000gn/T/updatecli/bin/a6a5b89025ff47d8e91d16ce3dbd751bcbbd4c2b1c01716eeb6e5c5cc9b6bc63.sh" exited on error (exit code 1) with the following output:
----
----

command stderr output was:
----
----
shell command failed. Expected exit code 0 but got 1
	 => expected condition result false, got false

✗ condition not met, skipping pipeline

=============================

REPORTS:


- Bump elastic-apm to latest version:
	Source:
		✔ [elastic-apm-agent-ruby]  (kind: gittag)
	Condition:
		✗ [checkIfVersionDiffers] Check if installed version differs (kind: shell)
	Target:
		- [dockerfile-label-schema] Set org.label-schema.version in Dockerfile (kind: file)
		- [dockerfile-opencontainers] Set org.opencontainers.image.version in Dockerfile (kind: file)
		- [gem] Bump elastic-apm (kind: shell)
		- [gemfile] Install new elastic-apm pip dependency version (kind: file)


Run Summary
===========
Pipeline(s) run:
  * Changed:	0
  * Failed:	0
  * Skipped:	1
  * Succeeded:	0
  * Total:	1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In any case, I don't see this is a problem but the opposite, it might help when the environments are not configured

Copy link
Copy Markdown
Member Author

@reakaleek reakaleek May 15, 2023

Choose a reason for hiding this comment

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

That's interesting.

Due to the output not being generated when the PATH is not passed, I assumed it's not working.

But you are right, it seems to have the correct behaviour even without any output.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread .ci/bump-opbeans-ruby.yml Outdated
kind: shell
sourceid: elastic-apm-agent-ruby
spec:
command: bash .ci/scripts/test-version.sh
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

NIT: if .ci/scripts/test-version.sh got execution permissions, and it uses the shebang I'd say bash is not required

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

reakaleek added 2 commits May 15, 2023 10:53
because it has exection permissions and has a shebang already
@reakaleek reakaleek merged commit 187d175 into elastic:main May 15, 2023
@reakaleek reakaleek deleted the feature/add-updatecli-condition branch May 15, 2023 09:06
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