Skip to content

Commit

Permalink
Add Generated SVG report
Browse files Browse the repository at this point in the history
  • Loading branch information
TWiStErRob committed Jun 28, 2023
1 parent 1eaf887 commit e6026b9
Show file tree
Hide file tree
Showing 5 changed files with 438 additions and 37 deletions.
183 changes: 166 additions & 17 deletions .github/workflows/svg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ jobs:
# 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
# - 22
# - 23
# - 24
# - 25
# - 26
# - 27
# - 28
# - 29
# - 30
# - 31
# - 32
# - 33
- 34
steps:
- name: "Set up JDK 11."
Expand All @@ -78,7 +78,7 @@ jobs:
emulator-boot-timeout: 900 # 15 minutes
script: |
adb devices -l
./config/scripts/adb-shell-create-sdcard-android-dir.sh ${{ matrix.android-api }}
./.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."
Expand All @@ -87,9 +87,9 @@ jobs:
with:
name: 'SVG ${{ matrix.android-api }}'
path: |
${{ github.workspace }}/**/build/reports/androidTests/connected/
${{ github.workspace }}/**/build/outputs/androidTest-results/connected/
${{ github.workspace }}/**/build/outputs/connected_android_test_additional_output/
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()
Expand All @@ -99,4 +99,153 @@ jobs:
comment_mode: off
report_individual_runs: true
test_changes_limit: 0
junit_files: ${{ github.workspace }}/**/build/outputs/androidTest-results/connected/TEST-*.xml
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,10 @@ fi
set -euxo pipefail

API_LEVEL=$1
adb shell "content query --uri content://media/external/file --projection _data" || true
adb shell "readlink -f /sdcard" || true
adb shell "ls -la /sdcard" || true
adb shell "ls -la /sdcard/" || true
adb shell "ls -la /sdcard/Android" || true
adb shell "ls -la /sdcard/Android/data" || true
adb shell "ls -la /storage/emulated/0" || true
adb shell "ls -la /storage/emulated/0/Android" || true
if [ "${API_LEVEL}" -lt 29 ]; then
# Satisfy AGP's findAdditionalTestOutputDirectoryOnDevice -> queryAdditionalTestOutputLocation
# so API 21-28 can generate additional output.
adb shell "mkdir -p /sdcard/Android"
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.
Expand All @@ -28,11 +20,3 @@ if [ "${API_LEVEL}" -lt 29 ]; then
else
echo "API 29+ (${API_LEVEL}) does not need to create /sdcard/Android"
fi
adb shell "content query --uri content://media/external/file --projection _data" || true
adb shell "readlink -f /sdcard" || true
adb shell "ls -la /sdcard" || true
adb shell "ls -la /sdcard/" || true
adb shell "ls -la /sdcard/Android" || true
adb shell "ls -la /sdcard/Android/data" || true
adb shell "ls -la /storage/emulated/0" || true
adb shell "ls -la /storage/emulated/0/Android" || true
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ public void test() throws Throwable {
LOG.info("Running on {} cores.", cpus);
ExecutorService service = Executors.newFixedThreadPool(cpus);
Set<String> exclusions = new HashSet<>(Arrays.asList(
"shrink_resources",
"icon_preview",
"icon_helpers"
"shrink_resources", // Resource for AAPT.
"icon_preview", // Development tool.
"icon_helpers", // Development tool.
"icon_template" // Template for new icons.
));
List<Future<?>> jobs = new ArrayList<>();
for (final Field field : fields) {
Expand Down
4 changes: 4 additions & 0 deletions tools/svg_render/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
api_levels.txt
svg_names.txt
svgs/
svg_*/
Loading

0 comments on commit e6026b9

Please sign in to comment.