diff --git a/.github/actions/prepare-android-env/action.yml b/.github/actions/prepare-android-env/action.yml index 76c262a17..aead3c54b 100644 --- a/.github/actions/prepare-android-env/action.yml +++ b/.github/actions/prepare-android-env/action.yml @@ -6,7 +6,7 @@ runs: - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: "11" + java-version: "17" distribution: "adopt" cache: gradle diff --git a/.github/workflows/run-code-quality-check.yml b/.github/workflows/run-code-quality-check.yml index f0d881c81..0d8d7483d 100644 --- a/.github/workflows/run-code-quality-check.yml +++ b/.github/workflows/run-code-quality-check.yml @@ -1,107 +1,107 @@ ---- -# MegaLinter GitHub Action configuration file -# More info at https://megalinter.github.io -name: MegaLinter - -on: - push: - pull_request: - branches: [main, develop] - -env: - APPLY_FIXES: all # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool) - APPLY_FIXES_EVENT: pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all) - APPLY_FIXES_MODE: commit # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request) - -concurrency: - group: ${{ github.ref }}-${{ github.workflow }} - cancel-in-progress: true - -permissions: - checks: write - contents: write - statuses: write - pull-requests: write - -jobs: - build: - name: MegaLinter - runs-on: ubuntu-latest - steps: - # Git Checkout - - name: Checkout Code - uses: actions/checkout@v3 - with: - token: ${{secrets.PAT || secrets.GITHUB_TOKEN }} - fetch-depth: 0 # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to improve performances - - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: "11" - distribution: "adopt" - cache: gradle - - - name: Build custom rules - run: ./gradlew :custom-ktlint-rules:assemble - - # MegaLinter - - name: MegaLinter - id: ml - # You can override MegaLinter flavor used to have faster performances - # More info at https://megalinter.github.io/flavors/ - uses: oxsecurity/megalinter@v6 - env: - # All available variables are described in documentation - # https://megalinter.github.io/configuration/ - VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} # Validates all source when push on main, else just the git diff with main. Override with true if you always want to lint all sources - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - KOTLIN_KTLINT_ARGUMENTS: "--ruleset=custom-ktlint-rules/build/libs/custom-ktlint-rules.jar" - # ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY - # DISABLE: COPYPASTE,SPELL # Uncomment to disable copy-paste and spell checks - - # Upload MegaLinter artifacts - - name: Archive production artifacts - if: ${{ success() }} || ${{ failure() }} - uses: actions/upload-artifact@v3 - with: - name: MegaLinter reports - path: | - megalinter-reports - mega-linter.log - - # Create pull request if applicable (for now works only on PR from same repository, not from forks) - - name: Create Pull Request with applied fixes - id: cpr - if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} - commit-message: "[MegaLinter] Apply linters automatic fixes" - title: "[MegaLinter] Apply linters automatic fixes" - labels: bot - base: ${{ github.head_ref }} - - name: Create PR output - if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - run: | - echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" - - # Push new commit if applicable (for now works only on PR from same repository, not from forks) - - name: Prepare commit - if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - run: sudo chown -Rc $UID .git/ - - name: Commit and push applied linter fixes - if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - uses: stefanzweifel/git-auto-commit-action@v4 - with: - branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }} - commit_message: "[MegaLinter] Apply linters fixes" - - - name: Include Slack Notification - if: failure() && (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 }} +#--- +## MegaLinter GitHub Action configuration file +## More info at https://megalinter.github.io +#name: MegaLinter +# +#on: +# push: +# pull_request: +# branches: [main, develop] +# +#env: +# APPLY_FIXES: all # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool) +# APPLY_FIXES_EVENT: pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all) +# APPLY_FIXES_MODE: commit # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request) +# +#concurrency: +# group: ${{ github.ref }}-${{ github.workflow }} +# cancel-in-progress: true +# +#permissions: +# checks: write +# contents: write +# statuses: write +# pull-requests: write +# +#jobs: +# build: +# name: MegaLinter +# runs-on: ubuntu-latest +# steps: +# # Git Checkout +# - name: Checkout Code +# uses: actions/checkout@v3 +# with: +# token: ${{secrets.PAT || secrets.GITHUB_TOKEN }} +# fetch-depth: 0 # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to improve performances +# +# - name: Set up JDK +# uses: actions/setup-java@v3 +# with: +# java-version: "11" +# distribution: "adopt" +# cache: gradle +# +# - name: Build custom rules +# run: ./gradlew :custom-ktlint-rules:assemble +# +# # MegaLinter +# - name: MegaLinter +# id: ml +# # You can override MegaLinter flavor used to have faster performances +# # More info at https://megalinter.github.io/flavors/ +# uses: oxsecurity/megalinter@v6 +# env: +# # All available variables are described in documentation +# # https://megalinter.github.io/configuration/ +# VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} # Validates all source when push on main, else just the git diff with main. Override with true if you always want to lint all sources +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# KOTLIN_KTLINT_ARGUMENTS: "--ruleset=custom-ktlint-rules/build/libs/custom-ktlint-rules.jar" +# # ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY +# # DISABLE: COPYPASTE,SPELL # Uncomment to disable copy-paste and spell checks +# +# # Upload MegaLinter artifacts +# - name: Archive production artifacts +# if: ${{ success() }} || ${{ failure() }} +# uses: actions/upload-artifact@v3 +# with: +# name: MegaLinter reports +# path: | +# megalinter-reports +# mega-linter.log +# +# # Create pull request if applicable (for now works only on PR from same repository, not from forks) +# - name: Create Pull Request with applied fixes +# id: cpr +# if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') +# uses: peter-evans/create-pull-request@v4 +# with: +# token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} +# commit-message: "[MegaLinter] Apply linters automatic fixes" +# title: "[MegaLinter] Apply linters automatic fixes" +# labels: bot +# base: ${{ github.head_ref }} +# - name: Create PR output +# if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') +# run: | +# echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" +# echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" +# +# # Push new commit if applicable (for now works only on PR from same repository, not from forks) +# - name: Prepare commit +# if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') +# run: sudo chown -Rc $UID .git/ +# - name: Commit and push applied linter fixes +# if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') +# uses: stefanzweifel/git-auto-commit-action@v4 +# with: +# branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }} +# commit_message: "[MegaLinter] Apply linters fixes" +# +# - name: Include Slack Notification +# if: failure() && (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 }} diff --git a/.github/workflows/run-snapshot-generation.yml b/.github/workflows/run-snapshot-generation.yml index 57b635d38..2093ca8a3 100644 --- a/.github/workflows/run-snapshot-generation.yml +++ b/.github/workflows/run-snapshot-generation.yml @@ -1,110 +1,110 @@ ---- -# Golden tests recording with Paparazzi configuration file -# Add [New snapshots] to the title of your PR to record new snapshots. -# Remove it to verify snapshots instead. -name: Snapshot recording - -on: - pull_request: - types: [opened, edited, synchronize] - -concurrency: - group: ${{ github.ref }}-${{ github.workflow }} - cancel-in-progress: true - -permissions: - checks: write - contents: write - statuses: write - pull-requests: write - actions: write - -jobs: - generate_snapshots: - if: ${{contains(github.event.pull_request.title, '[New snapshots]')}} - name: Generate snapshots - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - lfs: true - - - name: Gradle - Record snapshots with Paparazzi - id: testStep - run: ./gradlew components:recordPaparazziDebug - - - name: Commit and push recorded screenshots - uses: stefanzweifel/git-auto-commit-action@v4 - with: - branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }} - commit_message: "[Paparazzi] Record new snapshots" - - - name: Upload snapshot record report - if: failure() - uses: actions/upload-artifact@v3 - with: - name: snapshot-recording-failure-report - path: components/build/reports/tests/testDebugUnitTest/ - - - name: Find PR number - uses: jwalton/gh-find-current-pr@v1 - id: findPRId - if: always() - with: - state: open - - - name: Find Comment on PR - uses: peter-evans/find-comment@v2 - id: findCommentId - if: always() - with: - issue-number: ${{ steps.findPRId.outputs.pr }} - comment-author: "github-actions[bot]" - body-regex: "Snapshot recording result:" - - - name: Create or update comment on PR (Success) - uses: peter-evans/create-or-update-comment@v3 - if: always() && steps.testStep.outcome == 'success' - with: - comment-id: ${{ steps.findCommentId.outputs.comment-id }} - issue-number: ${{ steps.findPRId.outputs.pr }} - body: | - Snapshot recording result: :heavy_check_mark: - New snapshots recorded! Everything looks good! - - If there were changes in the user interface, a new commit has been created. You can review the new snapshots in the diff. If you find them acceptable, please proceed to merge this pull request. - - However, if you did not intend to record new snapshots, please remove the '[New snapshots]' part from your title (and discard the commit that includes the new snapshots). It will cause to run snapshot verification instead of recording. - edit-mode: replace - reactions: | - heart - hooray - reactions-edit-mode: replace - - - name: Create or update comment on PR (Failure) - uses: peter-evans/create-or-update-comment@v3 - if: always() && steps.testStep.outcome == 'failure' - with: - comment-id: ${{ steps.findCommentId.outputs.comment-id }} - issue-number: ${{ steps.findPRId.outputs.pr }} - body: | - Snapshot recording result: :x: - Something went wrong during snapshot recording. - If you need further investigation: - - Head over to the artifacts section of the [CI Run](https://github.com/appunite/Loudius/actions/runs/${{ github.run_id }}). - - Download the zip. - - Unzip and you can find report showing the problem - - If you not intended to record new snapshots please remove '[New snapshots]' part from your pull request title. It will cause to run snapshot verification instead of recording. - edit-mode: replace - reactions: | - confused - reactions-edit-mode: replace - - - name: Include Slack Notification - if: failure() && (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 }} +#--- +## Golden tests recording with Paparazzi configuration file +## Add [New snapshots] to the title of your PR to record new snapshots. +## Remove it to verify snapshots instead. +#name: Snapshot recording +# +#on: +# pull_request: +# types: [opened, edited, synchronize] +# +#concurrency: +# group: ${{ github.ref }}-${{ github.workflow }} +# cancel-in-progress: true +# +#permissions: +# checks: write +# contents: write +# statuses: write +# pull-requests: write +# actions: write +# +#jobs: +# generate_snapshots: +# if: ${{contains(github.event.pull_request.title, '[New snapshots]')}} +# name: Generate snapshots +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# with: +# lfs: true +# +# - name: Gradle - Record snapshots with Paparazzi +# id: testStep +# run: ./gradlew clean components:recordPaparazziDebug +# +# - name: Commit and push recorded screenshots +# uses: stefanzweifel/git-auto-commit-action@v4 +# with: +# branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }} +# commit_message: "[Paparazzi] Record new snapshots" +# +# - name: Upload snapshot record report +# if: failure() +# uses: actions/upload-artifact@v3 +# with: +# name: snapshot-recording-failure-report +# path: /home/runner/work/Loudius/Loudius/components/build/reports/tests/testDebugUnitTest/ +# +# - name: Find PR number +# uses: jwalton/gh-find-current-pr@v1 +# id: findPRId +# if: always() +# with: +# state: open +# +# - name: Find Comment on PR +# uses: peter-evans/find-comment@v2 +# id: findCommentId +# if: always() +# with: +# issue-number: ${{ steps.findPRId.outputs.pr }} +# comment-author: "github-actions[bot]" +# body-regex: "Snapshot (testing|recording) result:" +# +# - name: Create or update comment on PR (Success) +# uses: peter-evans/create-or-update-comment@v3 +# if: always() && steps.testStep.outcome == 'success' +# with: +# comment-id: ${{ steps.findCommentId.outputs.comment-id }} +# issue-number: ${{ steps.findPRId.outputs.pr }} +# body: | +# Snapshot recording result: :heavy_check_mark: +# New snapshots recorded! Everything looks good! +# +# If there were changes in the user interface, a new commit has been created. You can review the new snapshots in the diff. If you find them acceptable, please proceed to merge this pull request. +# +# However, if you did not intend to record new snapshots, please remove the '[New snapshots]' part from your title (and discard the commit that includes the new snapshots). It will cause to run snapshot verification instead of recording. +# edit-mode: replace +# reactions: | +# heart +# hooray +# reactions-edit-mode: replace +# +# - name: Create or update comment on PR (Failure) +# uses: peter-evans/create-or-update-comment@v3 +# if: always() && steps.testStep.outcome == 'failure' +# with: +# comment-id: ${{ steps.findCommentId.outputs.comment-id }} +# issue-number: ${{ steps.findPRId.outputs.pr }} +# body: | +# Snapshot recording result: :x: +# Something went wrong during snapshot recording. +# If you need further investigation: +# - Head over to the artifacts section of the [CI Run](https://github.com/appunite/Loudius/actions/runs/${{ github.run_id }}). +# - Download the zip. +# - Unzip and you can find report showing the problem +# +# If you not intended to record new snapshots please remove '[New snapshots]' part from your pull request title. It will cause to run snapshot verification instead of recording. +# edit-mode: replace +# reactions: | +# confused +# reactions-edit-mode: replace +# +# - name: Include Slack Notification +# if: failure() && (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 }} diff --git a/.github/workflows/run-snapshot-test.yml b/.github/workflows/run-snapshot-test.yml new file mode 100644 index 000000000..baeef66d5 --- /dev/null +++ b/.github/workflows/run-snapshot-test.yml @@ -0,0 +1,107 @@ +#--- +#name: Snapshot verification +# +#on: +# pull_request: +# +#concurrency: +# group: ${{ github.ref }}-${{ github.workflow }} +# cancel-in-progress: true +# +#permissions: +# checks: write +# contents: write +# statuses: write +# pull-requests: write +# actions: write +# +#jobs: +# test: +# if: ${{!contains(github.event.pull_request.title, '[New snapshots]')}} +# name: Verify snapshots +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# with: +# lfs: true +# +# - name: Prepare Android Environment +# uses: ./.github/actions/prepare-android-env +# +# - name: LFS-warning +# uses: ppremk/lfs-warning@v3.2 +# +# - name: Gradle - Verify snapshots with Paparazzi +# id: testStep +# run: ./gradlew clean components:verifyPaparazziDebug +# +# - name: Upload snapshot failure deltas +# if: failure() +# uses: actions/upload-artifact@v3 +# with: +# name: snapshot-failure-deltas +# path: /home/runner/work/Loudius/Loudius/components/out/failures/ +# +# - name: Upload snapshot failure report +# if: failure() +# uses: actions/upload-artifact@v3 +# with: +# name: snapshot-failure-report +# path: /home/runner/work/Loudius/Loudius/components/build/reports/tests/testDebugUnitTest/ +# +# - name: Find PR number +# uses: jwalton/gh-find-current-pr@v1 +# id: findPRId +# if: always() +# with: +# state: open +# +# - name: Find Comment on PR +# uses: peter-evans/find-comment@v2 +# id: findCommentId +# if: always() +# with: +# issue-number: ${{ steps.findPRId.outputs.pr }} +# comment-author: "github-actions[bot]" +# body-regex: "Snapshot (testing|recording) result:" +# +# - name: Create or update comment on PR (Success) +# uses: peter-evans/create-or-update-comment@v3 +# if: always() && steps.testStep.outcome == 'success' +# with: +# comment-id: ${{ steps.findCommentId.outputs.comment-id }} +# issue-number: ${{ steps.findPRId.outputs.pr }} +# body: | +# Snapshot testing result: :heavy_check_mark: +# Everything looks good! +# edit-mode: replace +# reactions: | +# heart +# hooray +# reactions-edit-mode: replace +# +# - name: Create or update comment on PR (Failure) +# uses: peter-evans/create-or-update-comment@v3 +# if: always() && steps.testStep.outcome == 'failure' +# with: +# comment-id: ${{ steps.findCommentId.outputs.comment-id }} +# issue-number: ${{ steps.findPRId.outputs.pr }} +# body: | +# Snapshot testing result: :x: +# Some of the snapshot tests seem to have failed. Please: +# - Head over to the artifacts section of the [CI Run](https://github.com/appunite/Loudius/actions/runs/${{ github.run_id }}). +# - Download the zip. +# - Unzip and you can find one or more images that show the expected and the actual test results. +# - If these changes are fixing an issue or are part of a new feature then please speak to the maintainer. If they are not intended then please fix them and repush again. +# edit-mode: replace +# reactions: | +# confused +# reactions-edit-mode: replace +# +# - name: Include Slack Notification +# if: failure() && (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 }} diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index aba3b72fe..ed4aed52d 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -1,200 +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 - env: - LOUDIUS_CLIENT_SECRET: ${{ secrets.LOUDIUS_CLIENT_SECRET }} - LOUDIUS_CLIENT_ID: ${{ secrets.LOUDIUS_CLIENT_ID }} - LOUDIUS_GITHUB_USER_PASSWORD: ${{ secrets.LOUDIUS_GITHUB_USER_PASSWORD }} - LOUDIUS_GITHUB_USER_NAME: ${{ secrets.LOUDIUS_GITHUB_USER_NAME }} - LOUDIUS_GITHUB_USER_OTP_SECRET: ${{ secrets.LOUDIUS_GITHUB_USER_OTP_SECRET }} - - - 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/lfs-warning@v3.2 - - - name: Prepare Android Environment - uses: ./.github/actions/prepare-android-env - - - name: Assemble App Debug APK and Android Instrumentation Tests - run: ./gradlew assembleDebug assembleDebugAndroidTest - env: - LOUDIUS_CLIENT_SECRET: ${{ secrets.LOUDIUS_CLIENT_SECRET }} - LOUDIUS_CLIENT_ID: ${{ secrets.LOUDIUS_CLIENT_ID }} - LOUDIUS_GITHUB_USER_PASSWORD: ${{ secrets.LOUDIUS_GITHUB_USER_PASSWORD }} - LOUDIUS_GITHUB_USER_NAME: ${{ secrets.LOUDIUS_GITHUB_USER_NAME }} - LOUDIUS_GITHUB_USER_OTP_SECRET: ${{ secrets.LOUDIUS_GITHUB_USER_OTP_SECRET }} - - - 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 \ - --app="app/build/outputs/apk/debug/app-debug.apk" \ - --test="app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk" \ - --device="model=Pixel2.arm,version=33,locale=en,orientation=portrait" \ - --type=instrumentation \ - --use-orchestrator \ - --test-runner-class="com.appunite.loudius.util.HiltTestRunner" \ - --timeout="20m" \ - --results-dir="${{ steps.generate-dir.outputs.results_dir }}" \ - --results-bucket="${{ steps.generate-dir.outputs.bucket }}" \ - --environment-variables "clearPackageData=true,coverage=true,coverageFilePath=/sdcard/Download/" - - - 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.arm-33-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 }} +#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/lfs-warning@v3.2 +# +# - 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 }} diff --git a/.github/workflows/run-ui-test.yml b/.github/workflows/run-ui-test.yml new file mode 100644 index 000000000..355b10d93 --- /dev/null +++ b/.github/workflows/run-ui-test.yml @@ -0,0 +1,84 @@ +#name: Android Release +# +#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 * * *" +# +#permissions: read-all +# +#concurrency: +# group: ${{ github.ref }}-${{ github.workflow }} +# cancel-in-progress: true +# +#jobs: +# apk: +# name: Run UI tests on Firebase Test Lab +# runs-on: ubuntu-20.04 +# +# steps: +# - name: Checkout +# uses: actions/checkout@v3 +# +# - 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" +# +# - id: auth +# name: Authenticate to Google Cloud +# uses: google-github-actions/auth@v1 +# with: +# credentials_json: ${{ secrets.SERVICE_ACCOUNT }} +# +# - name: Prepare Android Environment +# uses: ./.github/actions/prepare-android-env +# +# - name: Assemble App Debug APK and Android Instrumentation Tests +# run: ./gradlew assembleDebug assembleDebugAndroidTest +# +# - name: Set up Cloud SDK +# uses: google-github-actions/setup-gcloud@v1 +# with: +# install_components: "gsutil" +# +# - id: generate-dir +# name: Generate random directory +# 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: Upload to Big Query +# if: always() +# run: |- +# mkdir "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" "build/test-results/results.xml" +# if [[ "${{ github.event_name }}" != "pull_request" ]]; then +# python "build-tools/upload-junit-to-cloud.py" --final +# else +# python "build-tools/upload-junit-to-cloud.py" +# fi +# +# - name: Include Slack Notification +# if: failure() && (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 }} diff --git a/.github/workflows/run-unit-test.yml b/.github/workflows/run-unit-test.yml new file mode 100644 index 000000000..fbd8c5eed --- /dev/null +++ b/.github/workflows/run-unit-test.yml @@ -0,0 +1,53 @@ +name: Run unit tests + +on: + pull_request: + push: + branches: + - "develop" + - "main" + + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true + +permissions: read-all + +jobs: + unit-tests: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Prepare Android Environment + uses: ./.github/actions/prepare-android-env + + - name: Run test + run: ./gradlew codeCoverage + env: + GITHUB_USER: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Store HTML coverage report + uses: actions/upload-artifact@v3 + with: + name: coverage-report + path: "${{github.workspace}}/app/build/reports/jacoco/html/" + + - name: Add coverage to PR + id: jacoco + uses: madrapps/jacoco-report@v1.6.1 + with: + paths: | + ${{ github.workspace }}/**/build/reports/jacoco/codeCoverage/codeCoverage.xml + + - name: Include Slack Notification + if: failure() && (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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..1bdaaf424 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,45 @@ +#name: Run code coverage +# +#on: +# pull_request: +# push: +# branches: +# - "develop" +# - "main" +# +# # A workflow run is made up of one or more jobs that can run sequentially or in parallel +#jobs: +# # This workflow contains a single job called "build" +# build: +# # The type of runner that the job will run on +# runs-on: macos-latest +# # Steps represent a sequence of tasks that will be executed as part of the job +# steps: +# - uses: actions/checkout@v3 +# +# - name: Set up JDK +# uses: actions/setup-java@v3 +# with: +# java-version: "11" +# distribution: "adopt" +# cache: gradle +# +# - name: Validate Gradle wrapper +# uses: gradle/wrapper-validation-action@v1 +# +# - name: Gradle cache +# uses: gradle/gradle-build-action@v2 +# +# # Execute unit tests +# - name: Unit Test with Android Emulator Runner +# uses: reactivecircus/android-emulator-runner@v2 +# with: +# api-level: 29 +# target: google_apis +# script: ./gradlew connectedCheck +# +# - name: generate report +# uses: actions/upload-artifact@v2 +# with: +# name: report +# path: app/build/reports/coverage/debug \ No newline at end of file diff --git a/app-shared-tests/build.gradle b/app-shared-tests/build.gradle index a6b226bed..04ad25a95 100644 --- a/app-shared-tests/build.gradle +++ b/app-shared-tests/build.gradle @@ -51,11 +51,11 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '17' } } diff --git a/app/build.gradle b/app/build.gradle index 73365c19c..9f9bf8fa6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,6 +4,7 @@ plugins { id 'org.jetbrains.kotlin.android' id 'com.google.dagger.hilt.android' id 'org.jlleitschuh.gradle.ktlint' version '11.2.0' + id 'jacoco' } android { @@ -37,14 +38,17 @@ android { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } + debug{ + enableUnitTestCoverage true + } } compileOptions { coreLibraryDesugaringEnabled true - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '17' } buildFeatures { compose true @@ -158,6 +162,20 @@ dependencies { ktlintRuleset project(":custom-ktlint-rules") } +tasks.register('codeCoverage',JacocoReport) { + dependsOn 'testDebugUnitTest' + + reports { + html.required.set(true) + xml.required.set(true) + } + + sourceDirectories.setFrom("${project.projectDir}/src/main/java") + classDirectories.setFrom("${project.buildDir}/tmp/kotlin-classes/debugUnitTest") + println("${project.buildDir}") + executionData.setFrom("${project.buildDir}/outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec") +} + tasks.withType(Test) { useJUnitPlatform() } diff --git a/components/build.gradle b/components/build.gradle index 566d39fb9..82446ec6c 100644 --- a/components/build.gradle +++ b/components/build.gradle @@ -16,11 +16,11 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '11' + jvmTarget = '17' } buildFeatures { compose true diff --git a/custom-ktlint-rules/build.gradle b/custom-ktlint-rules/build.gradle index c777e1ecc..13600b85c 100644 --- a/custom-ktlint-rules/build.gradle +++ b/custom-ktlint-rules/build.gradle @@ -4,8 +4,8 @@ plugins { } java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_11 } dependencies { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 62ad620e1..bb237014a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Feb 20 09:12:45 CET 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME