Skip to content

Commit

Permalink
more reuse of workflows/steps #639
Browse files Browse the repository at this point in the history
  • Loading branch information
thoutbeckers committed Feb 1, 2023
1 parent 26c6414 commit 74bd1e6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 56 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
matrix:
module: ${{ fromJSON(needs.build.outputs.projects) }}
steps:
- name: restore workspace
uses: ./.github/workflows/restore_workspace_macos.yaml
- name: Setup tools and cache for workspace
uses: ./.github/workflows/setup_tools_macos/
with:
kotlinVersion: needs.build.outputs.kotlinVersion

- name: run tests
- name: run iOS tests
run: ./gradlew :${{ matrix.module }}:iosX64Test
6 changes: 4 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ jobs:
# remove VM settings as defined for using the IDE
- run: sed -i '' -e '/org.gradle.jvmargs/d' gradle.properties; cat gradle.properties

- name : set up JDK 11
# TODO: use setup_tools_macos

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

- name: Konan cache
uses: actions/cache@v3
Expand Down
43 changes: 9 additions & 34 deletions .github/workflows/setup_macos.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Setup macOS reusable workflow'
name: 'Setup macOS workspace reusable workflow'

env:
GRADLE_OPTS: "-Dorg.gradle.jvmargs=\"-Xmx8G -XX:MaxMetaspaceSize=512m -Dorg.gradle.daemon=false -Dkotlin.incremental=false\" -Dorg.gradle.daemon=false -Dkotlin.incremental=false -Dkotlin.daemon.jvm.options=-Xmx8G,-XX:MaxMetaspaceSize=512m,-Dorg.gradle.daemon=false,-Dkotlin.incremental=false"
Expand Down Expand Up @@ -33,50 +33,25 @@ jobs:
# remove VM settings as defined for using the IDE
- run: sed -i '' -e '/org.gradle.jvmargs/d' gradle.properties; cat gradle.properties

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

- name: get Kotlin version
id: kotlinVersion
run: grep kaluga.kotlinVersion= gradle.properties | sed s/"kaluga."// >> $GITHUB_OUTPUT

- name: Gradle cache
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
gradle-home-cache-includes: |
caches
notifications
- name: Konan cache
uses: actions/cache@v3
id: konan-cache
- name: setup tools and enable Gradle cache writing
uses: ./github/workspace/setup_tools_macos/
with:
path: |
~/.konan/cache/*
~/.konan/kotlin-native-prebuilt-macos-x86_64-${{ steps.kotlinVersion.outputs.kotlinVersion }}/*
key: konan-${{ steps.kotlinVersion.outputs.kotlinVersion }}
gradle-cache-read-only: false
kotlinVersion: ${{ steps.kotlinVersion.outputs.kotlinVersion }}

- run: ./gradlew generateNonDependentProjectsFile
- name: generate file with projects for build matrix
run: ./gradlew generateNonDependentProjectsFile

- name: Load projects for build matrix
- name: load projects for build matrix
uses: cardinalby/export-env-action@v2
id: envFile
with:
envFile: 'non_dependent_projects.properties'
export: 'false'

- name: Make cache of workspace
uses: actions/cache@v3
id: restore-build
with:
path: |
./*
!/.gradle
key: build-iOS-${{ github.sha }}

- name: Gradle task
- name: run custom Gradle task
run: ./gradlew ${{ inputs.gradleTask }}
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
name: "restore macOS workspace from cache"
name: "setup tools and caching for macOS workspace"
description: "setup tools and caching for macOS workspace"
inputs:
kotlinVersion:
required: true
description: Kotlin version
gradle-cache-read-only:
default: "true"
description: Updates gradle cache after actions if not read-only
runs:
using: "composite"
steps:
- name: Gradle cache
uses: gradle/gradle-build-action@v2
with:
cache-read-only: ${{ inputs.gradle-cache-read-only }}
gradle-home-cache-includes: |
caches
notifications
- name: Get cache of workspace
uses: actions/cache@v3
id: restore-build
with:
path: |
./*
!/.gradle
key: build-iOS-${{ github.sha }}

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

- name: Konan cache
uses: actions/cache@v3
id: konan-cache
with:
path: |
~/.konan/cache/*
~/.konan/kotlin-native-prebuilt-macos-x86_64-${{ needs.build.outputs.kotlinVersion }}/*
~/.konan/kotlin-native-prebuilt-macos-x86_64-${{ inputs.kotlinVersion }}/*
~/.konan/dependencies/*
key: konan-${{ inputs.kotlinVersion }}

- name: Make cache of workspace
uses: actions/cache@v3
id: restore-build
with:
path: |
./*
!/.gradle
key: build-iOS-${{ github.sha }}

0 comments on commit 74bd1e6

Please sign in to comment.