From 74907ced705f28d5c2c733fb6419bf9e1f1992e8 Mon Sep 17 00:00:00 2001 From: Boris Safonov Date: Tue, 21 May 2024 17:12:08 +0300 Subject: [PATCH] Test 2 --- .github/workflows/build-app.yml | 46 +++++++ .github/workflows/check-kalium-commitish.yml | 59 +++++++++ .../cherry-pick-pr-to-newer-release-cycle.yml | 48 ++++++++ .github/workflows/codestyle.yml | 33 +++++ .github/workflows/crowdin-source-updater.yml | 59 +++++++++ .../crowdin-translations-updater.yml | 72 +++++++++++ .github/workflows/generate-changelog.yml | 59 +++++++++ .github/workflows/gradle-run-ui-tests.yml | 72 +++++++++++ .github/workflows/gradle-run-unit-tests.yml | 113 ++++++++++++++++++ .github/workflows/jira-lint-and-link.yml | 19 +++ .github/workflows/pr-author-assigner.yml | 12 ++ .github/workflows/publish-test-results.yml | 79 ++++++++++++ .github/workflows/semantic-commit-lint.yml | 63 ++++++++++ .github/workflows/stale-issues-and-pr.yml | 30 +++++ .github/workflows/testing-test-build-app.yml | 15 ++- 15 files changed, 771 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/build-app.yml create mode 100644 .github/workflows/check-kalium-commitish.yml create mode 100644 .github/workflows/cherry-pick-pr-to-newer-release-cycle.yml create mode 100644 .github/workflows/codestyle.yml create mode 100644 .github/workflows/crowdin-source-updater.yml create mode 100644 .github/workflows/crowdin-translations-updater.yml create mode 100644 .github/workflows/generate-changelog.yml create mode 100644 .github/workflows/gradle-run-ui-tests.yml create mode 100644 .github/workflows/gradle-run-unit-tests.yml create mode 100644 .github/workflows/jira-lint-and-link.yml create mode 100644 .github/workflows/pr-author-assigner.yml create mode 100644 .github/workflows/publish-test-results.yml create mode 100644 .github/workflows/semantic-commit-lint.yml create mode 100644 .github/workflows/stale-issues-and-pr.yml diff --git a/.github/workflows/build-app.yml b/.github/workflows/build-app.yml new file mode 100644 index 00000000000..1c35a9b47c2 --- /dev/null +++ b/.github/workflows/build-app.yml @@ -0,0 +1,46 @@ +name: "Build App" + +on: + workflow_call: + inputs: + flavour: + required: true + type: string + +jobs: + build-app: + runs-on: buildjet-8vcpu-ubuntu-2204 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive # Needed in order to fetch Kalium sources for building + fetch-depth: 0 + - name: Set up JDK 17 + uses: buildjet/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: gradle + - name: Build beta flavour + if: ${{ inputs.flavour == 'beta-debug' }} + env: + GITHUB_USER: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + ./gradlew assembleBetaDebug -p ./ --no-daemon + cp app/build/outputs/apk/beta/debug/com.wire.*.apk wire-android-${{inputs.flavour}}-pr-${{ github.event.pull_request.number }}.apk + - name: Build dev flavour + if: ${{ inputs.flavour == 'dev-debug' }} + env: + GITHUB_USER: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + ./gradlew assembleDevDebug -p ./ --no-daemon + cp app/build/outputs/apk/dev/debug/com.wire.*.apk wire-android-${{inputs.flavour}}-pr-${{ github.event.pull_request.number }}.apk + - name: Upload APK + if: success() + uses: actions/upload-artifact@v3 + with: + name: wire-android-${{inputs.flavour}}-pr-${{ github.event.pull_request.number }}.apk + path: ./wire-android-${{inputs.flavour}}-pr-${{ github.event.pull_request.number }}.apk diff --git a/.github/workflows/check-kalium-commitish.yml b/.github/workflows/check-kalium-commitish.yml new file mode 100644 index 00000000000..35b7da35ad8 --- /dev/null +++ b/.github/workflows/check-kalium-commitish.yml @@ -0,0 +1,59 @@ +name: "Validate Kalium References" + +on: + pull_request: + types: [ opened, synchronize ] # Don't rerun on `edited` to save time + paths: + - 'kalium' + +jobs: + validate-kalium-ref: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive # Needed in order to fetch Kalium sources for building + fetch-depth: 0 + + - name: Run git merge-base + id: validate_kalium + env: + GH_BASE_REF: ${{github.base_ref}} + continue-on-error: true + # git merge-base --is-ancestor A B returns 0 when A is ancestor of B + # In our case, if FROM is not an ancestor of TO, then it returns 1 + run: | + KALIUM_TO_REF="$(git rev-parse HEAD:kalium)" + git fetch + git checkout "$GH_BASE_REF" + git pull + git submodule update + KALIUM_FROM_REF="$(git rev-parse HEAD:kalium)" + echo "kalium_from=$KALIUM_FROM_REF" >> $GITHUB_OUTPUT + echo "kalium_to=$KALIUM_TO_REF" >> $GITHUB_OUTPUT + cd kalium + git merge-base --is-ancestor "$KALIUM_FROM_REF" "$KALIUM_TO_REF" || echo "is_kalium_rollback=$?" >> $GITHUB_OUTPUT + unset KALIUM_TO_REF + unset KALIUM_FROM_REF + + - name: Leave a comment + if: ${{ steps.validate_kalium.outputs.is_kalium_rollback == 1 }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_AUTHOR: ${{ github.event.pull_request.user.login }} + KALIUM_FROM: ${{ steps.validate_kalium.outputs.kalium_from }} + KALIUM_TO: ${{ steps.validate_kalium.outputs.kalium_to }} + GH_BASE_REF: ${{github.base_ref}} + GH_HEAD_REF: ${{github.head_ref}} + run: | + gh pr comment "$GH_HEAD_REF" --body "@$PR_AUTHOR looks like you are rolling back kalium to a previous commitish. + + This means that the PR's target branch ($GH_BASE_REF) is using a newer version of Kalium, and the changes in this PR will rollback Kalium to an older version. + + | $GH_BASE_REF | This PR | + | ------------ | ------- | + | [$KALIUM_FROM](https://github.com/wireapp/kalium/tree/$KALIUM_FROM) | [$KALIUM_TO](https://github.com/wireapp/kalium/tree/$KALIUM_TO) | + + Is this intentional?" diff --git a/.github/workflows/cherry-pick-pr-to-newer-release-cycle.yml b/.github/workflows/cherry-pick-pr-to-newer-release-cycle.yml new file mode 100644 index 00000000000..1d2759409b9 --- /dev/null +++ b/.github/workflows/cherry-pick-pr-to-newer-release-cycle.yml @@ -0,0 +1,48 @@ +# GitHub Action: Cherry-pick merged PRs to `TARGET_BRANCH` +# +# This action automates the process of cherry-picking merged PRs from `release/candidate` branch to `TARGET_BRANCH`. +# It is triggered whenever a pull request is merged into `release/candidate`. +# +# The action performs the following steps: +# 1. Checkout the merged PR. +# 2. If changes are made outside the specified submodule or no submodule is specified, the action proceeds. +# 3. If a submodule name is provided in the `SUBMODULE_NAME` environment variable: +# a. The action creates a temporary branch. +# b. Updates the submodule to its latest version from the target branch. +# c. Commits the submodule updates. +# 4. Squashes the commit with the commit message of the merged PR (if a submodule was updated). +# 5. Cherry-picks the squashed (or original if no squashing occurred) commit to a new branch based on target. +# 6. If any conflicts arise during the cherry-pick, they are committed. +# 7. The branch with the cherry-picked changes is pushed. +# 8. A new pull request is created against `develop` with the cherry-picked changes. + +name: "Cherry-pick from RC to develop" + +on: + pull_request: + branches: + - release/candidate + types: + - closed + +jobs: + cherry-pick: + runs-on: ubuntu-latest + if: github.event.pull_request.merged == true + + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Cherry pick to `develop` + uses: wireapp/action-auto-cherry-pick@v1.0.1 + with: + target-branch: develop + submodules-target-branch: develop + pr-title-suffix: 🍒 + pr-labels: cherry-pick diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml new file mode 100644 index 00000000000..a6189bc7c77 --- /dev/null +++ b/.github/workflows/codestyle.yml @@ -0,0 +1,33 @@ +name: "Check Codestyle" + +on: [workflow_call] + +permissions: + contents: read + +jobs: + static-code-analysis: + runs-on: buildjet-2vcpu-ubuntu-2204 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive # Needed in order to fetch Kalium sources for building + fetch-depth: 0 + - name: Set up JDK 17 + uses: buildjet/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: gradle + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@216d1ad2b3710bf005dc39237337b9673fd8fcd5 + - name: Run Detekt + run: | + ./gradlew detektAll + - name: Cleanup Gradle Cache + # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. + # Restoring these files from a GitHub Actions cache might cause problems for future builds. + run: | + rm -f ~/.gradle/caches/modules-2/modules-2.lock + rm -f ~/.gradle/caches/modules-2/gc.properties diff --git a/.github/workflows/crowdin-source-updater.yml b/.github/workflows/crowdin-source-updater.yml new file mode 100644 index 00000000000..23a6d78c7f7 --- /dev/null +++ b/.github/workflows/crowdin-source-updater.yml @@ -0,0 +1,59 @@ +name: "Crowdin Action - Base Source Updater" + +# **What it does**: Download new source from crowdin project. +# **Why we have it**: We want to be able to pull-update base (EN) translations to the project. +# **Who does it impact**: Everyone collaborating on the project, and the translators. +# For more info: https://github.com/crowdin/github-action/blob/master/action.yml + +on: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + synchronize-with-crowdin: + runs-on: ubuntu-latest + + env: + GITHUB_USER: "AndroidBob" + GITHUB_TOKEN: ${{ secrets.ANDROID_BOB_GH_TOKEN }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: "Exit if the branch is not default 'develop'" + run: | + if [[ "${{ github.ref }}" != "refs/heads/develop" ]]; then + echo "Branch is not develop, exiting." + exit 0 + fi + + - name: Crowdin action + uses: crowdin/github-action@v1 + with: + project_id: ${{ secrets.CROWDIN_PROJECT_ID }} + token: ${{ secrets.CROWDIN_API_TOKEN }} + + download_sources: true + push_sources: true + upload_sources: false + download_translations: true + upload_translations: false + + create_pull_request: true + localization_branch_name: chore/sync-and-update-localization-source + commit_message: "chore: update localization sources from Crowdin" + pull_request_title: "chore: update localization sources from Crowdin" + pull_request_body: "This PR pulls in the latest localization **source** from Crowdin." + github_user_name: "AndroidBob" + github_user_email: "AndroidBob@users.noreply.github.com" + + pull_request_labels: "l10n, crowdin" + pull_request_assignees: "AndroidBob" + pull_request_team_reviewers: "wireapp/android" + pull_request_base_branch_name: ${{env.BASE_BRANCH}} + + config: "crowdin.yml" diff --git a/.github/workflows/crowdin-translations-updater.yml b/.github/workflows/crowdin-translations-updater.yml new file mode 100644 index 00000000000..f1757267c19 --- /dev/null +++ b/.github/workflows/crowdin-translations-updater.yml @@ -0,0 +1,72 @@ +name: "Crowdin Action" + +# **What it does**: Upload strings to crowdin project for translations and creates a PR with updates. +# **Why we have it**: We want to externalize and automate the translations process. +# **Who does it impact**: Everyone collaborating on the project. +# For more info: https://github.com/crowdin/github-action/blob/master/action.yml + +on: + push: + branches: [ develop ] + + workflow_dispatch: + inputs: + baseBranch: + description: "Base branch to create the PR and update the localization strings" + required: true + default: "develop" + type: choice + options: + - "develop" + - "release/candidate" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + synchronize-with-crowdin: + runs-on: ubuntu-latest + + env: + GITHUB_USER: "AndroidBob" + GITHUB_TOKEN: ${{ secrets.ANDROID_BOB_GH_TOKEN }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: "Set base branch from input" + env: + INPUT_BASE_BRANCH: ${{github.event.inputs.baseBranch}} + if: "${{ github.event.inputs.baseBranch != '' }}" + run: echo "BASE_BRANCH=$INPUT_BASE_BRANCH" >> "$GITHUB_ENV" + + - name: "Set base branch to default branch" + if: "${{ github.event.inputs.baseBranch == '' }}" + run: echo "BASE_BRANCH=develop" >> "$GITHUB_ENV" + + - name: Crowdin action + uses: crowdin/github-action@v1 + with: + project_id: ${{ secrets.CROWDIN_PROJECT_ID }} + token: ${{ secrets.CROWDIN_API_TOKEN }} + + upload_sources: true + download_translations: true + upload_translations: false + + create_pull_request: true + localization_branch_name: chore/sync-and-update-localization-${{env.BASE_BRANCH}} + commit_message: "chore: update localization strings via Crowdin" + pull_request_title: "chore: update localization strings via Crowdin" + pull_request_body: "This PR pulls in the latest localization translations from Crowdin." + github_user_name: "AndroidBob" + github_user_email: "AndroidBob@users.noreply.github.com" + + pull_request_labels: "l10n, crowdin" + pull_request_assignees: "AndroidBob" + pull_request_team_reviewers: "wireapp/android" + pull_request_base_branch_name: ${{env.BASE_BRANCH}} + + config: "crowdin.yml" diff --git a/.github/workflows/generate-changelog.yml b/.github/workflows/generate-changelog.yml new file mode 100644 index 00000000000..39e37555ad1 --- /dev/null +++ b/.github/workflows/generate-changelog.yml @@ -0,0 +1,59 @@ +name: 'Generate Changelog' + +on: + workflow_dispatch: + inputs: + current-release-tag: + type: string + description: 'The tag of the current release starting with v' + required: false + default: '' + push: + tags: + - 'v*' + +jobs: + Changelog: + runs-on: ubuntu-latest + + steps: + - name: 'Checkout Git repository with history for all branches and tags' + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive # Needed in order to fetch Kalium sources for building + + - name: 'Set current Git tag from input' + env: + INPUT_RELEASE_TAG: ${{github.event.inputs.current-release-tag}} + if: "${{ github.event.inputs.current-release-tag != '' }}" + run: echo "CURRENT_TAG=$INPUT_RELEASE_TAG" >> "$GITHUB_ENV" + + - name: 'Set current Git tag from commit' + if: "${{ github.event.inputs.current-release-tag == '' }}" + run: echo "CURRENT_TAG=$(git tag --points-at ${{github.sha}} | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(\+|$)' | tail -n 1)" >> "$GITHUB_ENV" + + - name: 'Set previous Git tag from commit' + run: echo "PREVIOUS_TAG=$(git tag | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(\+|$)' | tail -n 2 | head -n 1)" >> "$GITHUB_ENV" + + - name: 'Print environment variables' + run: | + echo -e "PREVIOUS_TAG = $PREVIOUS_TAG" + echo -e "CURRENT_TAG = $CURRENT_TAG" + echo -e "Node.js version = $(node --version)" + + - name: 'Generate changelog' + run: | + echo "{}" > ./package.json + npx generate-changelog@1.8.0 -t "$PREVIOUS_TAG...$CURRENT_TAG" + + - name: 'Attach changelog to tag' + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{github.token}} + with: + tag_name: ${{env.CURRENT_TAG}} + name: ${{env.CURRENT_TAG}} + body_path: ./CHANGELOG.md + draft: false + prerelease: false diff --git a/.github/workflows/gradle-run-ui-tests.yml b/.github/workflows/gradle-run-ui-tests.yml new file mode 100644 index 00000000000..751e1f2b656 --- /dev/null +++ b/.github/workflows/gradle-run-ui-tests.yml @@ -0,0 +1,72 @@ +name: "Run UI Tests" + +on: + merge_group: + pull_request: + types: [ opened, synchronize ] # Don't rerun on `edited` to save time + workflow_call: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + ui-tests: + runs-on: buildjet-8vcpu-ubuntu-2204 + strategy: + matrix: + api-level: [29] + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive # Needed in order to fetch Kalium sources for building + fetch-depth: 0 + + - name: Set up JDK 17 + uses: buildjet/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: gradle + + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@216d1ad2b3710bf005dc39237337b9673fd8fcd5 + + - name: AVD cache + uses: buildjet/cache@v4 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-${{ matrix.api-level }} + + - name: create AVD and generate snapshot for caching + if: steps.avd-cache.outputs.cache-hit != 'true' + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + target: google_apis + force-avd-creation: false + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: true + script: echo "Generated AVD snapshot for caching." + + - name: Android Instrumentation Tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + target: google_apis + script: ./gradlew runAcceptanceTests + env: + GITHUB_USER: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Cleanup Gradle Cache + # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. + # Restoring these files from a GitHub Actions cache might cause problems for future builds. + run: | + rm -f ~/.gradle/caches/modules-2/modules-2.lock + rm -f ~/.gradle/caches/modules-2/gc.properties diff --git a/.github/workflows/gradle-run-unit-tests.yml b/.github/workflows/gradle-run-unit-tests.yml new file mode 100644 index 00000000000..621e3befdff --- /dev/null +++ b/.github/workflows/gradle-run-unit-tests.yml @@ -0,0 +1,113 @@ +name: "Run Unit Tests" + +on: + merge_group: + pull_request: + types: [ opened, synchronize ] # Don't rerun on `edited` to save time + workflow_call: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + detekt: + uses: ./.github/workflows/codestyle.yml + unit-tests: + needs: [detekt] + runs-on: buildjet-8vcpu-ubuntu-2204 + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive # Needed in order to fetch Kalium sources for building + fetch-depth: 0 + + - name: Set up JDK 17 + uses: buildjet/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: gradle + + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@216d1ad2b3710bf005dc39237337b9673fd8fcd5 + + - name: Test Build Logic + run: | + ./gradlew -p buildSrc test + ./gradlew -p build-logic :plugins:test + + - name: Test with coverage + run: ./gradlew testCoverage + env: + GITHUB_USER: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Install Pip for test result publishing + run: sudo apt-get install -y python3-pip + + # Uploads test results as GitHub artifacts, so publish-test-results can find them later. + - name: Upload Test Results + uses: actions/upload-artifact@v4 + if: always() + with: + # This name is referenced in the publish-test-results workflow. + name: test-results + path: | + **/build/test-results/testDevDebugUnitTest/**/*.xml + **/build/test-results/**/*.xml + **/build/outputs/androidTest-results/**/*.xml + + - name: Generate report + uses: actions/upload-artifact@v4 + with: + name: report + path: app/build/reports/kover + + - name: Download Test Reports Folder + uses: actions/download-artifact@v4 + with: + name: report + path: app/build/reports/kover + merge-multiple: true + + - name: Upload code coverage to codecov + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + files: "app/build/reports/kover/report.xml" + + - name: Cleanup Gradle Cache + # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. + # Restoring these files from a GitHub Actions cache might cause problems for future builds. + run: | + rm -f ~/.gradle/caches/modules-2/modules-2.lock + rm -f ~/.gradle/caches/modules-2/gc.properties + + build-beta: + if: ${{ github.event_name == 'pull_request' }} + needs: [unit-tests] + uses: ./.github/workflows/build-app.yml + with: + flavour: "beta-debug" + + build-dev: + if: ${{ github.event_name == 'pull_request' }} + needs: [unit-tests] + uses: ./.github/workflows/build-app.yml + with: + flavour: "dev-debug" + + event_file: + # This name is referenced in the publish-test-results workflow. + name: "Upload Event File" + runs-on: ubuntu-latest + steps: + - name: Upload + uses: actions/upload-artifact@v3 + with: + name: Event File + path: ${{ github.event_path }} diff --git a/.github/workflows/jira-lint-and-link.yml b/.github/workflows/jira-lint-and-link.yml new file mode 100644 index 00000000000..52febc8d8d3 --- /dev/null +++ b/.github/workflows/jira-lint-and-link.yml @@ -0,0 +1,19 @@ +name: Link and Lint PR with Jira Ticket Number +on: + merge_group: + pull_request: + types: [opened, edited, synchronize] +jobs: + add-jira-description: + runs-on: ubuntu-latest + # Run only if the PR is not from a Fork / external contributor + if: (!startsWith(github.ref, 'refs/heads/dependabot/') && github.repository_owner == 'wireapp') + steps: + - uses: cakeinpanic/jira-description-action@v0.7.0 + name: jira-description-action + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + jira-token: ${{ secrets.JIRA_TOKEN }} + jira-base-url: https://wearezeta.atlassian.net + skip-branches: '^(production-release|main|master|release\/v\d+)$' #optional + fail-when-jira-issue-not-found: false diff --git a/.github/workflows/pr-author-assigner.yml b/.github/workflows/pr-author-assigner.yml new file mode 100644 index 00000000000..32586d4988a --- /dev/null +++ b/.github/workflows/pr-author-assigner.yml @@ -0,0 +1,12 @@ +name: Auto assign author to PR +on: + pull_request_target: + types: [ opened ] + +jobs: + assign-author: + runs-on: ubuntu-latest + steps: + - uses: samspills/assign-pr-to-author@v1.0.2 + with: + repo-token: '${{ secrets.GITHUB_TOKEN }}' diff --git a/.github/workflows/publish-test-results.yml b/.github/workflows/publish-test-results.yml new file mode 100644 index 00000000000..53dc3ecdbad --- /dev/null +++ b/.github/workflows/publish-test-results.yml @@ -0,0 +1,79 @@ +name: Publish Test Results + +# Takes the artifacts uploaded by run-unit-tests and publishes them in PRs as a comment. +# This is needed in order to support PRs created from forks, as PRs from Forks or Dependabot +# run in read-only mode and can't comment on PRs, for example. +# More context here: https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ +# This work-around makes it so that: +# - this workflow is triggered by the end of the test workflow, instead +# of being triggered directly by the PR +# - we can control the permissions to only have what's needed to write comments, etc. + +on: + workflow_run: + workflows: [Run Unit Tests] + types: + - completed +permissions: {} + +jobs: + test-results: + name: Publish Test Results + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion != 'skipped' + + # Limit permissions to only what's needed + permissions: + checks: write + + # needed to write the PR comment with the results + pull-requests: write + # required in order to download step to access artifacts API + actions: read + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download and Extract Artifacts + uses: dawidd6/action-download-artifact@v3 + with: + run_id: ${{ github.event.workflow_run.id }} + path: artifacts + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + commit: ${{ github.event.workflow_run.head_sha }} + event_file: artifacts/Event File/event.json + event_name: ${{ github.event.workflow_run.event }} + files: "artifacts/test-results/**/*.xml" + + - uses: fregante/setup-git-user@v2 + + - name: Post link to apks + if: github.event.workflow_run.conclusion == 'success' + env: + EVENT_FILE_PATH: artifacts/Event File/event.json + GITHUB_USER: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Get the PR number based on the event file uploaded by the test workflow. + # The event file is a JSON containing the data of the event that triggered the tests. + # In this case, it will contain information about the PR. + run: | + CHECKS_LINK="https://github.com/wireapp/wire-android/actions/runs/${{ github.event.workflow_run.id }}" + PR_NUMBER=$(jq --raw-output .pull_request.number "$EVENT_FILE_PATH") + gh pr comment "$PR_NUMBER" --body "APKs built during tests are available [here]($CHECKS_LINK). Scroll down to **Artifacts**!" + + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Install datadog-ci + run: npm install -g @datadog/datadog-ci + - name: "Upload results" + env: + DATADOG_API_KEY: ${{ secrets.DD_API_KEY }} + DD_ENV: ci + DATADOG_SITE: datadoghq.eu + run: | + find ./artifacts -name "*.xml" -type f | tr '\n' ' ' | xargs -L 1 datadog-ci junit upload --service wire-android-reloaded . diff --git a/.github/workflows/semantic-commit-lint.yml b/.github/workflows/semantic-commit-lint.yml new file mode 100644 index 00000000000..be7e6b60b24 --- /dev/null +++ b/.github/workflows/semantic-commit-lint.yml @@ -0,0 +1,63 @@ +name: "Semantic Commit Linting of PR titles" + +on: + pull_request_target: + types: [ opened, edited, synchronize ] + +jobs: + semantic-commit-pr-title-lint: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CUSTOM_PR_LABEL: "Fix PR Title or Commit message️" + HEAD: ${{github.head_ref}} + steps: + # Please look up the latest version from + # https://github.com/amannn/action-semantic-pull-request/releases + - name: Run Semantic Commint Linter + uses: amannn/action-semantic-pull-request@v5.5.2 + with: + # Configure which types are allowed. + # Default: https://github.com/commitizen/conventional-commit-types + types: | + breaking + build + ci + chore + docs + feat + fix + other + perf + refactor + revert + style + test + # For work-in-progress PRs you can typically use draft pull requests + # from Github. However, private repositories on the free plan don't have + # this option and therefore this action allows you to opt-in to using the + # special "[WIP]" prefix to indicate this state. This will avoid the + # validation of the PR title and the pull request checks remain pending. + # Note that a second check will be reported if this is enabled. + wip: true + # When using "Squash and merge" on a PR with only one commit, GitHub + # will suggest using that commit message instead of the PR title for the + # merge commit, and it's easy to commit this by mistake. Enable this option + # to also validate the commit message for one commit PRs. + validateSingleCommit: true + + # Required in order to add/remove labels from the PR + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Add Failure Label + if: failure() + run: | + gh api repos/{owner}/{repo}/labels -f name="${CUSTOM_PR_LABEL}" -f color="FF0000" || true + gh pr edit "${HEAD}" --add-label "${CUSTOM_PR_LABEL}" + - name: Remove Failure Label + if: success() + run: | + gh pr edit "${HEAD}" --remove-label "${CUSTOM_PR_LABEL}" diff --git a/.github/workflows/stale-issues-and-pr.yml b/.github/workflows/stale-issues-and-pr.yml new file mode 100644 index 00000000000..ae7ef7893e9 --- /dev/null +++ b/.github/workflows/stale-issues-and-pr.yml @@ -0,0 +1,30 @@ +name: 'Close stale issues and PR' + +# **What it does**: Mark issues and pull requests after no updates for 30 days. After that only issues will be automatically closed after 7 days of inactivity. +# **Why we have it**: We want to manage our queue of issues and pull requests. +# **Who does it impact**: Everyone collaborating on the project. + +on: + schedule: + - cron: '10 0 * * *' + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v9 + with: + days-before-stale: 30 + days-before-close: 7 + + stale-pr-message: 'This PR is stale because it has been open 30 days with no activity. Please update it or close it in case is not relevant anymore.' + stale-pr-label: 'stale' + exempt-pr-labels: 'WIP' + exempt-draft-pr: true + days-before-pr-close: -1 # never close PRs + + stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.' + stale-issue-label: 'stale' + exempt-issue-labels: 'pinned, security' + close-issue-message: 'This issue was closed because it has been stalled for 7 days with no activity.' + days-before-issue-close: 7 diff --git a/.github/workflows/testing-test-build-app.yml b/.github/workflows/testing-test-build-app.yml index 5c1a45b78b6..96132338241 100644 --- a/.github/workflows/testing-test-build-app.yml +++ b/.github/workflows/testing-test-build-app.yml @@ -4,7 +4,6 @@ on: merge_group: pull_request: types: [ opened, synchronize, edited ] - workflow_call: jobs: testing-build-app: @@ -27,10 +26,10 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | ./gradlew assembleStagingCompat -p ./ --no-daemon -# uplod-to-s3: -# needs: [ testing-build-app ] -# name: "Upload APK staging compat" -# uses: ./.github/workflows/upload-aws-s3.yml -# with: -# flavour: "staging" -# buildType: "compat" + uplod-to-s3: + needs: [ testing-build-app ] + name: "Upload APK staging compat" + uses: ./.github/workflows/upload-aws-s3.yml + with: + flavour: "staging" + buildType: "compat"