Skip to content

Commit

Permalink
github actions test
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-f committed Nov 8, 2023
1 parent 9796a8f commit 5a80fbb
Show file tree
Hide file tree
Showing 5 changed files with 264 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/actions/ios-set-up/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: iOS set up
description: Sets up Kotlin Native and Cocoapods
runs:
using: "composite"
steps:
- shell: bash
run: ./gradlew :shared:generateDummyFramework

- name: Set up cocoapods
uses: maxim-lobanov/setup-cocoapods@v1
with:
version: latest

- shell: bash
name: Install Dependencies
run: |
cd iosApp
pod install --verbose
12 changes: 12 additions & 0 deletions .github/actions/job-set-up/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Job set up
description: Sets up the Java and Gradle
runs:
using: "composite"
steps:
- uses: actions/setup-java@v3
with:
distribution: "adopt"
java-version: "11"

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
57 changes: 57 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build

on:
workflow_call:
inputs:
shouldRunKmp:
required: true
type: string
shouldRunAndroid:
required: true
type: string
shouldRunIos:
required: true
type: string
shouldRunDesktop:
required: true
type: string

jobs:
Android:
if: ${{ inputs.shouldRunKmp == 'true' || inputs.shouldRunAndroid == 'true' }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Job set up
uses: ./.github/actions/job-set-up

- run: ./gradlew :androidApp:assemble

Desktop:
if: ${{ inputs.shouldRunKmp == 'true' || inputs.shouldRunDesktop == 'true' }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Job set up
uses: ./.github/actions/job-set-up

- run: ./gradlew :desktopApp:assemble

iOS:
if: ${{ inputs.shouldRunKmp == 'true' || inputs.shouldRunIos == 'true' }}
runs-on: macos-12

steps:
- uses: actions/checkout@v3

- name: Job set up
uses: ./.github/actions/job-set-up

- name: iOS set up
uses: ./.github/actions/ios-set-up

- run: xcodebuild build -workspace iosApp/iosApp.xcworkspace -configuration Debug -scheme iosApp -sdk iphoneos -destination name='iPhone 14' -verbose
77 changes: 77 additions & 0 deletions .github/workflows/code_review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Code review

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
types: [opened, ready_for_review, synchronize]
branches:
- main

jobs:
SetUp:
runs-on: ubuntu-latest
steps:
- id: setVariables
name: Set variables
run: |
isFromMain=${{ github.ref == 'refs/heads/main' }}
isManual=${{ github.event_name == 'workflow_dispatch' }}
hasKmpLabel=${{ contains(github.event.pull_request.labels.*.name, 'KMP') }}
shouldRunKmp=false
if $isFromMain || $isManual || $hasKmpLabel ; then
shouldRunKmp=true
fi
echo "shouldRunKmp=$shouldRunKmp" >> "$GITHUB_OUTPUT"
echo "shouldRunAndroid=${{ contains(github.event.pull_request.labels.*.name, 'Android') }}" >> "$GITHUB_OUTPUT"
echo "shouldRunIos=${{ contains(github.event.pull_request.labels.*.name, 'iOS') }}" >> "$GITHUB_OUTPUT"
echo "shouldRunDesktop=${{ contains(github.event.pull_request.labels.*.name, 'Desktop') }}" >> "$GITHUB_OUTPUT"
if [ ${{ github.event_name }} == workflow_dispatch ] || [ ${{ github.event_name }} == push ] || ([ ${{ github.event_name }} == pull_request ] && [ ${{ github.event.pull_request.draft }} == false ]); then
exit 0
else
exit 1
fi
outputs:
shouldRunKmp: ${{ steps.setVariables.outputs.shouldRunKmp }}
shouldRunAndroid: ${{ steps.setVariables.outputs.shouldRunAndroid }}
shouldRunIos: ${{ steps.setVariables.outputs.shouldRunIos }}
shouldRunDesktop: ${{ steps.setVariables.outputs.shouldRunDesktop }}

Build:
needs: SetUp
uses: ./.github/workflows/build.yml
with:
shouldRunKmp: ${{ needs.SetUp.outputs.shouldRunKmp }}
shouldRunAndroid: ${{ needs.SetUp.outputs.shouldRunAndroid }}
shouldRunIos: ${{ needs.SetUp.outputs.shouldRunIos }}
shouldRunDesktop: ${{ needs.SetUp.outputs.shouldRunDesktop }}

UnitTests:
needs: SetUp
uses: ./.github/workflows/test.yml
with:
shouldRunKmp: ${{ needs.SetUp.outputs.shouldRunKmp }}
shouldRunAndroid: ${{ needs.SetUp.outputs.shouldRunAndroid }}
shouldRunIos: ${{ needs.SetUp.outputs.shouldRunIos }}
shouldRunDesktop: ${{ needs.SetUp.outputs.shouldRunDesktop }}

AllowMerge:
if: always()
runs-on: ubuntu-latest
needs: [ Build, UnitTests ]
steps:
- run: |
if [ ${{ github.event_name }} == pull_request ] && [ ${{ join(github.event.pull_request.labels.*.name) == '' }} == true ]; then
exit 1
elif [ ${{ (contains(needs.Build.result, 'failure')) }} == true ] || [ ${{ (contains(needs.UnitTests.result, 'failure')) }} == true ]; then
exit 1
else
exit 0
fi
100 changes: 100 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Tests

on:
workflow_call:
inputs:
shouldRunKmp:
required: true
type: string
shouldRunAndroid:
required: true
type: string
shouldRunIos:
required: true
type: string
shouldRunDesktop:
required: true
type: string

jobs:
Android:
if: ${{ inputs.shouldRunKmp == 'true' || inputs.shouldRunAndroid == 'true' }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Job set up
uses: ./.github/actions/job-set-up

- run: ./gradlew clean testDebug -p androidApp/

Desktop:
if: ${{ inputs.shouldRunKmp == 'true' || inputs.shouldRunDesktop == 'true' }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Job set up
uses: ./.github/actions/job-set-up

- run: ./gradlew clean jvmTest -p desktopApp/

iOS:
# if: ${{ inputs.shouldRunKmp == 'true' || inputs.shouldRunIos == 'true' }}
if: false
runs-on: macos-12

steps:
- uses: actions/checkout@v3

- name: Job set up
uses: ./.github/actions/job-set-up

- name: iOS set up
uses: ./.github/actions/ios-set-up

- run: xcodebuild build test -workspace iosApp/iosApp.xcworkspace -configuration Debug -scheme iosApp -sdk iphoneos -destination name='iPhone 14' -verbose

- name: Upload logs
if: always()
uses: actions/upload-artifact@v3
with:
path: "/Users/runner/Library/Developer/Xcode/DerivedData/*"

KMP-Android:
if: ${{ inputs.shouldRunKmp == 'true'}}
runs-on: macos-12

steps:
- uses: actions/checkout@v3

- name: Job set up
uses: ./.github/actions/job-set-up

- run: ./gradlew clean testDebugUnitTest -p shared/

KMP-Desktop:
if: ${{ inputs.shouldRunKmp == 'true'}}
runs-on: macos-12

steps:
- uses: actions/checkout@v3

- name: Job set up
uses: ./.github/actions/job-set-up

- run: ./gradlew clean desktopTest -p shared/

KMP-iOS:
if: ${{ inputs.shouldRunKmp == 'true'}}
runs-on: macos-12

steps:
- uses: actions/checkout@v3

- name: Job set up
uses: ./.github/actions/job-set-up

- run: if [[ $(uname -m) == 'arm64' ]]; then ./gradlew clean iosSimulatorArm64Test -p shared/; else ./gradlew clean iosX64Test -p shared/; fi

0 comments on commit 5a80fbb

Please sign in to comment.