-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use bash-cache command for .strings validation
#19624
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
Conversation
| echo "--- :writing_hand: Copy Files" | ||
| mkdir -pv ~/.configure/wordpress-ios/secrets | ||
| cp -v fastlane/env/project.env-example ~/.configure/wordpress-ios/secrets/project.env |
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 wonder whether we would benefit from removing the before_all check for this env file and instead rely on the lanes that need secret values to check for their availability.
WordPress-iOS/fastlane/Fastfile
Lines 124 to 126 in adbb17e
| unless File.file?(PROJECT_ENV_FILE_PATH) | |
| UI.user_error!("project.env not found at #{PROJECT_ENV_FILE_PATH}: Make sure your configuration is up to date with `rake dependencies`") | |
| end |
This is the first time the global check bothers me. I guess that's because it's the first time I need to setup the file only to satisfy the check, not because the code I run needs a value from 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.
I actually wondered about this in the past too.
Probably for another PR, and even a small "project" to not only change this on all repos, but also probably get rid of the requirement for ~/.*-env.default files too (which have been bothering me too, not only because those files clutters my $HOME, but also because I don't use those in practice, as I put all my tokens and the likes that we expect in those files… in my ~/.zshrc anyway (since they are mostly the same values for all repos, and I prefer having a single source of truth than one per project)
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.
+1
We could devise a system that checks the environment for all the required tokens, then delegate to each user how to provide them.
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.
It happens that I also just talked about a similar topic with @rynaardb minutes ago, because putting all my tokens in ~/.zshrc like I've been doing will create an issue now that I'll have to do Tumblr releases, which will likely use similar ENV var names for GitHub and Buildkite tokens and the like… but will need different values for it.
My braindump idea to improve on that while avoid polluting $HOME so that each user can provide the required tokens, but still be able to have different tokens (and different values for the same ENV vars) for different repos would basically be:
local_env_file = File.join(PROJECT_ROOT_FOLDER, 'local.env')
Dotenv.load(local_env_file) if File.exist?(local_env_file)And then add local.env to the .gitignore (†).
That way users will have the liberty to either not use that local.env file at all and just declare their ENV vars in ~/.zshrc or wherever they prefer… or, if that's more convenient for them (especially for Release Managers who do releases of different apps that require different tokens), create a local.env file at the root of the dir where they cloned the repo and use that.
(†) The name of the local.env file is inspired from the name of the local.properties file used in a similar fashion for Android Projects to define Java properties only for the local user)
You can test the changes in WordPress from this Pull Request by:
|
You can test the changes in Jetpack from this Pull Request by:
|
.buildkite/pipeline.yml
Outdated
| # Common plugin settings to use with the `plugins` key. | ||
| - &common_plugins | ||
| - automattic/bash-cache#2.8.0 | ||
| - automattic/bash-cache#mokagio/genstring-in-ci |
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.
Will need to push a new commit or rewrite this one to point to the next bash-cache version once Automattic/a8c-ci-toolkit-buildkite-plugin#36 lands.
35306ef to
2176ece
Compare
2176ece to
45ac4e8
Compare
Generated by 🚫 dangerJS |
AliSoftware
left a comment
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.
👌 ![]()
| echo "--- :writing_hand: Copy Files" | ||
| mkdir -pv ~/.configure/wordpress-ios/secrets | ||
| cp -v fastlane/env/project.env-example ~/.configure/wordpress-ios/secrets/project.env |
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 actually wondered about this in the past too.
Probably for another PR, and even a small "project" to not only change this on all repos, but also probably get rid of the requirement for ~/.*-env.default files too (which have been bothering me too, not only because those files clutters my $HOME, but also because I don't use those in practice, as I put all my tokens and the likes that we expect in those files… in my ~/.zshrc anyway (since they are mostly the same values for all repos, and I prefer having a single source of truth than one per project)
| echo "--- Lint Localized Strings Format" | ||
| LOGS=logs.txt | ||
| set +e | ||
| set -o pipefail | ||
| bundle exec fastlane generate_strings_file_for_glotpress skip_commit:true | tee $LOGS | ||
| EXIT_CODE=$? | ||
| set -e | ||
|
|
||
| echo $EXIT_CODE | ||
|
|
||
| if [[ $EXIT_CODE -ne 0 ]]; then | ||
| # Strings generation finished with errors, extract the errors in an easy-to-find section | ||
| echo "--- Report genstrings errors" | ||
| ERRORS=errors.txt | ||
| echo "Found errors when trying to run \`genstrings\` to generate the \`.strings\` files from \`*LocalizedStrings\` calls:" | tee $ERRORS | ||
| echo '' >> $ERRORS | ||
| # Print the errors inline. | ||
| # | ||
| # Notice the second `sed` call that removes the ANSI escape sequences that | ||
| # Fastlane uses to color the output. | ||
| grep -e "\[.*\].*genstrings:" $LOGS \ | ||
| | sed -e 's/\[.*\].*genstrings: error: /- /' \ | ||
| | sed -e $'s/\x1b\[[0-9;]*m//g' \ | ||
| | sort \ | ||
| | uniq \ | ||
| | tee -a $ERRORS | ||
| # Annotate the build with the errors | ||
| cat $ERRORS | buildkite-agent annotate --style error --context genstrings | ||
| fi | ||
|
|
||
| exit $EXIT_CODE | ||
| lint_localized_strings_format |
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.
🧹 🧹 🧹 ✨
The work from #19553 is now part of
bash-cache.Testing
CI is green in this step, which validates the happy path. I recycled the same test PR as #19553 by force pushing and you can see it still fails
Regression Notes
RELEASE-NOTES.txtif necessary. N.A.