Skip to content

Commit

Permalink
workflow test
Browse files Browse the repository at this point in the history
  • Loading branch information
itsPronay committed Dec 11, 2024
1 parent 4f27b01 commit 1524edc
Show file tree
Hide file tree
Showing 6 changed files with 440 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

# Upload APK
- name: Upload APK
uses: actions/upload-artifact@v2.2.0
uses: actions/upload-artifact@v4
with:
# Artifact name
name: android-client-app
Expand Down
182 changes: 182 additions & 0 deletions .github/workflows/master_dev_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
name: Workflow for master/development branches

on:
pull_request:
push:
branches:
- 'development'
- 'master'

concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
pull-requests: write

jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- uses: gradle/actions/setup-gradle@v4

- name: Cache Gradle and build outputs
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
build
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-

checks:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
check: [ build_logic, spotless, detekt ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Run ${{ matrix.check }}
id: run_check
run: |
if [ "${{ matrix.check }}" = "build_logic" ]; then
./gradlew check -p build-logic
elif [ "${{ matrix.check }}" = "spotless" ]; then
./gradlew spotlessCheck --no-configuration-cache --no-daemon
elif [ "${{ matrix.check }}" = "detekt" ]; then
./gradlew detekt
fi
- name: Upload Detekt Reports
if: ${{ matrix.check == 'detekt' && steps.run_check.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: detekt-reports
path: |
**/build/reports/detekt/detekt.md
dependency_guard:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- name: Check Dependency Guard
id: dependencyguard_verify
continue-on-error: true
run: ./gradlew dependencyGuard

- name: Prevent updating Dependency Guard baselines if this is a fork
id: checkfork_dependencyguard
if: steps.dependencyguard_verify.outcome == 'failure' && github.event.pull_request.head.repo.full_name != github.repository
run: |
echo "::error::Dependency Guard failed, please update baselines with: ./gradlew dependencyGuardBaseline" && exit 1
# Runs if previous job failed
- name: Generate new Dependency Guard baselines if verification failed and it's a PR
id: dependencyguard_baseline
if: steps.dependencyguard_verify.outcome == 'failure' && github.event_name == 'pull_request'
run: |
./gradlew dependencyGuardBaseline
- name: Push new Dependency Guard baselines if available
uses: stefanzweifel/git-auto-commit-action@v5
if: steps.dependencyguard_baseline.outcome == 'success'
with:
file_pattern: '**/dependencies/*.txt'
disable_globbing: true
commit_message: "🤖 Updates baselines for Dependency Guard"

tests_and_lint:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- name: Run tests
run: |
./gradlew testDebug :lint:test :androidApp:lintRelease :lint:lint
- name: Upload reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-and-lint-reports
path: |
**/build/reports/lint-results-*.html
**/build/test-results/test*UnitTest/**.xml
# Add `createDebugUnitTestCoverageReport` if we ever add JVM tests for prod
- name: Generate coverage reports for Debug variants (only API 30)
run: ./gradlew createDebugCombinedCoverageReport

- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.api-level }}
path: '**/build/reports/androidTests'

- name: Display local test coverage (only API 30)
id: jacoco
uses: madrapps/[email protected]
with:
title: Combined test coverage report
min-coverage-overall: 40
min-coverage-changed-files: 60
paths: |
${{ github.workspace }}/**/build/reports/jacoco/**/*Report.xml
token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload local coverage reports (XML + HTML) (only API 30)
uses: actions/upload-artifact@v4
with:
name: coverage-reports
if-no-files-found: error
compression-level: 1
overwrite: false
path: '**/build/reports/jacoco/'

build:
needs: [ checks, dependency_guard, tests_and_lint ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- name: Build APKs
run: ./gradlew :androidApp:assembleDebug

- name: Upload APKs
uses: actions/upload-artifact@v4
with:
name: APKs
path: '**/build/outputs/apk/**/*.apk'
21 changes: 21 additions & 0 deletions .github/workflows/monthy_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Bump our Calendar Version

on:
workflow_dispatch:
schedule:
- cron: '30 3 1 * *'
jobs:
tag:
name: Tag Monthly Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get Current Time
uses: josStorer/[email protected]
id: current-time

- name: Bump Calendar Version
uses: rickstaa/[email protected]
with:
tag: ${{ steps.current-time.outputs.year }}.${{ steps.current-time.outputs.month }}.0
162 changes: 162 additions & 0 deletions .github/workflows/release_to_internal_or_beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
name: Internal Or Beta Release

on:
workflow_dispatch:
inputs:
release_type:
required: false
default: 'internal'
description: Please select the release type
type: choice
options:
- internal
- beta

env:
SUPPLY_UPLOAD_MAX_RETRIES: 5

jobs:
app_build:
name: Github Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: '17'

- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- uses: ./.github/actions/create-release-number
name: Create Release Number
id: rel_number

- uses: ./.github/actions/inflate-secrets
name: Inflate Secrets
with:
keystore: ${{ secrets.ORIGINAL_KEYSTORE_FILE }}
google-services: ${{ secrets.GOOGLESERVICES }}
playstore-creds: ${{ secrets.PLAYSTORECREDS }}

- uses: ./.github/actions/create-release-notes
name: Create Release Notes
with:
tag-name: ${{ steps.rel_number.outputs.version }}
gh-token: ${{ secrets.GITHUB_TOKEN }}

- name: Build Release
env:
KEYSTORE_PATH: ${{ secrets.KEYSTORE_NAME }}
KEYSTORE_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }}
KEYSTORE_ALIAS: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }}
KEYSTORE_ALIAS_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }}
VERSION_CODE: ${{ steps.rel_number.outputs.version-code }}
run: |
./gradlew :androidApp:assembleRelease
- name: Archive Build
uses: actions/upload-artifact@v4
with:
path: ./**/*.apk

- name: Create Version File
if: github.event.inputs.release_type == 'beta'
shell: bash
env:
VERSION_CODE: ${{ steps.rel_number.outputs.version-code }}
run: |
echo $VERSION_CODE > ./androidApp/build/outputs/version_code.txt
- name: Create Github Pre-Release
if: github.event.inputs.release_type == 'beta'
uses: softprops/[email protected]
with:
tag_name: ${{ steps.rel_number.outputs.version }}
body_path: ./androidApp/build/outputs/changelogGithub
draft: false
prerelease: true
files: |
./androidApp/build/outputs/apk/release/androidApp-release.apk
./androidApp/build/outputs/version_code.txt
- name: Print `git status`
run: git status

play_publish:
name: Play Publish
runs-on: ubuntu-latest
concurrency:
group: playstore_deploy
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: '17'

- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true

- name: Install Fastlane
run: |
gem install bundler:2.2.27
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- uses: ./.github/actions/create-release-number
name: Create Release Number
id: rel_number

- uses: ./.github/actions/inflate-secrets
name: Inflate Secrets
with:
keystore: ${{ secrets.UPLOAD_KEYSTORE_FILE }}
google-services: ${{ secrets.GOOGLESERVICES }}
playstore-creds: ${{ secrets.PLAYSTORECREDS }}

- uses: ./.github/actions/create-release-notes
name: Create Release Notes
with:
tag-name: ${{ steps.rel_number.outputs.version }}
gh-token: ${{ secrets.GITHUB_TOKEN }}

- name: Build Release
env:
KEYSTORE_PATH: ${{ secrets.KEYSTORE_NAME }}
KEYSTORE_PASSWORD: ${{ secrets.UPLOAD_KEYSTORE_FILE_PASSWORD }}
KEYSTORE_ALIAS: ${{ secrets.UPLOAD_KEYSTORE_ALIAS }}
KEYSTORE_ALIAS_PASSWORD: ${{ secrets.UPLOAD_KEYSTORE_ALIAS_PASSWORD }}
VERSION_CODE: ${{ steps.rel_number.outputs.version-code }}
run: |
./gradlew :androidApp:bundleRelease
- name: Deploy to Play Store Internal
run: bundle exec fastlane android deploy_internal

- name: Promote Internal to Beta
if: github.event.inputs.release_type == 'beta'
run: bundle exec fastlane android promote_to_beta
Loading

0 comments on commit 1524edc

Please sign in to comment.