Skip to content

Commit

Permalink
complete test reports github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-f committed Mar 7, 2024
1 parent 22aa62d commit e6db9c1
Show file tree
Hide file tree
Showing 7 changed files with 870 additions and 225 deletions.
7 changes: 7 additions & 0 deletions .github/actions/ios-set-up/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: iOS set up
description: Sets up Kotlin Native
runs:
using: "composite"
steps:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
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: "17"

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
73 changes: 73 additions & 0 deletions .github/workflows/code_review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
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"
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 }}

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

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

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
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages
name: Deploy NoiseCapture as a static website

on:
# Runs on pushes targeting the default branch
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Tests

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

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

steps:
- uses: actions/checkout@v3

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

- run: ./gradlew :shared:cleanTestDebugUnitTest :shared:testDebugUnitTest



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:cleanTestDebugUnitTest :shared:testDebugUnitTest

iOS:
if: ${{ inputs.shouldRunKmp == 'true' && inputs.shouldRunIos == 'true' }}
runs-on: macos-13
timeout-minutes: 60
steps:
- uses: actions/checkout@v3

- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.0'

- name: set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17

- uses: gradle/gradle-build-action@v2
with:
cache-disabled: true

- name: iosX64Test
# Disable CC due to https://github.com/google/ksp/issues/1463
run: ./gradlew iosX64Test --no-configuration-cache

- name: Upload reports
if: always()
uses: actions/upload-artifact@v3
with:
name: ios-reports
path: |
**/build/reports/*
Loading

0 comments on commit e6db9c1

Please sign in to comment.