forked from canonical/anbox-streaming-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (122 loc) · 4.76 KB
/
pr.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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