• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: Build & test (snapshot)
2
3on:
4  push:
5    branches:
6      - snapshot
7    paths-ignore:
8      - '**.md'
9  pull_request:
10    branches:
11      - snapshot
12  workflow_dispatch:
13
14jobs:
15  build:
16    # Skip build if head commit contains 'skip ci'
17    if: "!contains(github.event.head_commit.message, 'skip ci')"
18
19    runs-on: ubuntu-latest
20    timeout-minutes: 30
21
22    steps:
23      - uses: actions/checkout@v2
24        with:
25          # Fetch expanded history, which is needed for affected module detection
26          fetch-depth: '500'
27
28      - name: Copy CI gradle.properties
29        run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
30
31      - name: set up JDK
32        uses: actions/setup-java@v1
33        with:
34          java-version: 17
35
36      - name: Decrypt secrets
37        run: release/signing-setup.sh ${{ secrets.ENCRYPT_KEY }}
38
39      - name: Generate cache key
40        run: ./checksum.sh checksum.txt
41
42      - uses: actions/cache@v2
43        with:
44          path: |
45            ~/.gradle/caches/modules-*
46            ~/.gradle/caches/jars-*
47            ~/.gradle/caches/build-cache-*
48          key: gradle-${{ hashFiles('checksum.txt') }}
49
50      - name: Build
51        run: |
52          ./gradlew --scan --stacktrace \
53              spotlessCheck \
54              assemble \
55              metalavaCheckCompatibilityRelease \
56              lintDebug
57
58      - name: Unit Tests
59        run: |
60          ./scripts/run-tests.sh \
61              --unit-tests \
62              --run-affected \
63              --affected-base-ref=$BASE_REF
64
65      - name: Upload test results
66        if: always()
67        uses: actions/upload-artifact@v2
68        with:
69          name: test-results-robolectric
70          path: |
71            **/build/test-results/*
72            **/build/reports/*
73
74      - name: Clean secrets
75        if: always()
76        run: release/signing-cleanup.sh
77
78  test:
79    runs-on: macos-latest
80    needs: build
81    timeout-minutes: 50
82
83    strategy:
84      # Allow tests to continue on other devices if they fail on one device.
85      fail-fast: false
86      matrix:
87        api-level: [ 22, 26, 29, 31, 32 ]
88        shard: [ 0, 1 ] # Need to update shard-count below if this changes
89
90    env:
91      TERM: dumb
92
93    steps:
94      - uses: actions/checkout@v2
95        with:
96          # Fetch expanded history, which is needed for affected module detection
97          fetch-depth: '500'
98
99      - name: Copy CI gradle.properties
100        run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
101
102      - name: set up JDK
103        uses: actions/setup-java@v1
104        with:
105          java-version: 17
106
107      - name: Decrypt secrets
108        run: release/signing-setup.sh ${{ secrets.ENCRYPT_KEY }}
109
110      - name: Generate cache key
111        run: ./checksum.sh checksum.txt
112
113      - uses: actions/cache@v2
114        with:
115          path: |
116            ~/.gradle/caches/modules-*
117            ~/.gradle/caches/jars-*
118            ~/.gradle/caches/build-cache-*
119          key: gradle-${{ hashFiles('checksum.txt') }}
120
121      # Determine what emulator image to use. We run all API 28+ emulators using
122      # the google_apis image
123      - name: Determine emulator target
124        id: determine-target
125        env:
126          API_LEVEL: ${{ matrix.api-level }}
127        run: |
128          TARGET="default"
129          if [ "$API_LEVEL" -ge "28" ]; then
130            TARGET="google_apis"
131          fi
132          echo "TARGET=$TARGET" >> $GITHUB_OUTPUT
133
134      - name: Run tests
135        uses: reactivecircus/android-emulator-runner@v2
136        with:
137          api-level: ${{ matrix.api-level }}
138          target: ${{ steps.determine-target.outputs.TARGET }}
139          profile: Galaxy Nexus
140          script: ./scripts/run-tests.sh --log-file=logcat.txt --run-affected --affected-base-ref=$BASE_REF --shard-index=${{ matrix.shard }} --shard-count=2
141
142      - name: Clean secrets
143        if: always()
144        run: release/signing-cleanup.sh
145
146      - name: Upload logs
147        if: always()
148        uses: actions/upload-artifact@v2
149        with:
150          name: logs-${{ matrix.api-level }}-${{ steps.determine-target.outputs.TARGET }}-${{ matrix.shard }}
151          path: logcat.txt
152
153      - name: Upload test results
154        if: always()
155        uses: actions/upload-artifact@v2
156        with:
157          name: test-results-${{ matrix.api-level }}-${{ steps.determine-target.outputs.TARGET }}-${{ matrix.shard }}
158          path: |
159            **/build/reports/*
160            **/build/outputs/*/connected/*
161
162  deploy:
163    if: github.event_name == 'push' # only deploy for pushed commits (not PRs)
164
165    runs-on: ubuntu-latest
166    needs: [ build, test ]
167    timeout-minutes: 30
168    env:
169      TERM: dumb
170
171    steps:
172      - uses: actions/checkout@v2
173
174      - name: Copy CI gradle.properties
175        run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
176
177      - name: set up JDK
178        uses: actions/setup-java@v1
179        with:
180          java-version: 17
181
182      - name: Decrypt secrets
183        run: release/signing-setup.sh ${{ secrets.ENCRYPT_KEY }}
184
185      - name: Generate cache key
186        run: ./checksum.sh checksum.txt
187
188      - uses: actions/cache@v2
189        with:
190          path: |
191            ~/.gradle/caches/modules-*
192            ~/.gradle/caches/jars-*
193            ~/.gradle/caches/build-cache-*
194          key: gradle-${{ hashFiles('checksum.txt') }}
195
196      - name: Deploy to Sonatype
197        run: ./gradlew publish --no-parallel --stacktrace --no-configuration-cache
198        env:
199          ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
200          ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
201
202      - name: Clean secrets
203        if: always()
204        run: release/signing-cleanup.sh
205