Skip to content

Commit

Permalink
Refactor if statements to match .NET
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Melchior committed Nov 16, 2023
1 parent d4af054 commit 9e434c7
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 70 deletions.
40 changes: 20 additions & 20 deletions .github/workflows/include-check-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:

- name: Save JVM packages
uses: actions/upload-artifact@v3
if: steps.jvm-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.jvm-cache.outputs.cache-hit == 'true'
with:
name: packages-jvm-${{ steps.find-library-version.outputs.label }}
path: ./packages/build/m2-buildrepo/**/*
Expand All @@ -131,7 +131,7 @@ jobs:
- name: Delete downloaded JVM cache files
id: delete-cache-jvm
uses: JesseTG/rm@v1.0.3
if: steps.jvm-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.jvm-cache.outputs.cache-hit == 'true'
with:
path: ./packages/build/m2-buildrepo

Expand All @@ -147,7 +147,7 @@ jobs:

- name: Save JNI Stub packages
uses: actions/upload-artifact@v3
if: steps.jni-swig-stub-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.jni-swig-stub-cache.outputs.cache-hit == 'true'
with:
name: jni-stub-${{ steps.find-library-version.outputs.label }}
path: ./packages/jni-swig-stub/build/generated/sources/jni/*
Expand All @@ -156,7 +156,7 @@ jobs:
- name: Delete downloaded JVM cache files
id: delete-cache-jni-stub
uses: JesseTG/rm@v1.0.3
if: steps.jni-swig-stub-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.jni-swig-stub-cache.outputs.cache-hit == 'true'
with:
path: ./packages/jni-swig-stub/build/generated/sources/jni

Expand All @@ -172,7 +172,7 @@ jobs:

- name: Save JNI Linux lib package
uses: actions/upload-artifact@v3
if: steps.jni-linux-lib-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.jni-linux-lib-cache.outputs.cache-hit == 'true'
with:
name: jni-linux-lib-${{ steps.find-library-version.outputs.label }}
path: ./packages/cinterop/src/jvmMain/linux-build-dir/**/*
Expand All @@ -181,7 +181,7 @@ jobs:
- name: Delete downloaded JVM cache files
id: delete-cache-linux-lib
uses: JesseTG/rm@v1.0.3
if: steps.jni-linux-lib-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.jni-linux-lib-cache.outputs.cache-hit == 'true'
with:
path: ./packages/cinterop/src/jvmMain/linux-build-dir

Expand All @@ -197,7 +197,7 @@ jobs:

- name: Save Android packages
uses: actions/upload-artifact@v3
if: steps.android-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.android-cache.outputs.cache-hit == 'true'
with:
name: packages-android-${{ steps.find-library-version.outputs.label }}
path: ./packages/build/m2-buildrepo/**/*
Expand All @@ -206,7 +206,7 @@ jobs:
- name: Delete downloaded Android cache files
id: delete-cache-android
uses: JesseTG/rm@v1.0.3
if: steps.android-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.android-cache.outputs.cache-hit == 'true'
with:
path: ./packages/build/m2-buildrepo

Expand All @@ -222,7 +222,7 @@ jobs:

- name: Save Android Test APK
uses: actions/upload-artifact@v3
if: steps.android-test-base-apk.outputs.cache-hit == 'true'
if: !cancelled() && steps.android-test-base-apk.outputs.cache-hit == 'true'
with:
name: android-base-test-apk-${{ steps.find-library-version.outputs.label }}
path: ./packages/test-base/build/outputs/apk/androidTest/debug/test-base-debug-androidTest.apk
Expand All @@ -231,7 +231,7 @@ jobs:
- name: Delete Android Test APK cache files
id: delete-cache-android-base-test-apk
uses: JesseTG/rm@v1.0.3
if: steps.android-test-base-apk.outputs.cache-hit == 'true'
if: !cancelled() && steps.android-test-base-apk.outputs.cache-hit == 'true'
with:
path: ./packages/test-base/build/outputs/apk/androidTest/debug/test-base-debug-androidTest.apk

Expand All @@ -247,7 +247,7 @@ jobs:

- name: Save MacOS arm64 packages
uses: actions/upload-artifact@v3
if: steps.macos-arm64-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.macos-arm64-cache.outputs.cache-hit == 'true'
with:
name: packages-macos-arm64-${{ steps.find-library-version.outputs.label }}
path: ./packages/build/m2-buildrepo/**/*
Expand All @@ -256,7 +256,7 @@ jobs:
- name: Delete downloaded MacOS arm64 cache files
id: delete-cache-macos-arm64
uses: JesseTG/rm@v1.0.3
if: steps.macos-arm64-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.macos-arm64-cache.outputs.cache-hit == 'true'
with:
path: ./packages/build/m2-buildrepo

Expand All @@ -272,7 +272,7 @@ jobs:

- name: Save MacOS x64 packages
uses: actions/upload-artifact@v3
if: steps.macos-x64-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.macos-x64-cache.outputs.cache-hit == 'true'
with:
name: packages-macos-x64-${{ steps.find-library-version.outputs.label }}
path: ./packages/build/m2-buildrepo/**/*
Expand All @@ -281,7 +281,7 @@ jobs:
- name: Delete downloaded MacOS x64 cache files
id: delete-cache-macos-x64
uses: JesseTG/rm@v1.0.3
if: steps.macos-x64-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.macos-x64-cache.outputs.cache-hit == 'true'
with:
path: ./packages/build/m2-buildrepo

Expand All @@ -297,7 +297,7 @@ jobs:

- name: Save iOS arm64 packages
uses: actions/upload-artifact@v3
if: steps.ios-arm64-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.ios-arm64-cache.outputs.cache-hit == 'true'
with:
name: packages-ios-arm64-${{ steps.find-library-version.outputs.label }}
path: ./packages/build/m2-buildrepo/**/*
Expand All @@ -306,7 +306,7 @@ jobs:
- name: Delete downloaded iOS arm64 cache files
id: delete-cache-ios-arm64
uses: JesseTG/rm@v1.0.3
if: steps.ios-arm64-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.ios-arm64-cache.outputs.cache-hit == 'true'
with:
path: ./packages/build/m2-buildrepo

Expand All @@ -322,7 +322,7 @@ jobs:

- name: Save iOS x64 packages
uses: actions/upload-artifact@v3
if: steps.ios-x64-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.ios-x64-cache.outputs.cache-hit == 'true'
with:
name: packages-ios-x64-${{ steps.find-library-version.outputs.label }}
path: ./packages/build/m2-buildrepo/**/*
Expand All @@ -331,7 +331,7 @@ jobs:
- name: Delete downloaded iOS x64 cache files
id: delete-cache-ios-x64
uses: JesseTG/rm@v1.0.3
if: steps.ios-x64-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.ios-x64-cache.outputs.cache-hit == 'true'
with:
path: ./packages/build/m2-buildrepo

Expand All @@ -348,7 +348,7 @@ jobs:

- name: Save JNI Windows lib package
uses: actions/upload-artifact@v3
if: steps.jni-windows-lib-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.jni-windows-lib-cache.outputs.cache-hit == 'true'
with:
name: jni-windows-lib-${{ needs.check-cache.outputs.version-label }}
path: ./packages/cinterop/src/jvmMain/windows-build-dir/Release/realmc.dll
Expand All @@ -357,6 +357,6 @@ jobs:
- name: Delete downloaded JNI Windows lib cache files
id: delete-cache-windows-lib
uses: JesseTG/rm@v1.0.3
if: steps.jni-windows-lib-cache.outputs.cache-hit == 'true'
if: !cancelled() && steps.jni-windows-lib-cache.outputs.cache-hit == 'true'
with:
path: ./packages/cinterop/src/jvmMain/windows-build-dir
99 changes: 49 additions & 50 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
build-jni-swig-stub:
runs-on: ubuntu-latest
needs: check-cache
if: needs.check-cache.outputs.jni-swig-stub-cache-hit != 'true'
if: !cancelled() && needs.check-cache.outputs.jni-swig-stub-cache-hit != 'true'
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -75,8 +75,10 @@ jobs:
build-jvm-linux-native-lib:
runs-on: ubuntu-latest
needs: [check-cache, build-jni-swig-stub]
if: always() &&
(needs.build-jni-swig-stub.result == 'success' || needs.build-jni-swig-stub.result == 'skipped') &&
if: always() &&
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.check-cache.outputs.jni-linux-lib-cache-hit != 'true'

steps:
Expand Down Expand Up @@ -129,8 +131,10 @@ jobs:
build-jvm-windows-native-lib:
runs-on: windows-latest
needs: [check-cache, build-jni-swig-stub]
if: always() &&
(needs.build-jni-swig-stub.result == 'success' || needs.build-jni-swig-stub.result == 'skipped') &&
if: always() &&
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.check-cache.outputs.jni-windows-lib-cache-hit != 'true'

steps:
Expand Down Expand Up @@ -190,8 +194,9 @@ jobs:
runs-on: macos-latest
needs: [check-cache, build-jvm-linux-native-lib, build-jvm-windows-native-lib]
if: always() &&
(needs.build-jvm-linux-native-lib.result == 'success' || needs.build-jvm-linux-native-lib.result == 'skipped') &&
(needs.build-jvm-windows-native-lib.result == 'success' || needs.build-jvm-windows-native-lib.result == 'skipped') &&
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.check-cache.outputs.packages-jvm-cache-hit != 'true'

steps:
Expand Down Expand Up @@ -295,7 +300,7 @@ jobs:
runs-on: ubuntu-latest
needs: check-cache
# needs: static-analysis
if: needs.check-cache.outputs.packages-android-cache-hit != 'true'
if: !cancelled() && needs.check-cache.outputs.packages-android-cache-hit != 'true'

steps:
- name: Checkout code
Expand Down Expand Up @@ -421,7 +426,7 @@ jobs:
runs-on: macos-latest
needs: check-cache
# needs: static-analysis
if: needs.check-cache.outputs.packages-macos-x64-cache-hit != 'true'
if: !cancelled() && needs.check-cache.outputs.packages-macos-x64-cache-hit != 'true'

steps:
- name: Checkout code
Expand Down Expand Up @@ -507,7 +512,7 @@ jobs:
runs-on: macos-latest
needs: check-cache
# needs: static-analysis
if: needs.check-cache.outputs.packages-macos-arm64-cache-hit != 'true'
if: !cancelled() && needs.check-cache.outputs.packages-macos-arm64-cache-hit != 'true'

steps:
- name: Checkout code
Expand Down Expand Up @@ -585,7 +590,7 @@ jobs:
runs-on: macos-latest
needs: check-cache
# needs: static-analysis
if: needs.check-cache.outputs.packages-ios-x64-cache-hit != 'true'
if: !cancelled() && needs.check-cache.outputs.packages-ios-x64-cache-hit != 'true'

steps:
- name: Checkout code
Expand Down Expand Up @@ -663,7 +668,7 @@ jobs:
runs-on: macos-latest
needs: check-cache
# needs: static-analysis
if: needs.check-cache.outputs.packages-ios-arm64-cache-hit != 'true'
if: !cancelled() && needs.check-cache.outputs.packages-ios-arm64-cache-hit != 'true'

steps:
- name: Checkout code
Expand Down Expand Up @@ -745,10 +750,10 @@ jobs:
timeout-minutes: 60
runs-on: macos-latest
needs: [check-cache, build-android-packages, build-jvm-packages]
if: |
always() &&
(needs.build-android-packages.result == 'success' || needs.build-android-packages.result == 'skipped') &&
(needs.build-jvm-packages.result == 'success' || needs.build-jvm-packages.result == 'skipped')
if: always() &&
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')

steps:
- name: Checkout code
Expand Down Expand Up @@ -819,10 +824,11 @@ jobs:
timeout-minutes: 60
runs-on: ubuntu-latest
needs: [ check-cache, build-android-packages, build-jvm-packages ]
if: |
always() &&
(needs.build-android-packages.result == 'success' || needs.build-android-packages.result == 'skipped') &&
(needs.build-jvm-packages.result == 'success' || needs.build-jvm-packages.result == 'skipped')
if: always() &&
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')

steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -866,9 +872,10 @@ jobs:
# TODO Do we need to wait for all matrix builds?
# Disable macos-arm for now as the host needs to have the Android SDK installed even though it isn't really using it.
needs: [check-cache, build-macos-x64-packages] #, build-macos-arm64-packages]
if: |
always() &&
(needs.build-macos-x64-packages.result == 'success' || needs.build-macos-x64-packages.result == 'skipped')
if: always() &&
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')

steps:
- name: Checkout code
Expand Down Expand Up @@ -922,9 +929,10 @@ jobs:
# TODO Do we need to wait for all matrix builds?
# Disable macos-arm for now as the host needs to have the Android SDK installed even though it isn't really using it.
needs: [check-cache, build-macos-x64-packages, build-ios-x64-packages] # , build-ios-arm64-packages]
if: |
always() &&
(needs.build-ios-x64-packages.result == 'success' || needs.build-ios-x64-packages.result == 'skipped')
if: always() &&
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')

steps:
- name: Checkout code
Expand Down Expand Up @@ -983,9 +991,10 @@ jobs:

runs-on: ${{ matrix.os }}
needs: [check-cache, build-jvm-packages]
if: |
always() &&
(needs.build-jvm-packages.result == 'success' || needs.build-jvm-packages.result == 'skipped')
if: always() &&
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')

steps:
- name: Checkout code
Expand Down Expand Up @@ -1026,14 +1035,10 @@ jobs:
package-all-artifacts:
runs-on: ubuntu-latest
needs: [check-cache, build-jvm-packages, build-android-packages, build-macos-x64-packages, build-macos-arm64-packages, build-ios-x64-packages, build-ios-arm64-packages]
if: |
always() &&
(needs.build-android-packages.result == 'success' || needs.build-android-packages.result == 'skipped') &&
(needs.build-jvm-packages.result == 'success' || needs.build-jvm-packages.result == 'skipped') &&
(needs.build-macos-x64-packages.result == 'success' || needs.build-ios-x64-packages.result == 'skipped') &&
(needs.build-macos-arm64-packages.result == 'success' || needs.build-macos-arm64-packages.result == 'skipped') &&
(needs.build-ios-x64-packages.result == 'success' || needs.build-ios-x64-packages.result == 'skipped') &&
(needs.build-ios-arm64-packages.result == 'success' || needs.build-ios-arm64-packages.result == 'skipped')
if: always() &&
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')

steps:
- name: Checkout code
Expand Down Expand Up @@ -1091,9 +1096,10 @@ jobs:
integration-tests:
uses: ./.github/workflows/include-integration-tests.yml
needs: [check-cache, package-all-artifacts]
if: |
always() &&
(needs.package-all-artifacts.result == 'success' || needs.package-all-artifacts.result == 'skipped')
if: always() &&
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
with:
version-label: ${{ needs.check-cache.outputs.version-label }}

Expand All @@ -1112,17 +1118,10 @@ jobs:
package-all-artifacts
]
if: always() &&
!cancelled() &&
endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') &&
needs.check-cache.result == 'success' &&
needs.static-analysis.result == 'success' &&
needs.static-analysis.result == 'success' &&
needs.integration-tests.result == 'success' &&
needs.test-jvm-packages.result == 'success' &&
needs.test-macos-packages.result == 'success' &&
needs.test-ios-packages.result == 'success' &&
needs.test-android-packages-emulator.result == 'success' &&
needs.test-android-packages-device-farm.result == 'success' &&
needs.package-all-artifacts.result == 'success'
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')

secrets: inherit
with:
Expand Down

0 comments on commit 9e434c7

Please sign in to comment.