Skip to content

Commit

Permalink
Merge branch 'main' into rehan/push-click-behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
mrehan27 committed Sep 26, 2023
2 parents 47e9512 + 8b9f02a commit 6138ed5
Show file tree
Hide file tree
Showing 45 changed files with 325 additions and 684 deletions.
20 changes: 20 additions & 0 deletions .github/actions/setup-android/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Setup Android
description: Setup CI with Android development tools to compile and test Android source code.

runs:
using: "composite"
steps:
- name: Install Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Install Android SDK
uses: android-actions/setup-android@v3

- name: Verify gradle scripts are valid gradle scripts
uses: gradle/wrapper-validation-action@v1

- name: Setup Gradle and cache dependencies between builds
uses: gradle/gradle-build-action@v2
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Dependabot helps update dependencies to keep them up-to-date.
# Configuration docs: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 1
reviewers:
- "customerio/mobile"
commit-message:
prefix: "chore"
include: "scope"
groups:
github-action-dependencies:
patterns:
- "*"
11 changes: 3 additions & 8 deletions .github/workflows/binary-validator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ jobs:
name: API check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-android
- name: API check
run: ./gradlew apiCheck

run: ./gradlew apiCheck
18 changes: 2 additions & 16 deletions .github/workflows/build-sample-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,13 @@ jobs:
runs-on: ubuntu-latest
name: Building app...${{ matrix.sample-app }}
steps:
- uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-android

# CLI to replace strings in files. The CLI recommends using `cargo install` which is slow. This Action is fast because it downloads pre-built binaries.
# If using sd on macos, "brew install" works great. for Linux, this is the recommended way.
- name: Install sd CLI to use later in the workflow
uses: kenji-miyake/setup-sd@v1

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Install tools from Gemfile (ruby language) used for building our apps with
uses: ruby/setup-ruby@v1
Expand All @@ -95,12 +87,6 @@ jobs:
touch "samples/local.properties"
echo "siteId=${{ secrets[matrix.cio-siteid-secret-key] }}" >> "samples/local.properties"
echo "apiKey=${{ secrets[matrix.cio-apikey-secret-key] }}" >> "samples/local.properties"
- name: Verify gradle scripts are not modified
uses: gradle/wrapper-validation-action@v1

- name: Setup Gradle and cache dependencies between builds
uses: gradle/gradle-build-action@v2
- name: Dump GitHub Action metadata because Fastlane uses it. Viewing it here helps debug JSON parsing code in Firebase.
run: cat $GITHUB_EVENT_PATH
Expand Down
31 changes: 13 additions & 18 deletions .github/workflows/deploy-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
new_release_published: ${{ steps.semantic-release.outputs.new_release_published }}
new_release_version: ${{ steps.semantic-release.outputs.new_release_version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# If using sd on macos, "brew install" works great. for Linux, this is the recommended way.
- name: Install sd CLI to use later in the workflow
uses: kenji-miyake/setup-sd@v1
Expand All @@ -33,24 +33,23 @@ jobs:
# 2. Updates metadata files. Such as updating the version number in package.json and adding entries to CHANGELOG.md file.
# 3. Create git tag and push it to github.
- name: Deploy git tag via semantic-release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v4
id: semantic-release
with:
dry_run: false
# version numbers below can be in many forms: M, M.m, M.m.p
semantic_version: 18
extra_plugins: |
conventional-changelog-conventionalcommits@4
@semantic-release/changelog@6
@semantic-release/git@10
@semantic-release/github@8
@semantic-release/exec@6
conventional-changelog-conventionalcommits
@semantic-release/changelog
@semantic-release/git
@semantic-release/github
@semantic-release/exec
env:
# Needs to push git commits to repo. Needs write access.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Notify team of git tag being created
uses: slackapi/slack-github-action@v1.18.0
uses: slackapi/slack-github-action@v1.24.0
if: steps.semantic-release.outputs.new_release_published == 'true' # only run if a git tag was made.
with:
# Use block kit for format of the JSON payloads: https://app.slack.com/block-kit-builder
Expand Down Expand Up @@ -87,7 +86,7 @@ jobs:
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

- name: Notify team of failure
uses: slackapi/slack-github-action@v1.18.0
uses: slackapi/slack-github-action@v1.24.0
if: ${{ failure() }} # only run this if any previous step failed
with:
# Use block kit for format of the JSON payloads: https://app.slack.com/block-kit-builder
Expand Down Expand Up @@ -129,12 +128,8 @@ jobs:
if: needs.deploy-git-tag.outputs.new_release_published == 'true' # only run if a git tag was made.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-android
- name: Push to Sonatype servers
run: MODULE_VERSION=${{ needs.deploy-git-tag.outputs.new_release_version }} ./scripts/deploy-code.sh
env:
Expand All @@ -146,7 +141,7 @@ jobs:
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}

- name: Notify team of successful deployment
uses: slackapi/slack-github-action@v1.18.0
uses: slackapi/slack-github-action@v1.24.0
if: ${{ success() }}
with:
# Use block kit for format of the JSON payloads: https://app.slack.com/block-kit-builder
Expand Down Expand Up @@ -183,7 +178,7 @@ jobs:
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

- name: Notify team of failure
uses: slackapi/slack-github-action@v1.18.0
uses: slackapi/slack-github-action@v1.24.0
if: ${{ failure() }} # only run this if any previous step failed
with:
# Use block kit for format of the JSON payloads: https://app.slack.com/block-kit-builder
Expand Down
22 changes: 6 additions & 16 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,25 @@ jobs:
module: [sdk, messagingpush, messaginginapp] # android modules
name: Android Lint (${{ matrix.module }})
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11' # Robolectric requires v9, but we choose LTS: https://adoptopenjdk.net/
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-android

- name: Run lint (${{ matrix.module }})
run: ./gradlew :${{ matrix.module }}:lintDebug

- name: Parse lint results (${{ matrix.module }})
uses: yutailang0119/action-android-lint@v1.0.2
uses: yutailang0119/action-android-lint@v3.1.0
with:
xml_path: ${{ matrix.module }}/build/reports/lint-results-debug.xml
report-path: ${{ matrix.module }}/build/reports/lint-results-debug.xml
if: ${{ always() }} # if running tests fails, we still want to parse the test results

# Task to verify ktlint already ran for all commits. This verifies you have your git hooks installed.
kotlin-lint:
runs-on: ubuntu-latest
name: Kotlin Lint
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11' # Robolectric requires v9, but we choose LTS: https://adoptopenjdk.net/
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-android

- name: Install and run ktlint
run: make lint-install && make lint-no-format
103 changes: 103 additions & 0 deletions .github/workflows/manual-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Manual Deploy to Maven Central
# Trigger this manual deployment in scenarios where:
# A git tag exists, but the initial deployment failed and fix has been pushed to main.
# This avoids the need to recreate the tag for redeployment.
on:
workflow_dispatch: # allows for manual triggering

jobs:
deploy-sonatype:
name: Deploy SDK to Maven Central
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0 # fetches all history for all tags and branches

- name: Get latest tag
id: get-latest-tag
run: |
echo '::group::Get latest tag'
TAG=$(git describe --tags --abbrev=0)
echo "TAG=$TAG" >> $GITHUB_ENV
echo '::endgroup::'
- uses: ./.github/actions/setup-android

- name: Push to Sonatype servers
run: MODULE_VERSION=${{ env.TAG }} ./scripts/deploy-code.sh
env:
OSSRH_USERNAME: ${{ secrets.GRADLE_PUBLISH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.GRADLE_PUBLISH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.GRADLE_SIGNING_KEYID }}
SIGNING_PASSWORD: ${{ secrets.GRADLE_SIGNING_PASSPHRASE }}
SIGNING_KEY: ${{ secrets.GRADLE_SIGNING_PRIVATE_KEY }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}

- name: Notify team of successful deployment
uses: slackapi/[email protected]
if: ${{ success() }}
with:
payload: |
{
"text": "Android SDK deployed to Maven Central",
"username": "Android deployment bot",
"icon_url": "https://media.pocketgamer.com/artwork/na-qulrguj/android.jpg",
"channel": "#mobile-deployments",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Android* SDK deployed to Maven Central! (manual deployment)"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Version:* ${{ env.TAG }}\n\nAndroid SDK deployment progress:\n~1. Git tag already created~\n~2. Manual deploy to maven central~\n\n"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFY_RELEASES_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
- name: Notify team of failure
uses: slackapi/[email protected]
if: ${{ failure() }}
with:
payload: |
{
"text": "Android SDK deployment failure",
"username": "Android deployment bot",
"icon_url": "https://media.pocketgamer.com/artwork/na-qulrguj/android.jpg",
"channel": "#mobile-deployments",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Android* SDK deployment :warning: failure :warning:"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Android SDK failed deployment during step *deploy to maven central*. View <https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|CI server logs> to learn why and fix the issue. <https://github.com/customerio/mobile/blob/main/GIT-WORKFLOW.md|Learn more about the deployment process and how to fix errors>."
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFY_RELEASES_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
15 changes: 5 additions & 10 deletions .github/workflows/pr-helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@ on:
pull_request:
types: [opened, reopened, edited, synchronize, labeled]

permissions:
pull-requests: write # Write access needed to create a comment.

jobs:
pr-help:
name: Semantic PR helper
lint-pr-title:
runs-on: ubuntu-latest
steps:
- name: Semantic PR helper
uses: levibostian/action-semantic-pr@v3
with:
readToken: ${{ secrets.GITHUB_TOKEN }}
permissions:
pull-requests: write # to comment on PRs
steps:
- uses: levibostian/action-conventional-pr-linter@v4
10 changes: 3 additions & 7 deletions .github/workflows/snapshot-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11
uses: actions/checkout@v4
- uses: ./.github/actions/setup-android

# Using branch name for name of snapshot. Makes it easy to remember and can easily trigger new builds of Remote Habits.
- name: Set snapshot version
Expand Down Expand Up @@ -45,7 +41,7 @@ jobs:
body-includes: Build available to test

- name: Inform pull request on build of SDK available to test
uses: peter-evans/create-or-update-comment@v2
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.find-previous-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand Down
Loading

0 comments on commit 6138ed5

Please sign in to comment.