mirror of
https://github.com/bitwarden/android.git
synced 2026-02-05 07:28:04 -06:00
117 lines
4.1 KiB
YAML
117 lines
4.1 KiB
YAML
name: Test
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
- "rc"
|
|
- "hotfix-rc"
|
|
pull_request:
|
|
types: [opened, synchronize]
|
|
merge_group:
|
|
types: [checks_requested]
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
_JAVA_VERSION: 21
|
|
_GITHUB_ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}
|
|
|
|
jobs:
|
|
test:
|
|
name: Test
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
packages: read
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- name: Check out repo
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Validate Gradle wrapper
|
|
uses: gradle/actions/wrapper-validation@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
|
|
|
- name: Cache Gradle files
|
|
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: ${{ runner.os }}-gradle-v2-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/libs.versions.toml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-gradle-v2-
|
|
|
|
- name: Cache build output
|
|
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
|
with:
|
|
path: |
|
|
${{ github.workspace }}/build-cache
|
|
key: ${{ runner.os }}-build-cache-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-
|
|
|
|
- name: Configure Ruby
|
|
uses: ruby/setup-ruby@44511735964dcb71245e7e55f72539531f7bc0eb # v1.257.0
|
|
with:
|
|
bundler-cache: true
|
|
|
|
- name: Configure JDK
|
|
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
|
with:
|
|
distribution: "temurin"
|
|
java-version: ${{ env._JAVA_VERSION }}
|
|
|
|
- name: Install Fastlane
|
|
run: |
|
|
bundle config path vendor/bundle
|
|
bundle install --jobs 4 --retry 3
|
|
|
|
- name: Build and test
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Used in settings.gradle.kts to download the SDK from GitHub Maven Packages
|
|
run: |
|
|
bundle exec fastlane check
|
|
|
|
- name: Upload test reports
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
|
if: always()
|
|
with:
|
|
name: test-reports
|
|
path: |
|
|
build/reports/kover/reportMergedCoverage.xml
|
|
app/build/reports/tests/
|
|
authenticator/build/reports/tests/
|
|
authenticatorbridge/build/reports/tests/
|
|
core/build/reports/tests/
|
|
data/build/reports/tests/
|
|
network/build/reports/tests/
|
|
ui/build/reports/tests/
|
|
|
|
- name: Upload to codecov.io
|
|
id: upload-to-codecov
|
|
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
|
|
if: github.event_name == 'push' || github.event_name == 'pull_request'
|
|
continue-on-error: true
|
|
with:
|
|
os: linux
|
|
files: build/reports/kover/reportMergedCoverage.xml
|
|
fail_ci_if_error: true
|
|
disable_search: true
|
|
|
|
- name: Comment PR if tests failed
|
|
if: steps.upload-to-codecov.outcome == 'failure' && (github.event_name == 'push' || github.event_name == 'pull_request')
|
|
env:
|
|
PR_NUMBER: ${{ github.event.number }}
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
RUN_ACTOR: ${{ github.triggering_actor }}
|
|
run: |
|
|
echo "> [!WARNING]" >> "$GITHUB_STEP_SUMMARY"
|
|
echo "> Uploading code coverage report failed. Please check the \"Upload to codecov.io\" step of \"Process Test Reports\" job for more details." >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
if [ -n "$PR_NUMBER" ]; then
|
|
message=$'> [!WARNING]\n> @'$RUN_ACTOR' Uploading code coverage report failed. Please check the "Upload to codecov.io" step of [Process Test Reports job]('$_GITHUB_ACTION_RUN_URL') for more details.'
|
|
gh pr comment --repo "$GITHUB_REPOSITORY" "$PR_NUMBER" --body "$message"
|
|
fi
|