8000 Reference untrusted git branch names via environment variables. (#1516) · compnerd/firebase-cpp-sdk@111c1a2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 111c1a2

Browse files
authored
Reference untrusted git branch names via environment variables. (firebase#1516)
* Apply fix using environment variables.
1 parent ba0b681 commit 111c1a2

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

.github/workflows/checks.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,19 @@ jobs:
111111
- name: Check whether release notes have been updated
112112
# Skip this if the PR has the skipReleaseNotes label or if it's a merge to other than main.
113113
if: ${{!contains(github.event.pull_request.labels.*.name, env.skipReleaseNotesLabel) && (github.event.pull_request.base.ref == 'main')}}
114+
env:
115+
HEAD_REF: ${{github.event.pull_request.head.ref}}
116+
BASE_REF: ${{github.event.pull_request.base.ref}}
114117
run: |
115118
set -e
116119
# Filename to check.
117120
README_FILE=release_build_files/readme.md
118121
# Determine the github merge base - same logic as integration_tests.yml
119122
# "git merge-base main branch_name" will give the common ancestor of both branches.
120-
MERGE_BASE=$(git merge-base origin/${{github.event.pull_request.head.ref}} origin/${{github.event.pull_request.base.ref}} || true)
123+
MERGE_BASE=$(git merge-base "origin/${HEAD_REF}" "origin/${BASE_REF}" || true)
121124
# If MERGE_BASE can't be determined, ignore this check, something odd is going on.
122125
if [[ -n "${MERGE_BASE}" ]]; then
123-
DIFF_RESULT=$(git diff --name-only "origin/${{github.event.pull_request.head.ref}}..${MERGE_BASE}" -- "${README_FILE}")
126+
DIFF_RESULT=$(git diff --name-only "origin/${HEAD_REF}..${MERGE_BASE}" -- "${README_FILE}")
124127
if [[ "${DIFF_RESULT}" != "${README_FILE}" ]]; then
125128
echo "::error ::Please update release notes (${README_FILE}) or add '${{env.skipReleaseNotesLabel}}' label."
126129
exit 1

.github/workflows/integration_tests.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ jobs:
164164
shell: bash
165165
command: pip install -r scripts/gha/python_requirements.txt
166166
- id: matrix_config
167+
env:
168+
HEAD_REF: ${{github.event.pull_request.head.ref}}
169+
BASE_REF: ${{github.event.pull_request.base.ref}}
167170
run: |
168171
if [[ "${{ steps.set_outputs.outputs.requested_tests }}" == "expanded" ]]; then
169172
TEST_MATRIX_PARAM=-e=1
@@ -174,12 +177,12 @@ jobs:
174177
elif [[ "${{ steps.set_outputs.outputs.requested_tests }}" == "auto" ]]; then
175178
# auto-diff only apply when running in a PR.
176179
# diff against the PR's base. "git merge-base main branch_name" will give the common ancestor of both branches.
177-
MERGE_BASE=$(git merge-base origin/${{github.event.pull_request.head.ref}} origin/${{github.event.pull_request.base.ref}} || true)
180+
MERGE_BASE=$(git merge-base "origin/${HEAD_REF}" "origin/${BASE_REF}" || true)
178181
# If origin/<branch> is no longer valid, then just run all tests.
179182
if [[ -n "${MERGE_BASE}" ]]; then
180-
echo "::warning ::Auto-diff origin/${{github.event.pull_request.head.ref}}..${MERGE_BASE}"
181-
git diff --name-only origin/${{github.event.pull_request.head.ref}}..${MERGE_BASE}
182-
TEST_MATRIX_PARAM="--auto_diff origin/${{github.event.pull_request.head.ref}}..${MERGE_BASE}"
183+
echo '::warning ::Auto-diff origin/${HEAD_REF}..${MERGE_BASE}"
184+
git diff --name-only "origin/${HEAD_REF}..${MERGE_BASE}"
185+
TEST_MATRIX_PARAM="--auto_diff origin/${HEAD_REF}..${MERGE_BASE}"
183186
fi
184187
fi
185188
@@ -188,12 +191,13 @@ jobs:
188191
if [[ "${{ github.event.schedule }}" == "0 9 * * *" ]]; then
189192
# at 1am PST/2am PDT. Running integration tests and generate test report for all testapps except firestore
190193
apis="analytics,app_check,auth,database,dynamic_links,functions,gma,installations,messaging,remote_config,storage"
194+
echo "::warning ::Running main nightly tests"
191195
elif [[ "${{ github.event.schedule }}" == "0 10 * * *" || "${{ github.event.schedule }}" == "0 11 * * *" ]]; then
192196
# at 2am PST/3am PDT and 3am PST/4am PDT. Running integration tests for firestore and generate test report 6250 .
193197
echo "::warning ::Running Firestore nightly tests"
194198
apis="firestore"
195199
else
196-
echo "::warning ::Running main nightly tests"
200+
echo "::warning ::Running pull request tests"
197201
apis=$( python scripts/gha/print_matrix_configuration.py -c -w integration_tests -k apis -o "${{github.event.inputs.apis}}" ${TEST_MATRIX_PARAM} )
198202
fi
199203
if [[ "${{ github.event.schedule }}" == "0 11 * * *" ]]; then

0 commit comments

Comments
 (0)
0