2rabs/nito-app

View on GitHub
.github/workflows/checks.yml

Summary

Maintainability
Test Coverage
name: "Checks"

on:
  pull_request:
    branches:
      - main

# Cancel any current or previous job from the same PR
concurrency:
  group: checks-${{ github.ref }}
  cancel-in-progress: true

jobs:
  changed:
    runs-on: ubuntu-22.04
    outputs:
      android: ${{ steps.changes.outputs.android }}
      ios: ${{ steps.changes.outputs.ios }}
      backend: ${{ steps.changes.outputs.backend }}
    steps:
      # https://github.com/marketplace/actions/checkout
      - name: Checkout
        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

      # https://github.com/marketplace/actions/paths-changes-filter
      - name: Paths Changes Filter
        uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
        id: changes
        with:
          filters: |
            android:
              - 'app/android/**/*'
              - 'app/shared/**/*'
              - 'build-logic/**/*'
              - 'core/**/*'
              - 'feature/**/*'
              - 'gradle/**/*'
              - 'build.gradle.kts'
              - 'gradle.properties'
              - 'settings.gradle.kts'
            ios:
              - 'app/ios/**/*'
              - 'app/ios-combined/**/*'
              - 'app/shared/**/*'
              - 'build-logic/**/*'
              - 'core/**/*'
              - 'feature/**/*'
              - 'gradle/**/*'
              - 'build.gradle.kts'
              - 'gradle.properties'
              - 'settings.gradle.kts'
            backend:
              - 'app/backend/**/*'
              - 'build-logic/**/*'
              - 'core/**/*'
              - 'gradle/**/*'
              - 'build.gradle.kts'
              - 'gradle.properties'
              - 'settings.gradle.kts'

  check-android:
    runs-on: ubuntu-22.04
    needs: changed
    if: needs.changed.outputs.android == 'true'
    steps:
      # https://github.com/marketplace/actions/checkout
      - name: Checkout
        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
        with:
          lfs: 'true'

      - name: Copy CI gradle.properties
        shell: bash
        run: |
          mkdir -p ~/.gradle
          cp .github/ci-gradle.properties ~/.gradle/gradle.properties

      # https://github.com/marketplace/actions/setup-java-jdk
      - name: Setup Java JDK
        uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2
        with:
          distribution: 'zulu'
          java-version: 17

      # https://github.com/marketplace/actions/build-with-gradle
      - name: Build with Gradle
        uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4.0.1

      - name: Unit Tests
        run: ./gradlew testDebugUnitTest

      - name: Build
        run: ./gradlew :app:android:assembleDevDebug

  check-ios:
    runs-on: macos-14
    needs: changed
    if: needs.changed.outputs.ios == 'true'
    strategy:
      matrix:
        destination: [ 'platform=iOS Simulator,OS=17.2,name=iPhone 15' ]
    steps:
      # https://github.com/marketplace/actions/checkout
      - name: Checkout
        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

      - name: Copy CI gradle.properties
        shell: bash
        run: |
          mkdir -p ~/.gradle
          cp .github/ci-gradle.properties ~/.gradle/gradle.properties

      # https://github.com/marketplace/actions/setup-java-jdk
      - name: Setup Java JDK
        uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2
        with:
          distribution: 'zulu'
          java-version: 17

      # https://github.com/marketplace/actions/build-with-gradle
      - name: Build with Gradle
        uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4.0.1

      # https://github.com/marketplace/actions/setup-xcode-version
      - name: Setup Xcode version
        uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
        with:
          xcode-version: '15.1.0'

      - name: Build iOS framework
        run: ./gradlew :app:ios-combined:assembleNitoKmpReleaseXCFramework

      - name: Run iOS unit tests
        continue-on-error: true
        run: xcodebuild clean build -project app/ios/App/Nito/Nito.xcodeproj -configuration Debug -scheme Dev -sdk iphoneos -destination "${destination}" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -test-timeouts-enabled YES
        env:
          destination: ${{ matrix.destination }}

  check-backend:
    runs-on: ubuntu-22.04
    needs: changed
    if: needs.changed.outputs.backend == 'true'
    steps:
      # https://github.com/marketplace/actions/checkout
      - name: Checkout
        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
        with:
          lfs: 'true'

      - name: Copy CI gradle.properties
        shell: bash
        run: |
          mkdir -p ~/.gradle
          cp .github/ci-gradle.properties ~/.gradle/gradle.properties

      # https://github.com/marketplace/actions/setup-java-jdk
      - name: Setup Java JDK
        uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2
        with:
          distribution: 'zulu'
          java-version: 17

      # https://github.com/marketplace/actions/build-with-gradle
      - name: Build with Gradle
        uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4.0.1

      - name: Unit Tests
        run: ./gradlew :app:backend:check

      - name: Build
        run: ./gradlew :app:backend:buildFatJar

  status-check:
    runs-on: ubuntu-22.04
    needs:
      - check-android
      - check-ios
      - check-backend
    permissions: { }
    if: failure()
    steps:
      - run: exit 1