Skip to content

Commit

Permalink
CI: Extract jobs into reusable workflows (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
shepeliev committed May 9, 2024
1 parent 618c831 commit 0b1ecb7
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 53 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build and test all

on:
push:
branches:
- main
paths-ignore:
- "**/*.md"
pull_request:
paths-ignore:
- "**/*.md"

workflow_dispatch:

jobs:
lint:
name: Lint
uses: ./.github/workflows/lint.yml

build-linux:
name: Build Linux
uses: ./.github/workflows/build-linux.yml

build-macos:
name: Build macOS
uses: ./.github/workflows/build-macos.yml

build-sample-app-macos:
name: Build Sample App macOS
uses: ./.github/workflows/build-sample-app-macos.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Pull Request Checks
name: Build Linux

on:
pull_request:
branches: [ main ]
workflow_call:
workflow_dispatch:

jobs:
lint:
build:
name: Build and test Android/JS/WasmJS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -19,22 +20,13 @@ jobs:
- name: Gradle cache
uses: gradle/gradle-build-action@v2

- name: Run Kotlin linter
run: ./gradlew ktlintCheck

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up JDK 17
uses: actions/setup-java@v1
- name: Cache konan directory
uses: actions/cache@v3
with:
java-version: 17
cache: gradle

- name: Gradle cache
uses: gradle/gradle-build-action@v2
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('*.gradle.kts', 'buildSrc/*') }}
restore-keys: |
${{ runner.os }}-konan-
- name: Enable KVM
run: |
Expand Down Expand Up @@ -78,37 +70,5 @@ jobs:
name: "JS Tests Report HTML"
path: "webrtc-kmp/build/reports/tests/wasmJs*Test"

test-ios:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2

- name: Cocoapods cache
uses: actions/cache@v3
id: cocoapods-cache
with:
path: |
~/.cocoapods
~/Library/Caches/CocoaPods
*/build/cocoapods
*/build/classes
key: cocoapods-cache

- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
cache: gradle

- name: Gradle cache
uses: gradle/gradle-build-action@v2

- name: Run iOS tests
run: ./gradlew cleanTest webrtc-kmp:iosSimulatorArm64Test

- name: Upload iOS test artifact
uses: actions/upload-artifact@v2
if: failure()
with:
name: "iOS Tests Report HTML"
path: "webrtc-kmp/build/reports/tests/iosX64Test"
- name: Build sample app
run: ./gradlew sample:composeApp:assemble
50 changes: 50 additions & 0 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build macOS

on:
workflow_call:
workflow_dispatch:

jobs:
build:
name: Build and test iOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v2

- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
cache: gradle

- name: Gradle cache
uses: gradle/gradle-build-action@v2

- name: Cache konan directory
uses: actions/cache@v3
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('*.gradle.kts', 'buildSrc/*') }}
restore-keys: |
${{ runner.os }}-konan-
- name: Cocoapods cache
uses: actions/cache@v3
id: cocoapods-cache
with:
path: |
~/.cocoapods
~/Library/Caches/CocoaPods
*/build/cocoapods
*/build/classes
key: cocoapods-cache

- name: Run iOS tests
run: ./gradlew cleanTest webrtc-kmp:iosSimulatorArm64Test

- name: Upload iOS test artifact
uses: actions/upload-artifact@v2
if: failure()
with:
name: "iOS Tests Report HTML"
path: "webrtc-kmp/build/reports/tests/iosX64Test"
45 changes: 45 additions & 0 deletions .github/workflows/build-sample-app-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build macOS

on:
workflow_call:
workflow_dispatch:

jobs:
build:
name: Build sample app iOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v2

- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
cache: gradle

- name: Gradle cache
uses: gradle/gradle-build-action@v2

- name: Cache konan directory
uses: actions/cache@v3
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('*.gradle.kts', 'buildSrc/*') }}
restore-keys: |
${{ runner.os }}-konan-
- name: Cocoapods cache
uses: actions/cache@v3
id: cocoapods-cache
with:
path: |
~/.cocoapods
~/Library/Caches/CocoaPods
*/build/cocoapods
*/build/classes
key: cocoapods-cache

- name: Build sample app
run: |
cd sample/iosApp
xcodebuild -configuration Debug -scheme iosApp -sdk iphonesimulator -arch arm64
31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Pull Request Checks

on:
workflow_call:
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
cache: gradle

- name: Gradle cache
uses: gradle/gradle-build-action@v2

- name: Cache konan directory
uses: actions/cache@v3
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('*.gradle.kts', 'buildSrc/*') }}
restore-keys: |
${{ runner.os }}-konan-
- name: Run Kotlin linter
run: ./gradlew ktlintCheck
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.shepeliev.webrtckmp.externals

import kotlin.js.JsName

@JsName("MediaStream")
external interface PlatformMediaStream {
val id: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.shepeliev.webrtckmp.externals

import kotlin.js.JsName
import com.shepeliev.webrtckmp.FacingMode
import com.shepeliev.webrtckmp.MediaStreamTrackState
import com.shepeliev.webrtckmp.MediaTrackConstraints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.shepeliev.webrtckmp.internal

import kotlin.js.JsName

@JsName("console")
internal external object Console {
fun log(message: String)
Expand Down

0 comments on commit 0b1ecb7

Please sign in to comment.