Skip to content

Commit

Permalink
Merge pull request #1090 from skniyajali/add-codecov-integration
Browse files Browse the repository at this point in the history
feat: Update project version and add Codecov integration
  • Loading branch information
niyajali authored Sep 12, 2024
2 parents a987bfc + c82229a commit a0b7586
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 18 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/Build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,13 @@ jobs:
run: |
echo "::error::Release Badging failed, please update badging with: ./gradlew updateReleaseBadging" && exit 1
# Runs if previous job failed
- name: Generate new release badging if verification failed and it's a PR
id: generate_badging
if: steps.checkfork_badging.outcome == 'failure' && github.event_name == 'pull_request'
if: steps.badging_verify.outcome == 'failure' && github.event_name == 'pull_request'
run: |
./gradlew updateProdReleaseBadging
- name: Push new release badging if available
uses: stefanzweifel/git-auto-commit-action@v5
if: steps.generate_badging.outcome == 'success'
Expand Down Expand Up @@ -315,4 +313,12 @@ jobs:
if-no-files-found: error
compression-level: 1
overwrite: false
path: '**/build/reports/jacoco/'
path: '**/build/reports/jacoco/'

- name: Upload Test Report
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
verbose: true
files: ${{ github.workspace }}/**/build/reports/jacoco/**/*Report.xml
token: ${{ secrets.CODECOV_TOKEN }}
34 changes: 29 additions & 5 deletions .github/workflows/cache_cleanup.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
name: cleanup caches by a branch
name: Cache Cleanup
on:
pull_request:
types:
- closed
workflow_dispatch:

jobs:
cleanup:
cleanup_pr:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Cleanup
- name: Cleanup PR Cache
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
echo "Fetching list of cache keys"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
Expand All @@ -27,4 +28,27 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge

cleanup_all:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Cleanup All Caches
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of all cache keys"
allCacheKeys=$(gh actions-cache list -R $REPO | cut -f 1)
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting all caches..."
for cacheKey in $allCacheKeys
do
gh actions-cache delete $cacheKey -R $REPO --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
*/
import com.niyaj.samples.apps.popos.PoposBuildType
import com.niyaj.samples.apps.popos.cleanedVersion

plugins {
alias(libs.plugins.popos.android.application)
Expand All @@ -39,7 +40,7 @@ android {

defaultConfig {
applicationId = libs.versions.namespace.get()
versionName = project.version.toString()
versionName = project.cleanedVersion
versionCode = System.getenv("VERSION_CODE")?.toIntOrNull() ?: 1
testInstrumentationRunner = "com.niyaj.testing.PoposTestRunner"

Expand Down
2 changes: 1 addition & 1 deletion app/prodRelease-badging.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package: name='com.niyaj.poposroom' versionCode='1' versionName='1.0.0-alpha.5.473+20240909T204119Z' platformBuildVersionName='14' platformBuildVersionCode='34' compileSdkVersion='34' compileSdkVersionCodename='14'
package: name='com.niyaj.poposroom' versionCode='1' versionName='0.0.1-beta.0.1' platformBuildVersionName='14' platformBuildVersionCode='34' compileSdkVersion='34' compileSdkVersionCodename='14'
sdkVersion:'26'
targetSdkVersion:'34'
uses-permission: name='android.permission.FOREGROUND_SERVICE'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ inline fun Project.detektGradle(crossinline configure: DetektExtension.() -> Uni
inline fun Project.spotlessGradle(crossinline configure: SpotlessExtension.() -> Unit) =
extensions.configure<SpotlessExtension> {
configure()
}
}

val Project.cleanedVersion: String
get() = this.version.toString().split('+')[0]
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ tasks.register("printModulePaths") {

object DynamicVersion {
fun setDynamicVersion(file: File, version: String) {
file.writeText(version)
val cleanedVersion = version.split('+')[0]
file.writeText(cleanedVersion)
}
}

Expand Down
8 changes: 8 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"fixes": [
"/home/runner/work/PoposRoom/PoposRoom>/::"
],
"codecov": {
"disable_default_path_fixes": true
}
}
8 changes: 3 additions & 5 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import org.ajoberstar.reckon.core.Scope
import org.ajoberstar.reckon.gradle.ReckonExtension

/*
* Copyright 2024 Sk Niyaj Ali
*
Expand All @@ -17,6 +14,8 @@ import org.ajoberstar.reckon.gradle.ReckonExtension
* limitations under the License.
*/

import org.ajoberstar.reckon.gradle.ReckonExtension

pluginManagement {
includeBuild("build-logic")
repositories {
Expand All @@ -41,8 +40,7 @@ plugins {

extensions.configure<ReckonExtension> {
setDefaultInferredScope("patch")
stages("alpha","beta","final")
setScopeCalc { java.util.Optional.of(Scope.PATCH) }
stages("beta", "final")
setScopeCalc(calcScopeFromProp().or(calcScopeFromCommitMessages()))
setStageCalc(calcStageFromProp())
setTagWriter { it.toString() }
Expand Down

0 comments on commit a0b7586

Please sign in to comment.