Skip to content

Commit

Permalink
Merge branch 'develop' into pull_request_template
Browse files Browse the repository at this point in the history
# Conflicts:
#	.gitignore
  • Loading branch information
nowakweronika committed Sep 19, 2023
2 parents 5bbb999 + 8e616a9 commit 4b03493
Show file tree
Hide file tree
Showing 226 changed files with 11,765 additions and 310 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/snapshots/**/*.png filter=lfs diff=lfs merge=lfs -text
17 changes: 17 additions & 0 deletions .github/actions/prepare-android-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Prepare Environment to build Android app"
description: "Cancels previous runs, set ups jdk, validates gradle wrapper and uses gradle cache"
runs:
using: "composite"
steps:
- 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
14 changes: 14 additions & 0 deletions .github/actions/slack-notification/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Send notification to Slack"
description: "Sending notification to Slack on loudius-internal channel with workflow failure message. "
runs:
using: "composite"
steps:
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ env.SLACK_WEBHOOK }}
SLACK_CHANNEL: loudius-internal
SLACK_COLOR: "#C73E1D"
SLACK_MESSAGE: "Uh-oh! The code monkeys are having a party on *${{ env.SLACK_GIT_REF }}* 🐒🎉 But it seems like they broke something in the *'${{ env.SLACK_WORKFLOW}}' workflow!* Can someone please bring some bananas to fix it? 🍌🔧"
SLACK_TITLE: ⚠️ Workflow Failure Alert ⚠️
SLACK_USERNAME: Code Monkey Bot 🐵
9 changes: 9 additions & 0 deletions .github/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
android-pixel-2:
type: instrumentation
app: app/build/outputs/apk/debug/app-debug.apk
test: app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
device:
- model: Pixel2
version: 30
locale: "en"
orientation: portrait
107 changes: 107 additions & 0 deletions .github/workflows/run-code-quality-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +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 }}
110 changes: 110 additions & 0 deletions .github/workflows/run-snapshot-generation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +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 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 }}
107 changes: 107 additions & 0 deletions .github/workflows/run-snapshot-test.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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 }}
Loading

0 comments on commit 4b03493

Please sign in to comment.