Skip to content

Commit a4119ef

Browse files
Refactor Github Action per b/485167538
1 parent c4ef6e9 commit a4119ef

7 files changed

Lines changed: 364 additions & 168 deletions

File tree

.github/workflows/android.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ jobs:
7979
- name: Set env variables for subsequent steps (all)
8080
shell: bash
8181
run: |
82-
echo "MATRIX_UNIQUE_NAME=${{ matrix.os }}-${{ matrix.architecture }}" >> $GITHUB_ENV
82+
echo "MATRIX_UNIQUE_NAME=${MATRIX_OS}-${MATRIX_ARCHITECTURE}" >> $GITHUB_ENV
8383
echo "GHA_INSTALL_CCACHE=1" >> $GITHUB_ENV
84+
env:
85+
MATRIX_OS: ${{ matrix.os }}
86+
MATRIX_ARCHITECTURE: ${{ matrix.architecture }}
8487

8588
- name: Setup python
8689
uses: actions/setup-python@v4

.github/workflows/checks.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,18 @@ jobs:
117117
README_FILE=release_build_files/readme.md
118118
# Determine the github merge base - same logic as integration_tests.yml
119119
# "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)
120+
MERGE_BASE=$(git merge-base origin/${GITHUB_EVENT_PULL_REQUEST_HEAD_REF} origin/${GITHUB_EVENT_PULL_REQUEST_BASE_REF} || true)
121121
# If MERGE_BASE can't be determined, ignore this check, something odd is going on.
122122
if [[ -n "${MERGE_BASE}" ]]; then
123-
DIFF_RESULT=$(git diff --name-only "origin/${{github.event.pull_request.head.ref}}..${MERGE_BASE}" -- "${README_FILE}")
123+
DIFF_RESULT=$(git diff --name-only "origin/${GITHUB_EVENT_PULL_REQUEST_HEAD_REF}..${MERGE_BASE}" -- "${README_FILE}")
124124
if [[ "${DIFF_RESULT}" != "${README_FILE}" ]]; then
125125
echo "::error ::Please update release notes (${README_FILE}) or add '${{env.skipReleaseNotesLabel}}' label."
126126
exit 1
127127
fi
128128
fi
129+
130+
env:
131+
GITHUB_EVENT_PULL_REQUEST_HEAD_REF: ${{github.event.pull_request.head.ref}}
132+
133+
GITHUB_EVENT_PULL_REQUEST_BASE_REF: ${{github.event.pull_request.base.ref}}
129134

.github/workflows/cpp-packaging.yml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ jobs:
4646
steps:
4747
- name: log run inputs
4848
run: |
49-
if [[ -n "${{ github.event.inputs.downloadPublicVersion }}" ]]; then
50-
echo "::warning ::Downloading public SDK package from https://dl.google.com/firebase/sdk/cpp/firebase_cpp_sdk_${{ github.event.inputs.downloadPublicVersion }}.zip"
51-
elif [[ -n "${{ github.event.inputs.downloadPreviousRun }}" ]]; then
52-
echo "::warning ::Downloading SDK package from previous run at https://github.com/firebase/firebase-cpp-sdk/actions/runs/${{ github.event.inputs.downloadPreviousRun }}"
49+
if [[ -n "${GITHUB_EVENT_INPUTS_DOWNLOADPUBLICVERSION}" ]]; then
50+
echo "::warning ::Downloading public SDK package from https://dl.google.com/firebase/sdk/cpp/firebase_cpp_sdk_${GITHUB_EVENT_INPUTS_DOWNLOADPUBLICVERSION}.zip"
51+
elif [[ -n "${GITHUB_EVENT_INPUTS_DOWNLOADPREVIOUSRUN}" ]]; then
52+
echo "::warning ::Downloading SDK package from previous run at https://github.com/firebase/firebase-cpp-sdk/actions/runs/${GITHUB_EVENT_INPUTS_DOWNLOADPREVIOUSRUN}"
5353
fi
54+
env:
55+
GITHUB_EVENT_INPUTS_DOWNLOADPUBLICVERSION: ${{ github.event.inputs.downloadPublicVersion }}
56+
GITHUB_EVENT_INPUTS_DOWNLOADPREVIOUSRUN: ${{ github.event.inputs.downloadPreviousRun }}
5457

5558
- name: log if skipping integration tests
5659
if: |
@@ -413,10 +416,12 @@ jobs:
413416
shell: bash
414417
run: |
415418
verbose_flag=
416-
if [[ -n "${{ github.event.inputs.verboseBuild }}" && "${{ github.event.inputs.verboseBuild }}" -ne 0 ]]; then
419+
if [[ -n "${GITHUB_EVENT_INPUTS_VERBOSEBUILD}" && "${GITHUB_EVENT_INPUTS_VERBOSEBUILD}" -ne 0 ]]; then
417420
verbose_flag=--verbose
418421
fi
419422
echo "VERBOSE_FLAG=${verbose_flag}" >> $GITHUB_ENV
423+
env:
424+
GITHUB_EVENT_INPUTS_VERBOSEBUILD: ${{ github.event.inputs.verboseBuild }}
420425

421426
# Run the build in the host OS default shell since Windows can't handle long path names in bash.
422427
- name: Build desktop SDK
@@ -430,7 +435,7 @@ jobs:
430435
find .. -type f -print > src_file_list.txt
431436
# Remove intermediate build files (.o and .obj) files to save space.
432437
find . -type f -name '*.o' -or -name '*.obj' -print0 | xargs -0 rm -f --
433-
tar -czhf ../firebase-cpp-sdk-${{ env.SDK_NAME }}-build.tgz .
438+
tar -czhf ../firebase-cpp-sdk-${SDK_NAME}-build.tgz .
434439
435440
- name: Print built libraries
436441
shell: bash
@@ -664,19 +669,21 @@ jobs:
664669
- name: fetch public SDK package from web
665670
if: ${{ github.event.inputs.downloadPublicVersion != '' && github.event.inputs.downloadPreviousRun == '' }}
666671
run: |
667-
if [[ ! "${{ github.event.inputs.downloadPublicVersion }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
668-
echo Invalid version number: "${{ github.event.inputs.downloadPublicVersion }}"
672+
if [[ ! "${GITHUB_EVENT_INPUTS_DOWNLOADPUBLICVERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
673+
echo Invalid version number: "${GITHUB_EVENT_INPUTS_DOWNLOADPUBLICVERSION}"
669674
exit 1
670675
fi
671676
set +e
672677
# Retry up to 10 times because Curl has a tendency to timeout on
673678
# Github runners.
674679
for retry in {1..10} error; do
675680
if [[ $retry == "error" ]]; then exit 5; fi
676-
curl -L https://dl.google.com/firebase/sdk/cpp/firebase_cpp_sdk_${{ github.event.inputs.downloadPublicVersion }}.zip --output firebase_cpp_sdk.zip && break
681+
curl -L https://dl.google.com/firebase/sdk/cpp/firebase_cpp_sdk_${GITHUB_EVENT_INPUTS_DOWNLOADPUBLICVERSION}.zip --output firebase_cpp_sdk.zip && break
677682
sleep 300
678683
done
679684
set -e
685+
env:
686+
GITHUB_EVENT_INPUTS_DOWNLOADPUBLICVERSION: ${{ github.event.inputs.downloadPublicVersion }}
680687

681688
- name: compute SDK hash
682689
shell: bash
@@ -817,21 +824,21 @@ jobs:
817824
USE_EXPANDED_MATRIX=0
818825
fi
819826
verbose_flag=
820-
if [[ -n "${{ github.event.inputs.verboseBuild }}" && "${{ github.event.inputs.verboseBuild }}" -ne 0 ]]; then
827+
if [[ -n "${GITHUB_EVENT_INPUTS_VERBOSEBUILD}" && "${GITHUB_EVENT_INPUTS_VERBOSEBUILD}" -ne 0 ]]; then
821828
verbose_flag=-v
822829
fi
823830
set -e
824831
if [[ "${{ github.event_name }}" == "schedule" ]]; then
825832
# trigger integration tests and generate two reports for nightly workflow run: one for firestore, one for the rest.
826-
python scripts/gha/trigger_workflow.py -t ${{ steps.generate-token.outputs.token }} \
833+
python scripts/gha/trigger_workflow.py -t ${STEPS_GENERATE_TOKEN_OUTPUTS_TOKEN} \
827834
-w integration_tests.yml \
828835
-p test_packaged_sdk ${{ github.run_id }} \
829836
-p use_expanded_matrix ${USE_EXPANDED_MATRIX} \
830837
-p apis "admob,analytics,auth,database,dynamic_links,functions,installations,messaging,remote_config,storage" \
831838
-p test_pull_request nightly-packaging \
832839
-s 10 \
833840
-A ${verbose_flag}
834-
python scripts/gha/trigger_workflow.py -t ${{ steps.generate-token.outputs.token }} \
841+
python scripts/gha/trigger_workflow.py -t ${STEPS_GENERATE_TOKEN_OUTPUTS_TOKEN} \
835842
-w integration_tests.yml \
836843
-p test_packaged_sdk ${{ github.run_id }} \
837844
-p use_expanded_matrix ${USE_EXPANDED_MATRIX} \
@@ -841,10 +848,13 @@ jobs:
841848
-A ${verbose_flag}
842849
else
843850
# trigger integration tests
844-
python scripts/gha/trigger_workflow.py -t ${{ steps.generate-token.outputs.token }} \
851+
python scripts/gha/trigger_workflow.py -t ${STEPS_GENERATE_TOKEN_OUTPUTS_TOKEN} \
845852
-w integration_tests.yml \
846853
-p test_packaged_sdk ${{ github.run_id }} \
847854
-p use_expanded_matrix ${USE_EXPANDED_MATRIX} \
848855
-s 10 \
849856
-A ${verbose_flag}
850857
fi
858+
env:
859+
GITHUB_EVENT_INPUTS_VERBOSEBUILD: ${{ github.event.inputs.verboseBuild }}
860+
STEPS_GENERATE_TOKEN_OUTPUTS_TOKEN: ${{ steps.generate-token.outputs.token }}

.github/workflows/desktop.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,33 @@ jobs:
128128
if: startsWith(matrix.os, 'windows')
129129
shell: bash
130130
run: |
131-
if [[ ${{matrix.msvc_runtime}} == "static" ]];
131+
if [[ ${MATRIX_MSVC_RUNTIME} == "static" ]];
132132
then echo "VCPKG_SUFFIX=windows-static" >> $GITHUB_ENV;
133-
elif [[ ${{matrix.msvc_runtime}} == "dynamic" ]];
133+
elif [[ ${MATRIX_MSVC_RUNTIME} == "dynamic" ]];
134134
then echo "VCPKG_SUFFIX=windows-static-md" >> $GITHUB_ENV;
135135
else
136136
echo "Warning, could not resolve vcpkg suffix.";
137137
fi
138+
env:
139+
MATRIX_MSVC_RUNTIME: ${{matrix.msvc_runtime}}
138140

139141
- name: Set env variables for subsequent steps (all)
140142
shell: bash
141143
run: |
142-
echo "BUILD_TYPE: ${{ matrix.build_type }}"
143-
echo "VCPKG_SUFFIX: ${{env.VCPKG_SUFFIX}}"
144-
echo "VCPKG_RESPONSE_FILE=external/vcpkg_custom_data/response_files/${{ matrix.architecture }}-${{ env.VCPKG_SUFFIX }}.txt" >> $GITHUB_ENV
145-
echo "MATRIX_UNIQUE_NAME=${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.architecture }}-${{ matrix.msvc_runtime }}" >> $GITHUB_ENV
144+
echo "BUILD_TYPE: ${MATRIX_BUILD_TYPE}"
145+
echo "VCPKG_SUFFIX: ${VCPKG_SUFFIX}"
146+
echo "VCPKG_RESPONSE_FILE=external/vcpkg_custom_data/response_files/${MATRIX_ARCHITECTURE}-${VCPKG_SUFFIX}.txt" >> $GITHUB_ENV
147+
echo "MATRIX_UNIQUE_NAME=${MATRIX_OS}-${MATRIX_BUILD_TYPE}-${MATRIX_ARCHITECTURE}-${MATRIX_MSVC_RUNTIME}" >> $GITHUB_ENV
146148
if [[ '${{ matrix.sdk_platform }}' == 'darwin' ]]; then
147149
# If Mac, also hash vcpkg cache on Xcode version.
148-
echo "VCPKG_EXTRA_HASH=-xcode${{matrix.xcode_version}}" >> $GITHUB_ENV
150+
echo "VCPKG_EXTRA_HASH=-xcode${MATRIX_XCODE_VERSION}" >> $GITHUB_ENV
149151
fi
152+
env:
153+
MATRIX_BUILD_TYPE: ${{ matrix.build_type }}
154+
MATRIX_ARCHITECTURE: ${{ matrix.architecture }}
155+
MATRIX_OS: ${{ matrix.os }}
156+
MATRIX_MSVC_RUNTIME: ${{ matrix.msvc_runtime }}
157+
MATRIX_XCODE_VERSION: ${{matrix.xcode_version}}
150158

151159
- name: Cache vcpkg C++ dependencies
152160
id: cache_vcpkg
@@ -180,7 +188,11 @@ jobs:
180188
- name: Build SDK
181189
shell: bash
182190
run: |
183-
python scripts/gha/build_desktop.py --build_tests --arch "${{ matrix.architecture }}" --config "${{ matrix.build_type }}" --msvc_runtime_library "${{ matrix.msvc_runtime }}" --gha_build
191+
python scripts/gha/build_desktop.py --build_tests --arch "${MATRIX_ARCHITECTURE}" --config "${MATRIX_BUILD_TYPE}" --msvc_runtime_library "${MATRIX_MSVC_RUNTIME}" --gha_build
192+
env:
193+
MATRIX_ARCHITECTURE: ${{ matrix.architecture }}
194+
MATRIX_BUILD_TYPE: ${{ matrix.build_type }}
195+
MATRIX_MSVC_RUNTIME: ${{ matrix.msvc_runtime }}
184196

185197
- name: Stats for ccache (mac and linux)
186198
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
@@ -340,9 +352,11 @@ jobs:
340352
shell: bash
341353
run: |
342354
cat build-results-desktop-ubuntu-20.04-openssl.log
343-
if [[ "${{ job.status }}" != "success" ]]; then
355+
if [[ "${JOB_STATUS}" != "success" ]]; then
344356
exit 1
345357
fi
358+
env:
359+
JOB_STATUS: ${{ job.status }}
346360
- name: Set up Node (16)
347361
uses: actions/setup-node@v3
348362
with:
@@ -370,6 +384,8 @@ jobs:
370384
shell: bash
371385
run: |
372386
cat testapps-desktop-ubuntu-20.04-openssl/test-results-desktop-ubuntu-20.04-openssl.log
373-
if [[ "${{ job.status }}" != "success" ]]; then
387+
if [[ "${JOB_STATUS}" != "success" ]]; then
374388
exit 1
375389
fi
390+
env:
391+
JOB_STATUS: ${{ job.status }}

0 commit comments

Comments
 (0)