Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize #254 & SVG generation #280

Merged
merged 33 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ac32d2c
Remove unused code
TWiStErRob Jun 20, 2023
48059fe
Remove external storage access from SVG app
TWiStErRob Jun 20, 2023
f25ab98
Merge fix254 branch
TWiStErRob Jun 21, 2023
4d438cc
Remove unused BackupZipFileImporter
TWiStErRob Jun 20, 2023
c693ef8
Using scoped storage this is now automatic
TWiStErRob Jun 21, 2023
6c00952
Fix stack traces during normal operation
TWiStErRob Jun 21, 2023
a05c8c0
Embrace UTP for SVG generation and new CI
TWiStErRob Jun 22, 2023
74b587d
Clean up ci
TWiStErRob Jun 22, 2023
3af0652
Stricter execution
TWiStErRob Jun 22, 2023
7c9750b
Update libs to latest to include jcenter fix
TWiStErRob Jun 24, 2023
21a6dda
Add diagnostic to find the reason for
TWiStErRob Jun 24, 2023
1f05cf9
"No result found." is not enough, list fully
TWiStErRob Jun 24, 2023
712d0af
The list shows missing Android folder, probably because it's a fresh …
TWiStErRob Jun 24, 2023
96be7b0
Fix empty lines
TWiStErRob Jun 24, 2023
3c549ad
Increase timeout, boot takes ages
TWiStErRob Jun 24, 2023
e4ad06f
Explain
TWiStErRob Jun 24, 2023
4fad4b1
All versions
TWiStErRob Jun 24, 2023
69318d6
Also run SVG test just for coverage of the SVG files
TWiStErRob Jun 24, 2023
c239779
Longer emulator timeout
TWiStErRob Jun 24, 2023
7f191a3
Diagnose more
TWiStErRob Jun 24, 2023
eb5b01f
List all folders
TWiStErRob Jun 25, 2023
efdc475
List Android folders too
TWiStErRob Jun 25, 2023
c96b65b
Create folder
TWiStErRob Jun 25, 2023
cdced0b
Make the new folder discoverable
TWiStErRob Jun 26, 2023
58794c9
Extract to separate file, emulator runner doesn't support multiline
TWiStErRob Jun 26, 2023
1eaf887
Add root access for 27
TWiStErRob Jun 26, 2023
e6026b9
Add Generated SVG report
TWiStErRob Jun 28, 2023
407e6ae
Tabs
TWiStErRob Jun 28, 2023
019324c
Clean up warnings and formatting
TWiStErRob Jun 28, 2023
5604699
Make file executable
TWiStErRob Jun 28, 2023
8c217a2
Allow glob to resolve
TWiStErRob Jun 28, 2023
744f67d
Trigger only on main for all API levels.
TWiStErRob Jun 28, 2023
64f62d0
Keep double quotes, because otherwise it triggers https://github.com/…
TWiStErRob Jun 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ jobs:
script: |
adb devices -l
./gradlew --no-daemon --stacktrace :android:connectedCheck -Pandroid.testInstrumentationRunnerArguments.notAnnotation=androidx.test.filters.FlakyTest
./gradlew --no-daemon --stacktrace :android:data:svg:connectedCheck

- name: "Upload 'Instrumentation Test Results ${{ matrix.android-api }}' artifact."
if: success() || failure()
Expand Down
251 changes: 251 additions & 0 deletions .github/workflows/svg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
name: SVG
on:
workflow_dispatch:
push:
branches:
- main

jobs:

validate:
name: "🦺 Validation"
runs-on: ubuntu-latest
timeout-minutes: 2
permissions:
# actions/checkout
contents: read
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v3
with:
submodules: true

- name: "Validate Gradle Wrapper JARs."
uses: gradle/wrapper-validation-action@v1


instrumentation:
name: "🎨 Generate SVGs on ${{ matrix.android-api }}"
needs: validate
runs-on: macos-latest
timeout-minutes: 30
permissions:
# actions/checkout
contents: read
# EnricoMi/publish-unit-test-result-action -> https://github.com/EnricoMi/publish-unit-test-result-action#permissions
checks: write
strategy:
fail-fast: false
matrix:
# The Android SDK API level (number), see https://apilevels.com/.
android-api:
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
steps:
- name: "Set up JDK 11."
uses: actions/setup-java@v3
with:
java-version: 11
distribution: zulu

- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v3
with:
submodules: true

- name: "Run SVG generation on emulator."
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.android-api }}
# TODEL Some are not available: https://issuetracker.google.com/issues/267458959
target: ${{ matrix.android-api >= 32 && 'google_apis' || 'default' }}
arch: ${{ matrix.android-api >= 21 && 'x86_64' || 'x86' }}
profile: pixel
# Ensure that /storage/sdcard exists, without this the stock DocumentsUI will be non-functional.
sdcard-path-or-size: 100M
emulator-boot-timeout: 900 # 15 minutes
script: |
adb devices -l
./.github/workflows/svg/adb-shell-create-sdcard-android-dir.sh ${{ matrix.android-api }}
./gradlew --no-daemon --stacktrace :android:data:svg:connectedCheck -Pandroid.experimental.androidTest.useUnifiedTestPlatform=true -Pandroid.testInstrumentationRunnerArguments.class=net.twisterrob.inventory.android.data.svg.DumpImages

- name: "Upload 'SVG ${{ matrix.android-api }}' artifact."
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: 'SVG ${{ matrix.android-api }}'
path: |
android/data/svg/build/reports/androidTests/connected/
android/data/svg/build/outputs/androidTest-results/connected/
android/data/svg/build/outputs/connected_android_test_additional_output/

- name: "Publish 'SVG Results ${{ matrix.android-api }}' check suite."
if: success() || failure()
uses: EnricoMi/publish-unit-test-result-action/composite@v2
with:
check_name: '🔔 Test: SVG Results ${{ matrix.android-api }}'
comment_mode: off
report_individual_runs: true
test_changes_limit: 0
junit_files: android/data/svg/build/outputs/androidTest-results/connected/TEST-*.xml

report:
name: "📢 SVG Report"
runs-on: ubuntu-22.04
needs: instrumentation
# The dependency job might be skipped, we don't need to run this job then.
if: success() || failure()
timeout-minutes: 10
steps:

- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v3

- name: "Download 'SVG 21' artifact."
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: 'SVG 21'
path: 'downloads/SVG 21'

- name: "Download 'SVG 22' artifact."
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: 'SVG 22'
path: 'downloads/SVG 22'

- name: "Download 'SVG 23' artifact."
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: 'SVG 23'
path: 'downloads/SVG 23'

- name: "Download 'SVG 24' artifact."
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: 'SVG 24'
path: 'downloads/SVG 24'

- name: "Download 'SVG 25' artifact."
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: 'SVG 25'
path: 'downloads/SVG 25'

- name: "Download 'SVG 26' artifact."
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: 'SVG 26'
path: 'downloads/SVG 26'

- name: "Download 'SVG 27' artifact."
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: 'SVG 27'
path: 'downloads/SVG 27'

- name: "Download 'SVG 28' artifact."
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: 'SVG 28'
path: 'downloads/SVG 28'

- name: "Download 'SVG 29' artifact."
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: 'SVG 29'
path: 'downloads/SVG 29'

- name: "Download 'SVG 30' artifact."
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: 'SVG 30'
path: 'downloads/SVG 30'

- name: "Download 'SVG 31' artifact."
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: 'SVG 31'
path: 'downloads/SVG 31'

- name: "Download 'SVG 32' artifact."
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: 'SVG 32'
path: 'downloads/SVG 32'

- name: "Download 'SVG 33' artifact."
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: 'SVG 33'
path: 'downloads/SVG 33'

- name: "Download 'SVG 34' artifact."
if: success() || failure()
uses: actions/download-artifact@v3
with:
name: 'SVG 34'
path: 'downloads/SVG 34'

- name: "Create reporting structure."
if: success() || failure()
run: |
mkdir svg-report
cd svg-report

# Gather all input SVGs into a folder.
mkdir svgs
cp ${{github.workspace}}/android/data/src/main/res/raw/*.svg ./svgs/
basename --suffix=.svg -- ./svgs/*.svg > ./svg_names.txt

# Output all the wanted API levels into a file.
seq 21 34 > ./api_levels.txt

# Copy report HTML to this folder.
cp ${{github.workspace}}/tools/svg_render/svgs.html ./index.html

- name: "Aggregate svg_*.zip files."
if: success() || failure()
working-directory: svg-report
run: |
# Get all ZIPs into a folder.
# Glob resolution is done by shell, so can't use quotes, have to escape spaces and parentheses.
cp ${{github.workspace}}/downloads/SVG\ ??/outputs/connected_android_test_additional_output/debugAndroidTest/connected/test\(AVD\)\ -\ */svg_??.zip ./
# At this point we should have svg_??.zip files.

# Unzip all ZIPs into separate folders.
for svg_zip in svg_??.zip; do unzip "${svg_zip}" -d "${svg_zip%.zip}"; done
# At this point we should have svg_??/*.png files.

- name: "Upload 'SVG Report' artifact."
if: success() || failure()
uses: actions/upload-artifact@v2
with:
name: 'SVG Report'
path: |
svg-report/
!svg-report/svg_??.zip
22 changes: 22 additions & 0 deletions .github/workflows/svg/adb-shell-create-sdcard-android-dir.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 API_LEVEL" >&2
exit 1
fi

# Similar to GitHub actions: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
set -euxo pipefail

API_LEVEL=$1
if [ "${API_LEVEL}" -lt 29 ]; then
# Satisfy AGP's findAdditionalTestOutputDirectoryOnDevice -> queryAdditionalTestOutputLocation
# so API 21-28 can generate additional output.
adb shell "mkdir /sdcard/Android"
# Tell the Android system's MediaProvider that we added a directory.
# This will ensure that `content query --uri content://media/external/file` finds the new folder.
# Note: API 21-22 does not support readlink -e.
# Note: API 27 does not support readlink without root (21-26,28-34 is ok).
adb shell "content insert --uri content://media/external/file --bind _data:s:\$(su root readlink -f /sdcard)/Android"
else
echo "API 29+ (${API_LEVEL}) does not need to create /sdcard/Android"
fi

This file was deleted.

Loading
Loading