Integration Tests #62
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Copyright 2023 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:45 PM PDT (Daylight saving time) -> 7:45 PM UTC | |
# Add +1 hour when back in PST | |
- cron: '45 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: | |
- 'or2' | |
- 'va6' | |
- 'irl1' | |
- 'ind1' | |
- 'jpn3' | |
- 'sgp3' | |
- 'aus3' | |
- 'EmptyString' | |
- 'Invalid' | |
- 'None' | |
jobs: | |
test-integration-upstream: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
api-level: [29] | |
steps: | |
- name: Job run identifier ${{ github.event.inputs.id }} | |
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: Check branch mismatch | |
run: | | |
CURRENT_BRANCH=$(echo "${GITHUB_REF##*/}") | |
INPUT_BRANCH="${{ github.event.inputs.branch }}" | |
echo "Running on branch: ${CURRENT_BRANCH}" | |
echo "Input branch: ${INPUT_BRANCH}" | |
if [ "${CURRENT_BRANCH}" != "${INPUT_BRANCH}" ]; then | |
echo "::warning title=Branch Mismatch::Input branch '${INPUT_BRANCH}' does not match current branch '${CURRENT_BRANCH}'" | |
fi | |
# This is to help reduce Android emulator boot up flakiness issues: | |
# See: https://github.com/ReactiveCircus/android-emulator-runner/issues/324#issuecomment-2009351180 | |
- name: Delete unnecessary tools 🔧 | |
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 | |
with: | |
android: false # Don't remove Android tools | |
tool-cache: true # Remove image tool cache - rm -rf "$AGENT_TOOLSDIRECTORY" | |
dotnet: true # rm -rf /usr/share/dotnet | |
haskell: true # rm -rf /opt/ghc... | |
swap-storage: true # rm -f /mnt/swapfile (4GiB) | |
docker-images: false # Takes 16s, enable if needed in the future | |
large-packages: false # includes google-cloud-sdk and it's slow | |
# The Android emulator requires Kernel-based Virtual Machine (KVM) access to run efficiently. | |
# This step ensures that the KVM is accessible with the proper permissions across all users. | |
- name: Enable KVM group perms | |
run: | | |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger --name-match=kvm | |
ls /dev/kvm | |
- name: Checkout | |
uses: actions/checkout@v4.2.0 | |
with: | |
ref: ${{ github.event.inputs.branch }} | |
- name: Set up Java | |
uses: actions/setup-java@v4.4.0 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
- name: Gradle cache | |
uses: gradle/actions/setup-gradle@v4.1.0 | |
- name: AVD cache | |
uses: actions/cache@v4.0.2 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ matrix.api-level }} | |
# Note that the AVD configurations must exactly match what's used in the test step, otherwise the cache will not be used. | |
- name: create AVD and generate snapshot for caching | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # v2.32.0 | |
with: | |
api-level: ${{ matrix.api-level }} | |
arch: x86_64 | |
disk-size: 6000M | |
heap-size: 600M | |
force-avd-creation: false | |
emulator-options: -no-metrics -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: echo "Generated AVD snapshot for caching." | |
# Logcat logging from: https://github.com/ReactiveCircus/android-emulator-runner/issues/9#issuecomment-867909354 | |
- name: Run tests | |
uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # v2.32.0 | |
with: | |
api-level: ${{ matrix.api-level }} | |
arch: x86_64 | |
disk-size: 6000M | |
heap-size: 600M | |
force-avd-creation: false | |
emulator-options: -no-snapshot-save -no-metrics -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: | | |
mkdir -p logs # Ensure the 'logs' directory exists | |
adb logcat -c # Clear logs | |
touch logs/emulator.log # Create log file | |
chmod 777 logs/emulator.log # Allow writing to log file | |
adb logcat >> logs/emulator.log & # Pipe all logcat messages into log file as a background process | |
make upstream-integration-test TAGS_MOBILE_PROPERTY_ID=${{ github.event.inputs.tags-mobile-property-id }} EDGE_LOCATION_HINT=${{ github.event.inputs.edge-location-hint }} | |
- name: Upload Logcat Logs | |
if: always() | |
uses: actions/upload-artifact@v4.4.0 | |
with: | |
name: logcat-logs | |
path: logs/emulator.log | |
# Potential workflow solutions on job failure | |
- name: On failure | |
if: ${{ failure() }} | |
run: | | |
echo 'Job used branch: ' ${{ github.event.inputs.branch }}. Please make sure this is the branch to run off of. |