-
Notifications
You must be signed in to change notification settings - Fork 9
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
Test buildkite_pipeline_upload
action in CI
#598
base: trunk
Are you sure you want to change the base?
Conversation
Generated by 🚫 Danger |
6a74513
to
755fec6
Compare
755fec6
to
d51ba84
Compare
image: &ruby_version "public.ecr.aws/docker/library/ruby:3.2.2" | ||
propagate-environment: true | ||
environment: | ||
- "RUBYGEMS_API_KEY" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got rid of all this because both were used only once.
echo "--- :fastlane: :buildkite: Test pipeline upload action" | ||
bundle exec fastlane run buildkite_pipeline_upload pipeline_file:.buildkite/pipeline_for_upload_action_test.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered having a dedicated step for this, and maybe we should, but at this point, before getting more feedback, I decided to leave in the same step as the tests.
What do you think?
A dedicated step might make things a bit clearer, but also seems like a lot (including extracting shared setup) for a simple action like this....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with keeping it here
if: build.tag != null | ||
depends_on: | ||
- test | ||
# Note: We intentionally call a separate `.sh` script here (as opposed to having all the | ||
# commands written inline) to avoid leaking a key used in the process in clear in the | ||
# BUILDKITE_COMMAND environment variable. | ||
command: .buildkite/commands/gem-push.sh | ||
plugins: [*docker_plugin] | ||
plugins: | ||
- docker#v5.8.0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version could be moved to the shared vars, too, but given it's used only once I haven't done it yet.
Conversely, the CI toolkit was already setup so I leaned into it rather than removing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One benefit I like with moving the version values in shared-pipeline-vars
is that it's immediately visible when we do a wave of updates what things could be updated and what plugins are in use in the pipeline and what version of each plugin is used, without having to parse through the YML files content to determine this.
So it's more to have all the versions grouped in one single place making them easy to locate, even if some of them don't really need DRY-ing because they're only used once.
# to set up some variables that will be interpolated in the `.yml` pipeline before uploading it. | ||
|
||
CI_TOOLKIT_PLUGIN_VERSION="2.18.2" | ||
RUBY_VERSION=$(cat .ruby-version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be good to use the same version in CI as the project uses locally.
But I'm also open to the idea of decoupling them in case we run into some situation where we want to use a version locally for which Docker has no image.
However, if we run into that scenario, maybe we should take a step back and ask why? Given's Ruby adoption, a version with no Docker image seems odd. Maybe if we end up in that scenario we are doing something odd ourselves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree we should use the same Ruby version for both
# This file is `source`'d before calling `buildkite-agent pipeline upload`, and can be used | ||
# to set up some variables that will be interpolated in the `.yml` pipeline before uploading it. | ||
|
||
CI_TOOLKIT_PLUGIN_VERSION="3.7.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice this is now the latest version. We were a few versions behind.
|
||
steps: | ||
- label: ":ok_hand: If this message is shown, the pipeline upload succeeded" | ||
command: echo "Acknowledged." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make this a bit more useful by, for example, uploading with the shared pipeline vars (see https://github.com/bloom/DayOne-Android/pull/4883/files#diff-dff4b99d4e651ab9d7597876ec8dbe92aa934e42c0fb55f4aadd6c106fc96688R683) and check that a sample value is available
[[ $RUBY_VERSION = $(cat .ruby-version) ]] || false
Alternatively we could use a dedicated file so that the test is more straightforward
[[ $TEST_VALUE_FOR_PIPELINE_UPLOAD_WITH_ENV_FILE = "this string is defined in the file at .buildkite/test_env" ]] || false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think it could be valuable to test those indeed. After all this is a key feature of the action we might want to test via integration testing:
- Make the action load the
shared-pipeline-vars
(which should be the default, btw) and validate that env vars were available - Provide a Hash of specific env vars to the action's
environment
parameter and validate they were taken into account too. That being said, I'm not sure if it's possible to pass a Hash from the CLI via thefastlane run
command 🤔
That being said, those features should appear be covered by our unit tests of the action… so we might wonder if it's worth also testing them in integration testing; but that would allow us to ensure Buildkite's behavior with passing env vars via Action.sh
behaves as expected at least and end up interpolated properly, so maybe still useful.
key: test | ||
steps: | ||
- label: "🧪 Build and Test using Ruby {{ matrix.ruby }}" | ||
- label: ":test_tube: Build and Test using Ruby {{ matrix.ruby }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth using the occasion to add a custom check name for that step? (github_commit_status:
or whatever the attribute is called)
echo "--- :fastlane: :buildkite: Test pipeline upload action" | ||
bundle exec fastlane run buildkite_pipeline_upload pipeline_file:.buildkite/pipeline_for_upload_action_test.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with keeping it here
if: build.tag != null | ||
depends_on: | ||
- test | ||
# Note: We intentionally call a separate `.sh` script here (as opposed to having all the | ||
# commands written inline) to avoid leaking a key used in the process in clear in the | ||
# BUILDKITE_COMMAND environment variable. | ||
command: .buildkite/commands/gem-push.sh | ||
plugins: [*docker_plugin] | ||
plugins: | ||
- docker#v5.8.0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One benefit I like with moving the version values in shared-pipeline-vars
is that it's immediately visible when we do a wave of updates what things could be updated and what plugins are in use in the pipeline and what version of each plugin is used, without having to parse through the YML files content to determine this.
So it's more to have all the versions grouped in one single place making them easy to locate, even if some of them don't really need DRY-ing because they're only used once.
|
||
steps: | ||
- label: ":ok_hand: If this message is shown, the pipeline upload succeeded" | ||
command: echo "Acknowledged." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think it could be valuable to test those indeed. After all this is a key feature of the action we might want to test via integration testing:
- Make the action load the
shared-pipeline-vars
(which should be the default, btw) and validate that env vars were available - Provide a Hash of specific env vars to the action's
environment
parameter and validate they were taken into account too. That being said, I'm not sure if it's possible to pass a Hash from the CLI via thefastlane run
command 🤔
That being said, those features should appear be covered by our unit tests of the action… so we might wonder if it's worth also testing them in integration testing; but that would allow us to ensure Buildkite's behavior with passing env vars via Action.sh
behaves as expected at least and end up interpolated properly, so maybe still useful.
@@ -0,0 +1 @@ | |||
15.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be updated to a more recent image at some point (potentially separate PR)?
# to set up some variables that will be interpolated in the `.yml` pipeline before uploading it. | ||
|
||
CI_TOOLKIT_PLUGIN_VERSION="2.18.2" | ||
RUBY_VERSION=$(cat .ruby-version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree we should use the same Ruby version for both
--- | ||
|
||
steps: | ||
- label: ":ok_hand: If this message is shown, the pipeline upload succeeded" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could benefit a custom (and more concise) github_commit_status
.
Could be done in a separate PR though as for it to be useful we'd also want to disable the default status created by Buildkite on each step (in the release-toolkit.tf
of buildkite-ci
) and switch to making all steps have explicit notify
@mokagio I just stumbled upon this old PR while looking at the opened PRs for this repo. It this still relevant? |
@AliSoftware I'd say it's still relevant yet. It doesn't hurt to have these tests does it? However, just to set expectations, I don't think I'll have time to address this before my support rotation next week subsequent AFK. |
What does it do?
Calls the new
buildkite_pipeline_upload
action in CI to upload a dedicated pipeline and have an integration-level test for the action.See #597 (review)
Checklist before requesting a review
bundle exec rubocop
to test for code style violations and recommendationsspecs/*_spec.rb
) if applicablebundle exec rspec
to run the whole test suite and ensure all your tests passCHANGELOG.md
file to describe your changes under the appropriate existing###
subsection of the existing## Trunk
section. – N.A.MIGRATION.md
file to describe how the changes will affect the migration from the previous major version and what the clients will need to change and consider. – N.A.