Skip to content

Integration Tests

Integration Tests #309

#
# Copyright 2024 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
# Action to execute upstream integration tests - Edge Network (Konductor)
name: Integration Tests
on:
# `*` is a special character in YAML so you have to quote this string
# Avoiding start of hour and other common times to avoid conflicts with peak times
schedule:
# Run every weekday at 12:16 PM PDT (Daylight saving time) -> 7:16 PM UTC
# Add +1 hour when back in PST
- cron: '16 19 * * 1-5'
workflow_dispatch:
inputs:
branch:
description: 'The branch to use when running the integration tests.'
required: false
default: 'main'
id:
description: '(Optional) The identifier for the run.'
required: false
tags-mobile-property-id:
type: string
description: '(Optional) The tags mobile property ID to use for the test. A default is used if not set.'
required: false
default: ''
edge-location-hint:
type: choice
description: '(Optional) The Edge location hint to set before each test.'
required: false
default: 'None'
options:
- 'aus3'
- 'ind1'
- 'irl1'
- 'jpn3'
- 'or2'
- 'sgp3'
- 'va6'
- 'EmptyString'
- 'Invalid'
- 'None'
run-name: ${{ inputs.id }}
jobs:
test-integration-upstream:
runs-on: macos-latest
steps:
- name: Job run identifier ${{ github.event.inputs.id }}
id: job-run-identifier
run: |
if [ -z "${{ github.event.inputs.id }}" ]; then \
echo No job run identifier was set.
else
echo 'Job run identifier is:' ${{ inputs.id }}
fi;
- name: Checkout
id: checkout
uses: actions/[email protected]
with:
ref: ${{ github.event.inputs.branch }}
- name: Cache Cocoapods
id: cache-cocoapods
uses: actions/[email protected]
with:
path: Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Execute Edge Network integration tests
id: execute-integration-tests
run: make test-integration-upstream TAGS_MOBILE_PROPERTY_ID=${{ github.event.inputs.tags-mobile-property-id }} EDGE_LOCATION_HINT=${{ github.event.inputs.edge-location-hint }}
# Potential workflow solutions on job failure
# All workflow setup step failures give exit code 2, with 3 as fallback
# Actual integration test failures give exit code 1
- name: On failure
id: on-failure
if: ${{ failure() }}
env:
BRANCH: ${{ github.event.inputs.branch }}
run: |
echo "Job used branch: $BRANCH. Please make sure this is the branch to run off of."
EXIT_CODE=3
if [[ "${{ steps.job-run-identifier.conclusion }}" == "failure" ]]; then
echo "Job step failed: Job run identifier."
EXIT_CODE=2
elif [[ "${{ steps.checkout.conclusion }}" == "failure" ]]; then
echo "Job step failed: Checkout."
EXIT_CODE=2
elif [[ "${{ steps.cache-cocoapods.conclusion }}" == "failure" ]]; then
echo "Job step failed: Cache Cocoapods."
EXIT_CODE=2
elif [[ "${{ steps.execute-integration-tests.conclusion }}" == "failure" ]]; then
echo "Job step failed: Execute Edge Network integration tests."
EXIT_CODE=1
else
echo "Job failed: Failure cause not identified."
fi
echo "EXIT_CODE=$EXIT_CODE" >> $GITHUB_OUTPUT
# Dynamic step name in JSON format, examples on job:
# - During job run (before this step): {"exitCode":${{ steps.on-failure.outputs.EXIT_CODE || 0 }}}
# - Failure: {"exitCode":1}
# - Success: {"exitCode":0}
- name: "{\"exitCode\":${{ steps.on-failure.outputs.EXIT_CODE || 0 }}}"
id: failure-data
if: ${{ failure() }}
run: |
echo 'exit code in the body: ${{ steps.on-failure.outputs.EXIT_CODE }}'
echo 'on-failure outputs: ${{ toJson(steps.on-failure.outputs) }}'