Skip to content

Daily Cron

Daily Cron #592

Workflow file for this run

name: "Daily Cron"
on:
# Run daily at midnight
schedule:
- cron: "0 0 * * *"
# Allow workflow to be manually run from the GitHub UI
workflow_dispatch:
# Allow workflow to be called from other files
workflow_call:
inputs:
dryRun:
description: "Do a dry run to preview instead of a real release [true/false]"
required: false
default: "true"
type: string
branch_name:
description: "branch name to run tests on"
required: false
default: "development"
type: string
jobs:
confirm-public-repo:
name: "Confirm android daily cron is run from public origin repo"
runs-on: ubuntu-latest
steps:
- name: "Cancel workflow"
if: ${{ github.repository != 'mParticle/mparticle-android-sdk' }}
uses: andymckay/cancel-action@0.2
create-regression-branch:
name: "Create Regression Branch"
runs-on: ubuntu-latest
needs: confirm-public-repo
env:
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
GIT_AUTHOR_NAME: mparticle-automation
GIT_AUTHOR_EMAIL: developers@mparticle.com
GIT_COMMITTER_NAME: mparticle-automation
GIT_COMMITTER_EMAIL: developers@mparticle.com
steps:
- name: "Clone branch"
uses: actions/checkout@v3
with:
repository: mparticle/mparticle-android-sdk
ref: ${{ inputs.branch_name }}
submodules: recursive
- name: "Import GPG Key"
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: "Create and push release branch"
run: |
git checkout -b regression/${{ github.run_number }}
git push origin regression/${{ github.run_number }}
- name: "Commit Kit Updates"
run: |
git submodule foreach "git fetch; git reset --hard origin/main";
git add .
git diff-index --quiet HEAD || git commit -m 'chore: Update Submodules'
- name: "Push kit updates to release branch"
run: git push origin regression/${{ github.run_number }}
instrumented-tests:
name: "Instrumented Tests"
timeout-minutes: 30
runs-on: macos-latest
needs: create-regression-branch
steps:
- name: "Checkout future release branch"
uses: actions/checkout@v3
with:
repository: mparticle/mparticle-android-sdk
ref: regression/${{ github.run_number }}
- name: "Install JDK 11"
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"
cache: "gradle"
- name: "Run Instrumented Tests"
uses: reactivecircus/android-emulator-runner@v2.26.0
with:
api-level: 29
script: ./gradlew :android-core:cAT :android-kit-base:cAT --stacktrace
- name: "Archive Instrumented Test Results"
uses: actions/upload-artifact@v3
if: always()
with:
name: instrumented-test-results
path: android-core/build/reports/androidTests/connected/**
instrumented-orchestrator-tests:
name: "Instrumented Orchestrator Tests"
timeout-minutes: 30
runs-on: macos-latest
needs: create-regression-branch
steps:
- name: "Checkout Branch"
uses: actions/checkout@v3
with:
repository: mparticle/mparticle-android-sdk
ref: regression/${{ github.run_number }}
- name: "Install JDK 11"
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"
cache: "gradle"
- name: "Run Instrumented Orchestrator Tests"
uses: reactivecircus/android-emulator-runner@v2.26.0
with:
api-level: 29
script: ./gradlew -Porchestrator=true :android-core:cAT --stacktrace
- name: "Archive Instrumented Orchestrator Tests Results"
uses: actions/upload-artifact@v3
if: always()
with:
name: "instrumented-orchestrator-tests-results"
path: android-core/build/orchestrator/**
unit-tests:
name: "Unit Tests"
timeout-minutes: 15
runs-on: ubuntu-latest
needs: create-regression-branch
steps:
- name: "Checkout future release branch"
uses: actions/checkout@v3
with:
repository: mparticle/mparticle-android-sdk
ref: regression/${{ github.run_number }}
- name: "Install JDK 11"
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"
cache: "gradle"
- name: "Run Unit Tests"
run: ./gradlew test
- name: "Print Android Unit Tests Report"
uses: asadmansr/android-test-report-action@v1.2.0
if: always()
- name: "Archive Unit Test Results"
uses: actions/upload-artifact@v3
if: always()
with:
name: "unit-tests-results"
path: ./**/build/reports/**
lint-checks:
name: "Lint Checks"
timeout-minutes: 15
runs-on: macos-latest
needs: create-regression-branch
steps:
- name: "Checkout Branch"
uses: actions/checkout@v3
with:
ref: regression/${{ github.run_number }}
submodules: recursive
- name: "Install JDK 11"
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"
cache: "gradle"
- name: "Run Android Core SDK Lint"
run: ./gradlew lint
- name: "Setup Android Kit Lint"
run: ./gradlew publishReleaseLocal
- name: "Run Android Kit Lint"
run: ./gradlew publishReleaseLocal -c settings-kits.gradle lint
- name: "Archive Test Results"
uses: actions/upload-artifact@v3
if: always()
with:
name: "core-lint-results"
path: ./**/build/reports/**
- name: "Archive Test Kit Results"
uses: actions/upload-artifact@v3
if: always()
with:
name: "kit-lint-results"
path: kits/**/build/reports/**
kotlin-lint-checks:
name: "Kotlin Lint Checks"
timeout-minutes: 15
runs-on: macos-latest
needs: create-regression-branch
steps:
- name: "Checkout Branch"
uses: actions/checkout@v3
with:
ref: regression/${{ github.run_number }}
submodules: recursive
- name: "Install JDK 11"
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"
cache: "gradle"
- name: "Run Android Core SDK Kotlin Lint"
run: ./gradlew ktlintCheck
- name: "Setup Android Kit Kotlin Lint"
run: ./gradlew publishReleaseLocal
- name: "Run Android Kit Kotlin Lint"
run: ./gradlew publishReleaseLocal -c settings-kits.gradle ktlintCheck
- name: "Archive Test Results"
uses: actions/upload-artifact@v3
if: always()
with:
name: "core-ktlint-results"
path: ./**/build/reports/**
- name: "Archive Test Kit Results"
uses: actions/upload-artifact@v3
if: always()
with:
name: "kit-ktlint-results"
path: kits/**/build/reports/**
update-kits:
name: "Update Kits"
needs: create-regression-branch
runs-on: macos-latest
env:
GIT_AUTHOR_NAME: mparticle-automation
GIT_AUTHOR_EMAIL: developers@mparticle.com
GIT_COMMITTER_NAME: mparticle-automation
GIT_COMMITTER_EMAIL: developers@mparticle.com
steps:
- name: "Checkout future release branch"
uses: actions/checkout@v3
with:
repository: mparticle/mparticle-android-sdk
ref: regression/${{ github.run_number }}
submodules: recursive
- name: "Install JDK 11"
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"
cache: "gradle"
- name: "Build Android Core"
run: ./gradlew -PisRelease=true clean publishReleaseLocal
- name: "Test Kits"
run: ./gradlew -PisRelease=true clean testRelease publishReleaseLocal -c settings-kits.gradle
semantic-release-dryrun:
name: "Test Semantic Release - Dry Run"
needs: [instrumented-tests, instrumented-orchestrator-tests, unit-tests, lint-checks, kotlin-lint-checks, update-kits]
runs-on: macos-latest
env:
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
GIT_AUTHOR_NAME: mparticle-automation
GIT_AUTHOR_EMAIL: developers@mparticle.com
GIT_COMMITTER_NAME: mparticle-automation
GIT_COMMITTER_EMAIL: developers@mparticle.com
steps:
- name: "Checkout public main branch"
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- name: "Merge future release branch into main branch"
run: |
git pull origin regression/${{ github.run_number }}
- name: "Semantic Release --dry-run"
if: ${{ inputs.dryRun }} == 'true'
run: |
npx \
-p lodash \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @semantic-release/exec@5 \
-p conventional-changelog-conventionalcommits \
semantic-release --dry-run
delete-regression-branch:
name: "Delete regression branch"
needs: semantic-release-dryrun
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
GIT_AUTHOR_NAME: mparticle-automation
GIT_AUTHOR_EMAIL: developers@mparticle.com
GIT_COMMITTER_NAME: mparticle-automation
GIT_COMMITTER_EMAIL: developers@mparticle.com
steps:
- name: "Checkout repo"
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: ${{ github.repository }}
ref: ${{ inputs.branch_name }}
- name: "Delete release branch"
if: always()
run: |
git fetch origin regression/${{ github.run_number }}
git push --delete origin regression/${{ github.run_number }}