-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,186 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- "develop" | ||
- "main" | ||
schedule: | ||
# Run twice a day the sanity check, at 9:13 and 21:13. | ||
# You ask why 13? because probably less people schedule their tasks at exactly this time, so I | ||
# guess CI is less occupied. And 13 is a lucky number ;) | ||
- cron: "13 9,21 * * *" | ||
|
||
concurrency: | ||
group: ${{ github.ref }}-${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
contents: read | ||
actions: read | ||
checks: write | ||
|
||
jobs: | ||
unit-tests: | ||
name: Unit Tests | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
|
||
- name: Prepare Android Environment | ||
uses: ./.github/actions/prepare-android-env | ||
|
||
- name: Run test | ||
run: ./gradlew test | ||
|
||
- name: Upload tests results | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: test-results | ||
path: | | ||
*/build/test-results/** | ||
*/build/paparazzi/failures/** | ||
retention-days: 5 | ||
|
||
android-tests: | ||
name: Run UI tests on Firebase Test Lab | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
|
||
- name: LFS-warning - Prevent large files that are not LFS tracked | ||
uses: ppremk/[email protected] | ||
|
||
- name: Prepare Android Environment | ||
uses: ./.github/actions/prepare-android-env | ||
|
||
- name: Assemble App Debug APK and Android Instrumentation Tests | ||
run: ./gradlew assembleDebug assembleDebugAndroidTest | ||
|
||
- id: auth | ||
name: Authenticate to Google Cloud | ||
uses: google-github-actions/auth@v1 | ||
with: | ||
credentials_json: ${{ secrets.SERVICE_ACCOUNT }} | ||
|
||
- name: Set up Cloud SDK | ||
uses: google-github-actions/setup-gcloud@v1 | ||
with: | ||
install_components: "gsutil" | ||
|
||
- name: Generate random directory | ||
id: generate-dir | ||
run: |- | ||
echo "results_dir=$(date +%F_%T)-${RANDOM}" >> "$GITHUB_OUTPUT" | ||
echo "bucket=test-lab-07qs3ns6c51bi-iazpthysivhkq" >> "$GITHUB_OUTPUT" | ||
- name: Run tests on Firebase Test Lab | ||
run: |- | ||
gcloud firebase test android run ".github/tests.yml:android-pixel-2" --results-dir="${{ steps.generate-dir.outputs.results_dir }}" --results-bucket="${{ steps.generate-dir.outputs.bucket }}" | ||
- name: Download test results from Firebase Test Lab | ||
if: always() | ||
run: |- | ||
mkdir "app/build/test-results" | ||
gsutil cp -r "gs://${{ steps.generate-dir.outputs.bucket }}/${{ steps.generate-dir.outputs.results_dir }}/Pixel2-30-en-portrait/test_result_1.xml" "app/build/test-results/results.xml" | ||
- name: Upload tests results | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: test-results | ||
path: | | ||
*/build/test-results/** | ||
retention-days: 5 | ||
|
||
test-license-headers: | ||
name: Ensure license headers are added | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Ensure license headers are added | ||
run: python "build-tools/check-license-headers.py" | ||
|
||
test-results: | ||
name: Upload tests results | ||
runs-on: ubuntu-20.04 | ||
if: always() | ||
needs: | ||
- android-tests | ||
- unit-tests | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
sparse-checkout: build-tools/ | ||
|
||
- name: Download tests results for both jobs | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: test-results | ||
|
||
- id: auth | ||
name: Authenticate to Google Cloud | ||
uses: google-github-actions/auth@v1 | ||
with: | ||
credentials_json: ${{ secrets.SERVICE_ACCOUNT }} | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Install Python dependencies | ||
uses: py-actions/py-dependency-install@v4 | ||
with: | ||
path: "build-tools/requirements.txt" | ||
|
||
- name: Upload to Big Query | ||
run: |- | ||
if [[ "${{ github.event_name }}" != "pull_request" ]]; then | ||
python "build-tools/upload-junit-to-cloud.py" --url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" --final --glob "*/build/test-results/**/*.xml" | ||
else | ||
python "build-tools/upload-junit-to-cloud.py" --url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" --glob "*/build/test-results/**/*.xml" | ||
fi | ||
- name: Test Report | ||
uses: dorny/test-reporter@v1 | ||
with: | ||
name: Tests Results | ||
path: "*/build/test-results/**/*.xml" | ||
reporter: java-junit | ||
fail-on-error: "false" | ||
|
||
- name: Include Slack Notification | ||
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' | ||
uses: ./.github/actions/slack-notification | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
SLACK_GIT_REF: ${{ github.ref }} | ||
SLACK_WORKFLOW: ${{ github.workflow }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'kotlin-kapt' | ||
id 'org.jetbrains.kotlin.android' | ||
id 'com.google.dagger.hilt.android' | ||
id 'org.jlleitschuh.gradle.ktlint' version '11.2.0' | ||
} | ||
|
||
android { | ||
namespace 'com.appunite.loudius' | ||
compileSdk 33 | ||
|
||
defaultConfig { | ||
minSdk 24 | ||
targetSdk 33 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
buildFeatures { | ||
compose true | ||
} | ||
packagingOptions { | ||
resources { | ||
excludes += 'META-INF/{AL2.0,LGPL2.1}' | ||
excludes += 'META-INF/LICENSE.md' | ||
excludes += 'META-INF/LICENSE-notice.md' | ||
} | ||
} | ||
|
||
composeOptions { | ||
kotlinCompilerExtensionVersion '1.4.2' | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation(project(":app")) | ||
|
||
// Hilt | ||
implementation "com.google.dagger:hilt-android:2.45" | ||
kapt "com.google.dagger:hilt-compiler:2.45" | ||
api 'com.google.dagger:hilt-android-testing:2.45' | ||
|
||
// assertion library | ||
// cannot use 0.34.0 due to an existing bug | ||
// https://github.com/robfletcher/strikt/issues/259 | ||
api 'io.strikt:strikt-core:0.33.0' | ||
api 'io.strikt:strikt-mockk:0.33.0' | ||
|
||
// Setup Junit4 and Junit5 | ||
api(platform("org.junit:junit-bom:5.10.0")) | ||
api("org.junit.jupiter:junit-jupiter") { | ||
because 'allows to write and run Jupiter tests' | ||
} | ||
api("junit:junit:4.13.2") | ||
runtimeOnly("org.junit.vintage:junit-vintage-engine") { | ||
because 'allows JUnit 3 and JUnit 4 tests to run' | ||
} | ||
runtimeOnly("org.junit.platform:junit-platform-launcher") { | ||
because 'allows tests to run from IDEs that bundle older version of launcher' | ||
} | ||
|
||
//testing | ||
api 'androidx.test:core-ktx:1.5.0' | ||
api 'org.robolectric:robolectric:4.10.3' | ||
api 'androidx.test.ext:junit-ktx:1.1.5' | ||
|
||
api "io.mockk:mockk:1.13.3" | ||
|
||
api "com.squareup.okhttp3:mockwebserver:4.10.0" | ||
|
||
api 'androidx.test.ext:junit:1.1.5' | ||
api 'androidx.test.espresso:espresso-core:3.5.1' | ||
api "androidx.compose.ui:ui-test-junit4:$compose_version" | ||
|
||
api 'androidx.test.espresso:espresso-intents:3.5.1' | ||
|
||
// Firebase instrumentation lib | ||
api 'com.google.firebase:testlab-instr-lib:0.2' | ||
|
||
// ktlint | ||
ktlintRuleset project(":custom-ktlint-rules") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.