Skip to content

Build and run tests for a PR #7

Build and run tests for a PR

Build and run tests for a PR #7

Workflow file for this run

name: Build and run tests for a PR
on:
pull_request:
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
# to avoid shadow clone which would impact the version generation
# See `scripts/gen-version.sh`
fetch-depth: "0"
- name: Get version
id: get-version
run: |
echo "version=$(./scripts/gen-version.sh)" >> $GITHUB_OUTPUT
- name: Setup tmate session
timeout-minutes: 360
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
- name: Build
run: |
./scripts/build.sh
- name: Run tests
run: |
./scripts/run-tests.sh
- name: Collect artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: anbox-streaming-sdk_${{ steps.get-version.outputs.version }}
if-no-files-found: error
path: results/
run-e2e-tests:
needs: [build]
name: Run e2e tests (appliance, amd64)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Store current date and time in output
id: datetime
run: echo "datetime=$(date -u +'%Y-%m-%dT%H.%M.%SZ')" >> $GITHUB_OUTPUT
- name: Determine test configuration
id: config
run: |
echo "base_version=$(cat .base_version)" >> "$GITHUB_OUTPUT"
- name: Setup Anbox Cloud
uses: canonical/anbox-cloud-github-action@main
with:
channel: ${{ steps.config.outputs.base_version }}/edge
- name: Tune installation
run: |
amc config set container.security_updates false
- name: Restore cached images
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
with:
path: images
key: anbox-images-amd64
restore-keys: |
anbox-images-amd64-
- name: Import cached images
run: |
for name in android13 aaos13 ; do
amc image add jammy:"$name":amd64 "$GITHUB_WORKSPACE"/images/"$name"_amd64.tar.xz
done
- name: Register trust certificate with AMS
working-directory: js/tests/e2e
run: |
openssl req -x509 -newkey rsa:4096 -keyout anbox-cloud.key \
-out anbox-cloud.crt -days 365 -nodes \
-subj "/C=GB/ST=London/L=London/O=Global Security/OU=IT Department/CN=example.com"
amc config trust add ./anbox-cloud.crt
- name: Configure env variables
working-directory: js/tests/e2e
run: |
echo "CI=true" > .env.local
echo "AMS_API_CERTIFICATE=anbox-cloud.crt" >> .env.local
echo "AMS_API_CERTIFICATE_KEY=anbox-cloud.key" >> .env.local
echo "AMS_API_URL=$(sudo cat /var/snap/anbox-cloud-appliance/common/dashboard/config.yaml | grep AMS_API_URL | cut -d ' ' -f2)" >> .env.local
echo "ASG_API_URL=$(sudo cat /var/snap/anbox-cloud-appliance/common/dashboard/config.yaml | grep ASG_API_URL | cut -d ' ' -f2)" >> .env.local
echo "ASG_API_TOKEN=$(sudo cat /var/snap/anbox-cloud-appliance/common/dashboard/config.yaml | grep ASG_API_TOKEN | cut -d ' ' -f2)" >> .env.local
- name: Run tests
working-directory: js/tests/e2e
run: |
./run-tests.sh
- name: Dump logs
if: failure()
run: |
sudo snap logs -n all anbox-cloud-appliance > appliance.log
sudo anbox-cloud-appliance.buginfo > appliance.buginfo
for id in $(amc ls --format=csv | cut -d',' -f1) ; do
status=$(amc show "$id" --format=json | jq -r .status)
if [ "$status" = error ] ; then
for log in $(amc show "$id" --format=json | jq -r '.stored_logs[]' | xargs) ; do
amc show-log "$id" "$log" |& tee -a "$id"_"$log"
done
elif [ "$status" = started ] || [ "$status" = running ]; then
for name in android anbox ; do
timeout 30s amc logs "$id" -t "$name" |& tee -a "$id"_"$name".log
done
fi
done
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
if: always()
with:
name: test-data-${{ steps.datetime.outputs.datetime }}
path: |
js/tests/e2e/playwright-report/
js/tests/e2e/*.log
appliance.buginfo
*.log
retention-days: 30