Skip to content

Commit 2b9c78e

Browse files
authored
Make start build can trigger package and integration test (#327)
1 parent 9ce04b5 commit 2b9c78e

File tree

2 files changed

+140
-41
lines changed

2 files changed

+140
-41
lines changed

.github/workflows/build_starter.yml

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ on:
1515
unity_branch:
1616
description: 'Unity branch to build against, empty means current branch'
1717
default: ''
18+
required: false
1819
platforms:
1920
description: 'CSV of Android,iOS,Windows,macOS,Linux'
2021
default: 'Android,iOS,Windows,macOS,Linux'
@@ -28,6 +29,21 @@ on:
2829
description: 'Additional flags to pass into CMake'
2930
default: ''
3031
required: false
32+
release_label:
33+
description: 'If the package is intended to run for a release, put <version>-RC## for label'
34+
default: 'NoneRelease'
35+
type: string
36+
required: true
37+
should_trigger_package:
38+
description: 'If we want to trigger package process'
39+
default: true
40+
type: boolean
41+
required: true
42+
skipIntegrationTests:
43+
description: 'If we want to skip integration test'
44+
default: '0'
45+
required: true
46+
3147
env:
3248
pythonVersion: '3.7'
3349

@@ -52,8 +68,6 @@ jobs:
5268
run: |
5369
platform=$( python scripts/gha/print_matrix_configuration.py -c -w build_unity_sdks -k platform -o "${{github.event.inputs.platforms}}" )
5470
echo "::set-output name=platform::${platform}"
55-
56-
5771
5872
build_android:
5973
name: build-android-unity${{ github.event.inputs.unity_version }}-CPP${{ github.event.inputs.firebase_cpp_sdk_version }}
@@ -119,3 +133,48 @@ jobs:
119133
apis: ${{ github.event.inputs.apis }}
120134
unity_platform_name: Windows
121135
additional_cmake_flags: ${{ github.event.inputs.additional_cmake_flags }}
136+
137+
trigger_package:
138+
name: package ${{ github.event.inputs.release_label }}
139+
needs: [build_android, build_ios, build_linux, build_macos, build_windows]
140+
if: (github.event.inputs.should_trigger_package == 'true') && !cancelled() && !failure()
141+
runs-on: ubuntu-latest
142+
steps:
143+
- name: Checkout repo
144+
uses: actions/[email protected]
145+
146+
- name: Setup python
147+
uses: actions/setup-python@v2
148+
with:
149+
python-version: 3.7
150+
151+
- name: Install python deps
152+
shell: bash
153+
run: |
154+
pip install -r scripts/gha/requirements.txt
155+
- name: Generate token for GitHub API
156+
# This step is necessary because the existing GITHUB_TOKEN cannot be used inside one workflow to trigger another.
157+
#
158+
# Instead, generate a new token here, using our GitHub App's private key and App ID (saved as Secrets).
159+
#
160+
# This method is preferred over the "personal access token" solution, as the GitHub App's scope is limited to just
161+
# the firebase-cpp-sdk repository.
162+
uses: tibdex/github-app-token@v1
163+
id: generate-token
164+
with:
165+
app_id: ${{ secrets.WORKFLOW_TRIGGER_APP_ID }}
166+
private_key: ${{ secrets.WORKFLOW_TRIGGER_APP_PRIVATE_KEY }}
167+
- name: Use GitHub API to start workflow
168+
shell: bash
169+
run: |
170+
set -e
171+
python scripts/gha/trigger_workflow.py -t ${{ steps.generate-token.outputs.token }} -w package.yml \
172+
-p use_new_build '1' \
173+
-p release_label ${{ github.event.inputs.release_label }} \
174+
-p skipIntegrationTests ${{ github.event.inputs.skipIntegrationTests }} \
175+
-p download_android_run ${{ github.run_id }} \
176+
-p download_ios_run ${{ github.run_id }} \
177+
-p download_linux_run ${{ github.run_id }} \
178+
-p download_macos_run ${{ github.run_id }} \
179+
-p download_windows_run ${{ github.run_id }} \
180+
-s 10 -A -v

.github/workflows/package.yml

Lines changed: 79 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,73 +4,71 @@ name: Package SDKs
44
on:
55
workflow_dispatch:
66
inputs:
7-
operating_systems:
8-
description: 'CSV of VMs to run on'
9-
default: 'ubuntu-latest'
7+
use_new_build:
8+
description: 'Check if this package grabs artifacts from new build workflow'
9+
default: '0'
1010
required: true
1111
skipIntegrationTests:
1212
description: 'skip integration tests?'
13-
default: 0
13+
default: '0'
1414
required: false
1515
create_new_branch:
16-
description: 'If we need to create new branch to package guids update. 0 means no creation and 1 means create. If working_branch set, will ignore this value. '
17-
default: 0
16+
description: 'Check if we need to create new branch to package guids update. If working_branch set, will ignore this value. '
17+
default: '0'
1818
required: false
1919
working_branch:
2020
description: 'If already a working in progress release branch'
2121
required: false
22+
release_label:
23+
description: 'If the package is intended to run for a release, put <version>-RC## for label'
24+
required: false
2225
download_ios_run:
23-
description: 'run id for ios.yml'
26+
description: 'run id for ios.yml or build_starter.yml, search for ios_unity output'
2427
required: false
2528
download_android_run:
26-
description: 'run id for android.yml'
29+
description: 'run id for android.yml or build_starter.yml, search for android_unity output'
2730
required: false
28-
download_desktop_run:
29-
description: 'run id for sdk_build.yml'
31+
download_linux_run:
32+
description: 'run id for sdk_build.yml or build_starter.yml, search for linux_unity output'
3033
required: false
31-
release_label:
32-
description: 'If the package is intended to run for a release, put <version>-RC## for label'
34+
download_macos_run:
35+
description: 'run id for sdk_build.yml or build_starter.yml, search for macos_unity output'
36+
required: false
37+
download_windows_run:
38+
description: 'run id for sdk_build.yml or build_starter.yml, search for windows_unity output'
3339
required: false
3440

41+
3542
env:
3643
# Use SHA256 for hashing files.
3744
hashCommand: "sha256sum"
3845

3946
jobs:
4047
package_sdks:
41-
name: package-${{matrix.os}}-${{github.event.inputs.release_label}}
42-
runs-on: ${{matrix.os}}
48+
name: package-${{github.event.inputs.release_label}}
49+
runs-on: ubuntu-latest
4350
strategy:
4451
fail-fast: false
45-
matrix:
46-
os: [ubuntu-latest]
47-
include:
48-
- os: ubuntu-latest
49-
package_dir: output
5052
steps:
5153
- name: Print out inputs
5254
shell: bash
5355
run: |
54-
echo operation_system: ${{ github.event.inputs.operating_systems }}
56+
echo use_new_build: ${{ github.event.inputs.use_new_build }}
5557
echo skipIntegrationTests: ${{ github.event.inputs.skipIntegrationTests }}
5658
echo create_new_branch: ${{ github.event.inputs.create_new_branch }}
59+
echo release_label: ${{ github.event.inputs.release_label }}
5760
echo working_branch: ${{ github.event.inputs.working_branch }}
5861
echo download_ios_run: ${{ github.event.inputs.download_ios_run }}
5962
echo download_android_run: ${{ github.event.inputs.download_android_run }}
60-
echo download_desktop_run: ${{ github.event.inputs.download_desktop_run }}
63+
echo download_linux_run: ${{ github.event.inputs.download_linux_run }}
64+
echo download_macos_run: ${{ github.event.inputs.download_macos_run }}
65+
echo download_windows_run: ${{ github.event.inputs.download_windows_run }}
6166
6267
- name: Check out base branch
6368
uses: actions/[email protected]
6469
with:
6570
fetch-depth: 0
6671
ref: ${{ github.event.inputs.working_branch }}
67-
68-
- name: Get token for firebase-workflow-trigger
69-
uses: tibdex/github-app-token@v1
70-
id: generate-token
71-
with:
72-
app_id: ${{ secrets.WORKFLOW_TRIGGER_APP_ID }}
73-
private_key: ${{ secrets.WORKFLOW_TRIGGER_APP_PRIVATE_KEY }}
7472

7573
- name: Setup Python
7674
uses: actions/setup-python@v2
@@ -103,26 +101,68 @@ jobs:
103101
echo "UPDATE_LOGFILE=update_log.txt" >> $GITHUB_ENV
104102
echo "NEW_BRANCH=${{ github.event.inputs.working_branch }}" >> $GITHUB_ENV
105103
106-
# Fetch all the zip files from previous run
107-
- name: Fetch Desktop Artifacts
104+
- name: Set Fetch Workflow name
105+
id: set-fetch-workflow
106+
shell: bash
107+
run: |
108+
if [[ "${{ github.event.inputs.use_new_build }}" == "1" ]]; then
109+
# all use build_starter.yml
110+
echo "::set-output name=android_yml::'build_starter.yml'"
111+
echo "::set-output name=ios_yml::'build_starter.yml'"
112+
echo "::set-output name=linux_yml::'build_starter.yml'"
113+
echo "::set-output name=macos_yml::'build_starter.yml'"
114+
echo "::set-output name=windows_yml::'build_starter.yml'"
115+
else
116+
echo "::set-output name=android_yml::'android.yml'"
117+
echo "::set-output name=ios_yml::'ios.yml'"
118+
echo "::set-output name=linux_yml::'sdk_build.yml'"
119+
echo "::set-output name=macos_yml::'sdk_build.yml'"
120+
echo "::set-output name=windows_yml::'sdk_build.yml'"
121+
fi
122+
123+
- name: Fetch Android Artifacts
108124
uses: dawidd6/action-download-artifact@v2
125+
continue-on-error: true
109126
with:
110-
workflow: 'sdk_build.yml'
111-
run_id: ${{ github.event.inputs.download_desktop_run }}
127+
workflow: ${{ steps.set-fetch-workflow.outputs.android_yml }}
128+
run_id: ${{ github.event.inputs.download_android_run }}
129+
name: android_unity
112130
path: built_artifect
113-
131+
114132
- name: Fetch iOS Artifacts
115133
uses: dawidd6/action-download-artifact@v2
134+
continue-on-error: true
116135
with:
117-
workflow: 'ios.yml'
136+
workflow: ${{ steps.set-fetch-workflow.outputs.ios_yml }}
118137
run_id: ${{ github.event.inputs.download_ios_run }}
138+
name: ios_unity
119139
path: built_artifect
120-
121-
- name: Fetch Android Artifacts
140+
141+
- name: Fetch Linux Artifacts
122142
uses: dawidd6/action-download-artifact@v2
143+
continue-on-error: true
123144
with:
124-
workflow: 'android.yml'
125-
run_id: ${{ github.event.inputs.download_android_run }}
145+
workflow: ${{ steps.set-fetch-workflow.outputs.linux_yml }}
146+
run_id: ${{ github.event.inputs.download_linux_run }}
147+
name: linux_unity
148+
path: built_artifect
149+
150+
- name: Fetch MacOS Artifacts
151+
uses: dawidd6/action-download-artifact@v2
152+
continue-on-error: true
153+
with:
154+
workflow: ${{ steps.set-fetch-workflow.outputs.macos_yml }}
155+
run_id: ${{ github.event.inputs.download_macos_run }}
156+
name: macos_unity
157+
path: built_artifect
158+
159+
- name: Fetch Windows Artifacts
160+
uses: dawidd6/action-download-artifact@v2
161+
continue-on-error: true
162+
with:
163+
workflow: ${{ steps.set-fetch-workflow.outputs.windows_yml }}
164+
run_id: ${{ github.event.inputs.download_windows_run }}
165+
name: windows_unity
126166
path: built_artifect
127167

128168
- name: move zip files
@@ -247,7 +287,7 @@ jobs:
247287
trigger_integration_tests:
248288
# Trigger the integration_tests workflow.
249289
needs: [package_sdks]
250-
if: (github.event.inputs.skipIntegrationTests == 0 || github.event.inputs.skipIntegrationTests == '') && !cancelled() && !failure()
290+
if: (github.event.inputs.skipIntegrationTests == '0') && !cancelled() && !failure()
251291
runs-on: ubuntu-latest
252292
steps:
253293
- name: Checkout repo

0 commit comments

Comments
 (0)