Skip to content

Commit

Permalink
Revamp CI setup (#3074)
Browse files Browse the repository at this point in the history
* Bump AGP versions and try to make it green

* spotless

* Latest 8.3.0

* Add more logs to flaky test

* Remove assumeThat

* Clean up CI jobs

* Enable gradle cache

* Upload test results

* Speed up CodeQL builds

* Fix test results upload

* Run tests and lint for PRs

* Fix makefile

* Fix makefile

* Only run release-build workflow on release/ branches

* Remove unnecessary clean and stop for ui tests

* Parallelize tests

* Speed up tests depending on session finalizer

* Api dump

* Remove unnecessary robolectric test

* Reduce number of benchmarks to speed up builds

* Add logs to flaky test

* Ensure no shared state in tests

* Do not submit to another queue in PersistingOptionsObserver

* Set timeouts for spring-boot tests to avoid long-runnings

* Decouple robolectric and unit tests for sentry-android-core

* Revert "Decouple robolectric and unit tests for sentry-android-core"

This reverts commit 65887b4.

* Revert

* Delete SdkBenchmarkTest as it replicates what app-metrics action does

* Changelog

* Add --no-build-cache for distribution artifacts

* Add largeHeap to the test app
  • Loading branch information
romtsn committed Jan 10, 2024
1 parent eecfab6 commit 2fe9631
Show file tree
Hide file tree
Showing 32 changed files with 291 additions and 252 deletions.
27 changes: 9 additions & 18 deletions .github/workflows/agp-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,20 @@ on:
push:
branches:
- main
- release/**
pull_request:

jobs:
cancel-previous-workflow:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@01ce38bf961b4e243a6342cbade0dbc8ba3f0432 # pin@0.12.0
with:
access_token: ${{ github.token }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
agp-matrix-compatibility:
timeout-minutes: 30
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
agp: [ '8.0.0','8.1.0-alpha11' ]
agp: [ '8.0.0','8.1.4','8.2.0','8.3.0-beta01' ]
integrations: [ true, false ]

name: AGP Matrix Release - AGP ${{ matrix.agp }} - Integrations ${{ matrix.integrations }}
Expand All @@ -34,15 +29,15 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup Gradle
uses: gradle/gradle-build-action@982da8e78c05368c70dac0351bb82647a9e9a5d2 # pin@v2

- name: Setup Java Version
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # pin@v2

- name: Setup KVM
shell: bash
run: |
Expand All @@ -58,11 +53,6 @@ jobs:
- name: Make assembleUiTests
run: make assembleUiTests

# We stop gradle at the end to make sure the cache folders
# don't contain any lock files and are free to be cached.
- name: Make stop
run: make stop

# We tried to use the cache action to cache gradle stuff, but it made tests slower and timeout
- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@99a4aac18b4df9b3af66c4a1f04c1f23fa10c270 # pin@v2
Expand All @@ -73,6 +63,7 @@ jobs:
disable-animations: true
disable-spellchecker: true
target: 'aosp_atd'
arch: x86
channel: canary # Necessary for ATDs
script: ./gradlew sentry-android-integration-tests:sentry-uitest-android:connectedReleaseAndroidTest -DtestBuildType=release --daemon

Expand Down
65 changes: 21 additions & 44 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,43 @@ on:
push:
branches:
- main
- release/**
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build Job ${{ matrix.os }} - Java ${{ matrix.java }}
runs-on: ${{ matrix.os }}
strategy:
# we want that the matrix keeps running, default is to cancel them if it fails.
fail-fast: false
matrix:
os: [ubuntu-latest]
# Zulu Community distribution of OpenJDK
java: ['17']
name: Build Job ubuntu-latest - Java 17
runs-on: ubuntu-latest

steps:
- name: Git checkout
- name: Checkout Repo
uses: actions/checkout@v4

- name: 'Set up Java: ${{ matrix.java }}'
- name: Setup Java Version
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
java-version: '17'

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# Clean, check formatting, build and do a dry release
- name: Make all
run: make all

# We stop gradle at the end to make sure the cache folders
# don't contain any lock files and are free to be cached.
- name: Make stop
run: make stop
- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # pin@v2

- name: Archive packages
# We need artifacts from only one the builds
if: runner.os == 'Linux' && matrix.java == '17'
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}
if-no-files-found: error
path: |
./*/build/distributions/*.zip
./sentry-opentelemetry/*/build/distributions/*.zip
./sentry-android-ndk/build/intermediates/merged_native_libs/release/out/lib/*
- name: Run Tests with coverage and Lint
run: make preMerge

- name: Upload coverage to Codecov
# We need coverage data from only one the builds
if: runner.os == 'Linux' && matrix.java == '17'
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@v3
with:
name: sentry-java
fail_ci_if_error: false

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
**/build/reports/*
31 changes: 17 additions & 14 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
schedule:
- cron: '17 23 * * 3'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
analyze:
name: Analyze
Expand All @@ -20,32 +24,31 @@ jobs:
language: ['cpp', 'java']

steps:
- name: Checkout repository
- name: Checkout Repo
uses: actions/checkout@v4

- name: 'Set up Java: ${{ matrix.java }}'
- name: Setup Java Version
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
java-version: '17'

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # pin@v2

- name: Initialize CodeQL
uses: github/codeql-action/init@cdcdbb579706841c47f7063dda365e292e5cad7a # pin@v2
with:
languages: ${{ matrix.language }}

- run: |
./gradlew assemble
- if: matrix.language == 'cpp'
name: Build Cpp
run: |
./gradlew sentry-android-ndk:buildCMakeRelWithDebInfo
- if: matrix.language == 'java'
name: Build Java
run: |
./gradlew buildForCodeQL
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@cdcdbb579706841c47f7063dda365e292e5cad7a # pin@v2
11 changes: 2 additions & 9 deletions .github/workflows/generate-javadocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,8 @@ jobs:
distribution: 'temurin'
java-version: '17'

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # pin@v2

- name: Generate Aggregate Javadocs
run: |
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/integration-tests-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
- '**/sentry-android-integration-tests/**'
- '**/.github/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Benchmarks
Expand All @@ -30,16 +34,14 @@ jobs:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # pin@v2

# Clean, build and release a test apk, but only if we will run the benchmark
- name: Make assembleBenchmarks
if: env.SAUCE_USERNAME != null
run: make assembleBenchmarks

# We stop gradle at the end to make sure the cache folders
# don't contain any lock files and are free to be cached.
- name: Make stop
run: make stop

- name: Run All Tests in SauceLab
uses: saucelabs/saucectl-run-action@7fe025ef1fdc6f211add3751a6c7d8bba27ba9b1 # pin@v3
if: github.event_name != 'pull_request' && env.SAUCE_USERNAME != null
Expand Down Expand Up @@ -77,6 +79,9 @@ jobs:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # pin@v2

- uses: actions/cache@v3
id: app-plain-cache
with:
Expand Down
21 changes: 7 additions & 14 deletions .github/workflows/integration-tests-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ on:
push:
branches:
- main
- release/**
pull_request:

jobs:
cancel-previous-workflow:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@01ce38bf961b4e243a6342cbade0dbc8ba3f0432 # pin@0.12.0
with:
access_token: ${{ github.token }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Ui tests
runs-on: ubuntu-latest
Expand All @@ -33,16 +28,14 @@ jobs:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # pin@v2

# Clean, build and release a test apk, but only if we will run the benchmark
- name: Make assembleUiTests
if: env.SAUCE_USERNAME != null
run: make assembleUiTests

# We stop gradle at the end to make sure the cache folders
# don't contain any lock files and are free to be cached.
- name: Make stop
run: make stop

- name: Run Tests in SauceLab
uses: saucelabs/saucectl-run-action@7fe025ef1fdc6f211add3751a6c7d8bba27ba9b1 # pin@v3
env:
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'Release'
on:
push:
branches:
- release/**

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
release:
name: Build release artifacts
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup Java Version
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # pin@v2

- name: Build artifacts
run: make publish

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}
if-no-files-found: error
path: |
./*/build/distributions/*.zip
./sentry-opentelemetry/*/build/distributions/*.zip
./sentry-android-ndk/build/intermediates/merged_native_libs/release/out/lib/*
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- If you are setting global job listeners please also add `SentryJobListener`
- Ensure serialVersionUID of Exception classes are unique ([#3115](https://github.com/getsentry/sentry-java/pull/3115))
- Get rid of "is not eligible for getting processed by all BeanPostProcessors" warnings in Spring Boot ([#3108](https://github.com/getsentry/sentry-java/pull/3108))
- Fix missing `release` and other fields for ANRs reported with `mechanism:AppExitInfo` ([#3074](https://github.com/getsentry/sentry-java/pull/3074))

### Dependencies

Expand Down
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
.PHONY: all clean compile javadocs dryRelease update stop checkFormat format api assembleBenchmarkTestRelease assembleUiTestRelease createCoverageReports
.PHONY: all clean compile javadocs dryRelease update stop checkFormat format api assembleBenchmarkTestRelease assembleUiTestRelease createCoverageReports check preMerge publish

all: stop clean javadocs compile createCoverageReports
assembleBenchmarks: stop clean assembleBenchmarkTestRelease
assembleUiTests: stop clean assembleUiTestRelease
assembleBenchmarks: assembleBenchmarkTestRelease
assembleUiTests: assembleUiTestRelease
preMerge: check createCoverageReports
publish: clean dryRelease

# deep clean
clean:
Expand All @@ -18,7 +20,7 @@ javadocs:

# do a dry release (like a local deploy)
dryRelease:
./gradlew aggregateJavadocs publishToMavenLocal --no-daemon --no-parallel
./gradlew aggregateJavadocs distZip --no-build-cache

# check for dependencies update
update:
Expand Down Expand Up @@ -57,3 +59,7 @@ assembleUiTestRelease:
createCoverageReports:
./gradlew jacocoTestReport
./gradlew koverXmlReportRelease

# Run tests and lint
check:
./gradlew check

0 comments on commit 2fe9631

Please sign in to comment.