Skip to content

Commit e1a21a8

Browse files
authored
Update Integration Test CI Scheduled/Label/Post-submit Triggers (#392)
1 parent 7a13328 commit e1a21a8

File tree

5 files changed

+115
-133
lines changed

5 files changed

+115
-133
lines changed

.github/workflows/build_starter.yml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ on:
2323
default: ''
2424
required: false
2525
platforms:
26-
description: 'CSV of Android,iOS,Windows,macOS,Linux'
27-
default: 'Android,iOS,Windows,macOS,Linux'
26+
description: 'Test Platforms of Android,iOS,Windows,macOS,Linux,Playmode'
27+
default: 'Android,iOS,Windows,macOS,Linux,Playmode'
2828
required: true
2929
apis:
3030
description: 'CSV of apis to build and test'
@@ -50,9 +50,9 @@ on:
5050
default: true
5151
type: boolean
5252
required: true
53-
skipIntegrationTests:
54-
description: 'If we want to skip integration test'
55-
default: '0'
53+
runIntegrationTests:
54+
description: 'run integration tests? (0 will not run integrations)'
55+
default: '1'
5656
required: true
5757

5858
env:
@@ -68,7 +68,7 @@ jobs:
6868
apis: ${{ steps.set_outputs.outputs.apis }}
6969
release_version: ${{ steps.set_outputs.outputs.release_version }}
7070
should_trigger_package: ${{ steps.set_outputs.outputs.should_trigger_package }}
71-
skipIntegrationTests: ${{ steps.set_outputs.outputs.skipIntegrationTests }}
71+
runIntegrationTests: ${{ steps.set_outputs.outputs.runIntegrationTests }}
7272
firebase_cpp_sdk_version: ${{ steps.set_outputs.outputs.firebase_cpp_sdk_version }}
7373
unity_branch: ${{ steps.set_outputs.outputs.unity_branch }}
7474
additional_cmake_flags: ${{ steps.set_outputs.outputs.additional_cmake_flags }}
@@ -94,7 +94,7 @@ jobs:
9494
echo "::set-output name=apis::${{ github.event.inputs.apis }}"
9595
echo "::set-output name=unity_version::${{ github.event.inputs.unity_version }}"
9696
echo "::set-output name=should_trigger_package::${{ github.event.inputs.should_trigger_package }}"
97-
echo "::set-output name=skipIntegrationTests::${{ github.event.inputs.skipIntegrationTests }}"
97+
echo "::set-output name=runIntegrationTests::${{ github.event.inputs.runIntegrationTests }}"
9898
echo "::set-output name=unity_branch::${{ github.event.inputs.unity_branch }}"
9999
echo "::set-output name=additional_cmake_flags::${{ github.event.inputs.unity_branch }}"
100100
else
@@ -104,11 +104,33 @@ jobs:
104104
echo "::set-output name=apis::'analytics,auth,crashlytics,database,dynamic_links,firestore,functions,installations,messaging,remote_config,storage'"
105105
echo "::set-output name=unity_version::2019"
106106
echo "::set-output name=should_trigger_package::true"
107-
echo "::set-output name=skipIntegrationTests::0"
108107
echo "::set-output name=firebase_cpp_sdk_version::"
109108
echo "::set-output name=unity_branch::"
110109
echo "::set-output name=additional_cmake_flags::"
110+
if [[ "${{ github.event_name }}" == "schedule" ]]; then
111+
echo "::set-output name=runIntegrationTests::nightly-packaging"
112+
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
113+
if [[ "${{ github.event.action }}" == "labeled" && "${{ github.event.label.name }}" == "tests-requested: quick" ]]; then
114+
echo "::set-output name=runIntegrationTests::${{ github.event.pull_request.number }}:label-quick-packaging"
115+
elif [[ "${{ github.event.action }}" == "labeled" && "${{ github.event.label.name }}" == "tests-requested: full" ]]; then
116+
echo "::set-output name=runIntegrationTests::${{ github.event.pull_request.number }}:label-full-packaging"
117+
elif [[ "${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged == true}}" == "true" ]]; then
118+
echo "::set-output name=runIntegrationTests::${{ github.event.pull_request.number }}:pr-close-packaging"
119+
else
120+
echo "::set-output name=invalid_trigger::1"
121+
fi
122+
else
123+
echo "::set-output name=invalid_trigger::1"
124+
fi
111125
fi
126+
- name: Cancel workflow
127+
if: ${{ steps.set_outputs.outputs.invalid_trigger }}
128+
uses: andymckay/[email protected]
129+
- name: Wait for workflow cancellation
130+
if: ${{ steps.set_outputs.outputs.invalid_trigger }}
131+
run: |
132+
sleep 300
133+
exit 1 # fail out if the cancellation above somehow failed.
112134
113135
- name: Print output
114136
run: |
@@ -118,7 +140,7 @@ jobs:
118140
echo outputs.apis : ${{ steps.set_outputs.outputs.apis }}
119141
echo outputs.unity_version : ${{ steps.set_outputs.outputs.unity_version }}
120142
echo outputs.should_trigger_package : ${{ steps.set_outputs.outputs.should_trigger_package }}
121-
echo outputs.skipIntegrationTests : ${{ steps.set_outputs.outputs.skipIntegrationTests }}
143+
echo outputs.runIntegrationTests : ${{ steps.set_outputs.outputs.runIntegrationTests }}
122144
echo outputs.firebase_cpp_sdk_version : ${{ steps.set_outputs.outputs.firebase_cpp_sdk_version }}
123145
echo outputs.unity_branch : ${{ steps.set_outputs.outputs.unity_branch }}
124146
echo outputs.additional_cmake_flags : ${{ steps.set_outputs.outputs.additional_cmake_flags }}
@@ -222,7 +244,7 @@ jobs:
222244
if: (needs.check_and_prepare.outputs.should_trigger_package == 'true') && !cancelled() && !failure()
223245
with:
224246
release_label: ${{ needs.check_and_prepare.outputs.release_label }}
225-
skipIntegrationTests: ${{ needs.check_and_prepare.outputs.skipIntegrationTests }}
247+
runIntegrationTests: ${{ needs.check_and_prepare.outputs.runIntegrationTests }}
226248
build_run_id: ${{ github.run_id }}
227249
working_branch: ${{ needs.decide_build_branch.outputs.build_branch }}
228250
platforms: ${{ needs.check_and_prepare.outputs.platform }}

.github/workflows/integration_tests.yml

Lines changed: 44 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
name: Integration tests
22

33
on:
4-
schedule:
5-
- cron: "0 9 * * *" # 9am UTC = 1am PST / 2am PDT
6-
7-
pull_request:
8-
types: [ labeled, closed ]
94

105
workflow_dispatch:
116
inputs:
@@ -75,66 +70,53 @@ jobs:
7570
### trigger value: manual_trigger, scheduled_trigger, label_trigger, postsubmit_trigger
7671
- id: set_outputs
7772
run: |
78-
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
79-
if [[ "${{ github.event.inputs.test_pull_request }}" != "nightly-packaging" ]]; then
80-
# Triggered manually
81-
echo "::set-output name=trigger::manual_trigger"
82-
if [[ "${{ github.event.inputs.use_expanded_matrix }}" == "1" ]]; then
83-
echo "::set-output name=requested_tests::expanded"
84-
fi
85-
if [[ -z "${{github.event.inputs.test_pull_request}}" ]]; then
86-
# test_pull_request not specified
87-
echo "::set-output name=github_ref::$GITHUB_SHA"
88-
elif [[ "${{github.event.inputs.test_pull_request}}" == *:* ]]; then
89-
# If specified as pr:commit_hash, split them.
90-
echo "::set-output name=github_ref::$(echo ${{ github.event.inputs.test_pull_request }} | cut -d: -f2)"
91-
echo "::set-output name=pr_number::$(echo ${{ github.event.inputs.test_pull_request }} | cut -d: -f1)"
92-
else
93-
# Just the PR specified, use refs/pull/<number>/merge as the ref.
94-
echo "::set-output name=github_ref::refs/pull/${{github.event.inputs.test_pull_request}}/merge"
95-
echo "::set-output name=pr_number::${{ github.event.inputs.test_pull_request }}"
96-
fi
97-
elif [[ "${{ github.event.inputs.test_pull_request }}" == "nightly-packaging" ]]; then
98-
# Triggered by scheduled packaging SDK workflow.
99-
echo "::set-output name=trigger::scheduled_trigger"
100-
echo "::set-output name=github_ref::$GITHUB_SHA"
101-
echo "::set-output name=requested_tests::expanded"
102-
fi
103-
elif [[ "${{ github.event_name }}" == "schedule" ]]; then
73+
if [[ "${{ github.event.inputs.test_pull_request }}" == *"label-quick-packaging" ]]; then
74+
# Triggered by build_starter SDK workflow.
75+
echo "::set-output name=trigger::label_trigger"
76+
echo "::set-output name=requested_tests::auto"
77+
echo "::set-output name=github_ref::${{github.sha}}"
78+
echo "::set-output name=pr_number::$(echo ${{ github.event.inputs.test_pull_request }} | cut -d: -f1)"
79+
elif [[ "${{ github.event.inputs.test_pull_request }}" == *"label-full-packaging" ]]; then
80+
# Triggered by build_starter SDK workflow.
81+
echo "::set-output name=trigger::label_trigger"
82+
echo "::set-output name=requested_tests::expanded"
83+
echo "::set-output name=github_ref::${{github.sha}}"
84+
echo "::set-output name=pr_number::$(echo ${{ github.event.inputs.test_pull_request }} | cut -d: -f1)"
85+
elif [[ "${{ github.event.inputs.test_pull_request }}" == *"pr-close-packaging" ]]; then
86+
# Triggered by build_starter SDK workflow.
87+
echo "::set-output name=trigger::postsubmit_trigger"
88+
echo "::set-output name=requested_tests::auto"
89+
echo "::set-output name=github_ref::${{github.sha}}"
90+
echo "::set-output name=pr_number::$(echo ${{ github.event.inputs.test_pull_request }} | cut -d: -f1)"
91+
elif [[ "${{ github.event.inputs.test_pull_request }}" == "nightly-packaging" ]]; then
92+
# Triggered by build_starter SDK workflow.
10493
echo "::set-output name=trigger::scheduled_trigger"
105-
echo "::set-output name=github_ref::$GITHUB_SHA"
10694
echo "::set-output name=requested_tests::expanded"
107-
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
108-
echo "::set-output name=github_ref::$GITHUB_SHA"
109-
if [[ "${{ github.event.action }}" == "labeled" && "${{ github.event.label.name }}" == "${{ env.triggerLabelPrefix }}"* ]]; then
110-
echo "::set-output name=trigger::label_trigger"
111-
echo "::set-output name=pr_number::${{ github.event.pull_request.number }}"
112-
if [[ "${{ github.event.label.name }}" == "${{ env.triggerLabelQuick }}" ]]; then
113-
echo "::set-output name=requested_tests::auto"
114-
else
115-
echo "::set-output name=requested_tests::expanded"
116-
fi
117-
elif [[ "${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged == true}}" == "true" ]]; then
118-
echo "::set-output name=trigger::postsubmit_trigger"
119-
echo "::set-output name=pr_number::${{ github.event.pull_request.number }}"
120-
echo "::set-output name=requested_tests::auto"
95+
echo "::set-output name=github_ref::${{github.sha}}"
96+
elif [[ "${{ github.event.inputs.test_pull_request }}" == "1" ]]; then
97+
# Triggered by build_starter SDK workflow.
98+
echo "::set-output name=trigger::manual_trigger"
99+
echo "::set-output name=requested_tests::auto"
100+
echo "::set-output name=github_ref::${{github.sha}}"
101+
else
102+
# Triggered manually
103+
echo "::set-output name=trigger::manual_trigger"
104+
if [[ "${{ github.event.inputs.use_expanded_matrix }}" == "1" ]]; then
105+
echo "::set-output name=requested_tests::expanded"
106+
fi
107+
if [[ -z "${{github.event.inputs.test_pull_request}}" ]]; then
108+
# test_pull_request not specified
109+
echo "::set-output name=github_ref::${{github.sha}}"
110+
elif [[ "${{github.event.inputs.test_pull_request}}" == *:* ]]; then
111+
# If specified as pr:commit_hash, split them.
112+
echo "::set-output name=github_ref::$(echo ${{ github.event.inputs.test_pull_request }} | cut -d: -f2)"
113+
echo "::set-output name=pr_number::$(echo ${{ github.event.inputs.test_pull_request }} | cut -d: -f1)"
114+
else
115+
# Just the PR specified, use refs/pull/<number>/merge as the ref.
116+
echo "::set-output name=github_ref::refs/pull/${{github.event.inputs.test_pull_request}}/merge"
117+
echo "::set-output name=pr_number::${{ github.event.inputs.test_pull_request }}"
121118
fi
122119
fi
123-
### If it's not a defined trigger, cancel workflow
124-
### e.g. Triggered by non-"test-request" label; triggered by not merged PR close event.
125-
- name: Cancel workflow
126-
if: ${{ !steps.set_outputs.outputs.trigger }}
127-
uses: andymckay/[email protected]
128-
- name: Wait for workflow cancellation
129-
if: ${{ !steps.set_outputs.outputs.trigger }}
130-
run: |
131-
sleep 300
132-
exit 1 # fail out if the cancellation above somehow failed.
133-
- name: Cancel previous runs on the same PR
134-
if: steps.set_outputs.outputs.trigger == 'label_trigger'
135-
uses: styfle/[email protected]
136-
with:
137-
access_token: ${{ github.token }}
138120
- uses: actions/checkout@v2
139121
with:
140122
ref: ${{steps.set_outputs.outputs.github_ref}}
@@ -262,7 +244,7 @@ jobs:
262244
workflow: 'build_starter.yml'
263245
run_id: ${{ github.event.inputs.packaged_sdk_run_id }}
264246
- name: Build integration tests
265-
timeout-minutes: 180
247+
timeout-minutes: 240
266248
shell: bash
267249
run: |
268250
unzip -q firebase_unity_sdk.zip -d ~/Downloads/

0 commit comments

Comments
 (0)