Skip to content

Commit

Permalink
Updating workflows. (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamMc331 authored Nov 16, 2024
1 parent db0cce0 commit 57a50aa
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 88 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Android Build

# This will cancel any in progress workflows for the same PR, if
# multiple pushes happen in quick succession.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on: pull_request

jobs:
android-build:
runs-on: macos-14
steps:
- uses: actions/checkout@v4

- name: Set Up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v3
with:
# Only write to the cache for builds on the 'development' branch
cache-read-only: ${{ github.ref != 'refs/heads/development' }}

- name: Generate local.properties
env:
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }}
run: echo $LOCAL_PROPERTIES > ./local.properties

# assembleDebug is used to improve build times by only building
# the debug Android artifacts. https://touchlab.co/touchlab-build-only-what-you-need
- name: Build Project
run: ./gradlew assembleDebug
39 changes: 0 additions & 39 deletions .github/workflows/compile.yml

This file was deleted.

23 changes: 13 additions & 10 deletions .github/workflows/danger_checks.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: Danger Checks

# This will cancel any in progress workflows for the same PR, if
# multiple pushes happen in quick succession.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on: pull_request

jobs:
Expand All @@ -15,21 +21,18 @@ jobs:
distribution: 'zulu'
java-version: 17

- name: Set Up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
- name: Setup Gradle
uses: gradle/gradle-build-action@v3

- name: Generate local.properties
env:
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }}
run: echo $LOCAL_PROPERTIES > ./local.properties

- name: Danger Checks
run: |
gem install bundler
bundle install
bundle exec danger
- name: Dependency Updates
run: ./gradlew dependencyUpdates

- name: Danger Checks
uses: danger/kotlin@1.3.1
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/ios_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: iOS Build

# This will cancel any in progress workflows for the same PR, if
# multiple pushes happen in quick succession.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on: pull_request

jobs:
ios-build:
runs-on: macos-14
steps:
- uses: actions/checkout@v4

- name: Set Up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- name: Generate local.properties
env:
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }}
run: echo $LOCAL_PROPERTIES > ./local.properties

- name: Run tests
run: ./gradlew :shared:iosX64Test

- name: Build
uses: sersoft-gmbh/xcodebuild-action@v3
with:
project: iosApp/templateIOS.xcodeproj
scheme: templateIOS
destination: name=iPhone 8
sdk: iphoneos
configuration: Debug
action: build
use-xcpretty: false
build-settings: CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO
19 changes: 12 additions & 7 deletions .github/workflows/lint_checks.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
name: Lint Checks

on:
push:
branches:
- development
pull_request:
# This will cancel any in progress workflows for the same PR, if
# multiple pushes happen in quick succession.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on: pull_request

jobs:
lint-checks:
runs-on: ubuntu-latest
runs-on: macos-14
steps:
- uses: actions/checkout@v4

Expand All @@ -30,4 +32,7 @@ jobs:
run: echo $LOCAL_PROPERTIES > ./local.properties

- name: Lint Checks
run: ./gradlew detektAll lintKotlin android:app:lint
run: ./gradlew detektAll lintKotlin lint

# - name: Dependency Sort Checks
# run: ./gradlew checkSortDependencies
14 changes: 8 additions & 6 deletions .github/workflows/paparazzi_tests.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
name: Paparazzi Tests

on:
push:
branches:
- development
pull_request:
# This will cancel any in progress workflows for the same PR, if
# multiple pushes happen in quick succession.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on: pull_request

jobs:
paparazzi-tests:
runs-on: ubuntu-latest
runs-on: macos-14
steps:
- uses: actions/checkout@v4

Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
name: Unit Tests

on:
push:
branches:
- development
pull_request:
# This will cancel any in progress workflows for the same PR, if
# multiple pushes happen in quick succession.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on: pull_request

jobs:
unit-tests:
runs-on: ubuntu-latest
runs-on: macos-14
steps:
- uses: actions/checkout@v4

Expand All @@ -29,7 +31,5 @@ jobs:
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }}
run: echo $LOCAL_PROPERTIES > ./local.properties

- name: Build Project
run: |
./gradlew allTests
./gradlew android:app:test
- name: Run Tests
run: ./gradlew test
11 changes: 0 additions & 11 deletions Dangerfile

This file was deleted.

43 changes: 43 additions & 0 deletions Dangerfile.df.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
@file:Suppress("MagicNumber", "WildcardImport", "ForbiddenComment")

// Editing this file: https://github.com/danger/kotlin?tab=readme-ov-file#autocomplete-and-syntax-highlighting-in-intellij-idea-or-android-studio
import systems.danger.kotlin.*
import java.io.File

danger(args) {

onGitHub {
val additions = pullRequest.additions ?: 0
val deletions = pullRequest.deletions ?: 0

message("Thanks @${pullRequest.user.login}!")

if (pullRequest.body.isNullOrBlank()) {
fail("Please provide a summary in the Pull Request description.")
}

if (additions > 500) {
warn("Please consider breaking up this pull request.")
}

if (issue.labels.isEmpty()) {
warn("Please add labels to this PR.")
}

if (deletions > additions) {
message("🎉 Code Cleanup!")
}

val updatesFile = File("build/dependencyUpdates/report.txt")
val lines = updatesFile.readLines()

val headerIndex = lines.indexOfFirst { line ->
line.contains("The following dependencies have later milestone versions:")
}

if (headerIndex >= 0) {
val message = lines.subList(headerIndex, lines.size).joinToString("\n")
message(message)
}
}
}
5 changes: 0 additions & 5 deletions Gemfile

This file was deleted.

2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ buildscript {
}

apply(from = "buildscripts/githooks.gradle")
apply(from = "buildscripts/versionsplugin.gradle")

allprojects {
repositories {
Expand Down Expand Up @@ -97,6 +98,7 @@ afterEvaluate {
plugins {
id("io.gitlab.arturbosch.detekt").version(libs.versions.detektGradlePlugin.get())
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.benmanes.versions).apply(false)
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.kotlinAndroid) apply false
alias(libs.plugins.kotlin.compose) apply false
Expand Down
15 changes: 15 additions & 0 deletions buildscripts/versionsplugin.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apply plugin: "com.github.ben-manes.versions"

def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}

tasks.named("dependencyUpdates").configure {
rejectVersionIf {
isNonStable(it.candidate.version)
}

gradleReleaseChannel = "current"
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ composeCompiler = "1.5.0"
detektGradlePlugin = "1.23.6"
espresso = "3.6.1"
glance = "1.1.0"
gradleVersionsPlugin = "0.51.0"
jsoup = "1.18.1"
junit = "4.13.2"
kmpCompose = "1.6.11"
Expand Down Expand Up @@ -127,6 +128,7 @@ ktor-client = [

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
benmanes-versions = { id = "com.github.ben-manes.versions", version.ref = "gradleVersionsPlugin" }
cash-paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
Expand Down

0 comments on commit 57a50aa

Please sign in to comment.