chore(ci): enable workflows and scripts on preview (#15581)#15584
chore(ci): enable workflows and scripts on preview (#15581)#15584noahdietz merged 1 commit intogoogleapis:previewfrom
Conversation
Summary of ChangesHello @noahdietz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the continuous integration (CI) pipeline by introducing greater flexibility in how conditional tests are executed. By parameterizing the target branch for Git operations, the CI workflows can now be effectively run against branches other than Highlights
Changelog
Ignored Files
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates the run_conditional_tests.sh script to be more flexible by allowing a configurable target branch instead of a hardcoded main branch. The changes also improve the script's robustness by using [[...]] for tests. The code is well-written. I've added one suggestion to refactor a conditional block to reduce code duplication and improve maintainability.
| if [[ ${BUILD_TYPE} == "presubmit" ]]; then | ||
| # For presubmit build, we want to know the difference from the | ||
| # common commit in origin/main. | ||
| GIT_DIFF_ARG="origin/main..." | ||
| # common commit in the target branch. | ||
| GIT_DIFF_ARG="origin/$TARGET_BRANCH..." | ||
|
|
||
| # Then fetch enough history for finding the common commit. | ||
| git fetch origin main --deepen=200 | ||
| git fetch origin "$TARGET_BRANCH" --deepen=200 | ||
|
|
||
| elif [ ${BUILD_TYPE} == "continuous" ]; then | ||
| elif [[ ${BUILD_TYPE} == "continuous" ]]; then | ||
| # For continuous build, we want to know the difference in the last | ||
| # commit. This assumes we use squash commit when merging PRs. | ||
| GIT_DIFF_ARG="HEAD~.." | ||
|
|
||
| # Then fetch one last commit for getting the diff. | ||
| git fetch origin main --deepen=1 | ||
| git fetch origin "$TARGET_BRANCH" --deepen=1 |
There was a problem hiding this comment.
To improve maintainability and reduce code duplication, this conditional logic can be refactored. By setting a FETCH_DEPTH variable within the if/elif blocks, you can use a single git fetch command afterwards. This makes the script's intent clearer and easier to modify in the future.
| if [[ ${BUILD_TYPE} == "presubmit" ]]; then | |
| # For presubmit build, we want to know the difference from the | |
| # common commit in origin/main. | |
| GIT_DIFF_ARG="origin/main..." | |
| # common commit in the target branch. | |
| GIT_DIFF_ARG="origin/$TARGET_BRANCH..." | |
| # Then fetch enough history for finding the common commit. | |
| git fetch origin main --deepen=200 | |
| git fetch origin "$TARGET_BRANCH" --deepen=200 | |
| elif [ ${BUILD_TYPE} == "continuous" ]; then | |
| elif [[ ${BUILD_TYPE} == "continuous" ]]; then | |
| # For continuous build, we want to know the difference in the last | |
| # commit. This assumes we use squash commit when merging PRs. | |
| GIT_DIFF_ARG="HEAD~.." | |
| # Then fetch one last commit for getting the diff. | |
| git fetch origin main --deepen=1 | |
| git fetch origin "$TARGET_BRANCH" --deepen=1 | |
| FETCH_DEPTH="" | |
| if [[ ${BUILD_TYPE} == "presubmit" ]]; then | |
| # For presubmit build, we want to know the difference from the | |
| # common commit in the target branch. | |
| GIT_DIFF_ARG="origin/$TARGET_BRANCH..." | |
| FETCH_DEPTH=200 | |
| elif [[ ${BUILD_TYPE} == "continuous" ]]; then | |
| # For continuous build, we want to know the difference in the last | |
| # commit. This assumes we use squash commit when merging PRs. | |
| GIT_DIFF_ARG="HEAD~.." | |
| FETCH_DEPTH=1 | |
| fi | |
| if [[ -n "${FETCH_DEPTH}" ]]; then | |
| # Fetch enough history for getting the diff. | |
| git fetch origin "$TARGET_BRANCH" --deepen="${FETCH_DEPTH}" | |
| fi |
Cherry pick commit from
mainfor #15581.