Repository navigation
96 lines (92 loc) · 3.79 KB
/
Copy pathe2e-build.yml
File metadata and controls
96 lines (92 loc) · 3.79 KB
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
name: E2E Build
on:
workflow_call:
inputs:
e2e_required:
description: "The e2e-scope job's decision, 'true' or 'false'. The build is skipped on 'false'."
required: false
type: string
default: 'true'
outputs:
built:
description: "'true' when the apks were built; on a pull request that does not touch the E2E sources the build is skipped."
value: ${{ jobs.build.outputs.built }}
env:
# The Gradle build cache comes from the Actions cache below instead of S3.
GRADLE_LOCAL_BUILD_CACHE: 'true'
jobs:
build:
permissions:
actions: write
contents: read
name: compose apks
# No GitHub API calls here: e2e-scope decides on the static-IP runner whether the E2E sources
# changed, so a standard GitHub-hosted runner works. The 2-core runners in the static-IP group
# shut down mid-build.
runs-on: ubuntu-24.04
if: ${{ inputs.e2e_required == 'true' }}
env:
# Without a PR number, fastlane builds without asking the GitHub API for the changed files.
GITHUB_PR_NUM: ''
outputs:
built: ${{ steps.build_apks.outputs.built }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- uses: GetStream/android-ci-actions/actions/setup-java@cb46e4f44d105a68738bfd2a1cfd156bb768665b
- uses: GetStream/android-ci-actions/actions/enable-kvm@cb46e4f44d105a68738bfd2a1cfd156bb768665b
- uses: GetStream/android-ci-actions/actions/setup-ruby@cb46e4f44d105a68738bfd2a1cfd156bb768665b
# Only pushes to develop save a new cache; every other run restores the latest one.
- name: Restore Gradle cache
id: gradle_cache
uses: actions/cache/restore@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-e2e-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-gradle-e2e-
- name: Build apks
id: build_apks
run: |
bundle exec fastlane build_e2e_test
if ls demo-app/build/outputs/apk/e2etesting/debug/*.apk > /dev/null 2>&1; then
echo "built=true" >> "$GITHUB_OUTPUT"
else
echo "built=false" >> "$GITHUB_OUTPUT"
fi
timeout-minutes: 30
- name: Save Gradle cache
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
uses: actions/cache/save@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ steps.gradle_cache.outputs.cache-primary-key }}
- name: Upload apks
uses: actions/upload-artifact@v7
with:
name: apks
path: |
demo-app/build/outputs/apk/e2etesting/debug/*.apk
demo-app/build/outputs/apk/androidTest/e2etesting/debug/*.apk
# Keeps one snapshot, so the saves don't pile up in the repo's Actions cache.
# Calls the GitHub API, and the org IP allow list only admits static-IP runners.
remove-older-gradle-caches:
needs: build
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
permissions:
actions: write
name: Remove older Gradle caches
runs-on: { group: github-public-amd64 }
steps:
# A failed save only warns, so the older snapshots stay unless the new one is listed.
- name: Remove older Gradle caches
env:
GH_TOKEN: ${{ github.token }}
NEW_KEY: ${{ runner.os }}-gradle-e2e-${{ github.run_id }}
run: |
gh cache list -R "$GITHUB_REPOSITORY" --ref "$GITHUB_REF" --key "${{ runner.os }}-gradle-e2e-" --limit 100 --json id,key \
--jq 'if any(.[]; .key == env.NEW_KEY) then .[] | select(.key != env.NEW_KEY) | .id else empty end' \
| xargs -r -n1 gh cache delete -R "$GITHUB_REPOSITORY"