Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions .github/workflows/_build-ios-port.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: _Build iOS port (reusable)

# Reusable workflow that runs scripts/setup-workspace.sh + scripts/build-ios-port.sh
# once per workflow run, populating shared caches that downstream test jobs (in
# scripts-ios.yml, scripts-ios-native.yml, ios-packaging.yml) restore via the
# same cache keys.
#
# A separate "cn1-built" cache is keyed on the CN1 source hash with no restore-
# keys (exact match only). On hit, the entire setup-workspace + build-ios-port
# sequence is skipped — the iOS port artifact in ~/.m2/repository/com/codenameone
# is already correct for the current source state.
#
# This cache is shared across all three iOS workflows on the same branch, so
# whichever workflow runs first populates it and the others skip the rebuild.

on:
workflow_call:

jobs:
build:
runs-on: macos-15
timeout-minutes: 60
concurrency:
group: mac-ios-port-${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4

- name: Cache CocoaPods and user gems
uses: actions/cache@v4
with:
path: |
~/.gem
~/Library/Caches/CocoaPods
~/.cocoapods/repos
key: ${{ runner.os }}-pods-v1-${{ hashFiles('scripts/setup-workspace.sh') }}
restore-keys: |
${{ runner.os }}-pods-v1-

- name: Ensure CocoaPods tooling
run: |
mkdir -p ~/.codenameone
cp maven/UpdateCodenameOne.jar ~/.codenameone/
set -euo pipefail
if ! command -v ruby >/dev/null; then
echo "ruby not found"; exit 1
fi
GEM_USER_DIR="$(ruby -e 'print Gem.user_dir')"
export PATH="$GEM_USER_DIR/bin:$PATH"
if ! command -v pod >/dev/null 2>&1; then
gem install cocoapods xcodeproj --no-document --user-install
fi
pod --version

- name: Compute setup-workspace hash
id: setup_hash
run: |
set -euo pipefail
echo "hash=$(shasum -a 256 scripts/setup-workspace.sh | awk '{print $1}')" >> "$GITHUB_OUTPUT"

- name: Compute CN1 source hash
id: src_hash
run: |
set -euo pipefail
SRC_HASH=$(find CodenameOne/src Ports/iOSPort vm/JavaAPI vm/ByteCodeTranslator Themes \
-type f \( -name '*.java' -o -name '*.m' -o -name '*.h' -o -name '*.xml' -o -name '*.properties' -o -name '*.css' \) 2>/dev/null \
| sort | xargs shasum -a 256 | shasum -a 256 | awk '{print $1}')
POM_HASH=$(find . -name 'pom.xml' -not -path './scripts/*' 2>/dev/null \
| sort | xargs shasum -a 256 | shasum -a 256 | awk '{print $1}')
SCRIPT_HASH=$(shasum -a 256 \
scripts/setup-workspace.sh \
scripts/build-ios-port.sh \
scripts/build-native-themes.sh \
.github/workflows/_build-ios-port.yml \
| shasum -a 256 | awk '{print $1}')
echo "hash=${SRC_HASH:0:16}-${POM_HASH:0:16}-${SCRIPT_HASH:0:16}" >> "$GITHUB_OUTPUT"

- name: Set TMPDIR
run: echo "TMPDIR=${{ runner.temp }}" >> $GITHUB_ENV

- name: Cache codenameone-tools
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/codenameone-tools
key: ${{ runner.os }}-cn1-tools-${{ steps.setup_hash.outputs.hash }}
restore-keys: |
${{ runner.os }}-cn1-tools-

- name: Cache Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2-

- name: Restore cn1-binaries cache
uses: actions/cache@v4
with:
path: ../cn1-binaries
key: cn1-binaries-${{ runner.os }}-${{ steps.setup_hash.outputs.hash }}
restore-keys: |
cn1-binaries-${{ runner.os }}-

# Built CN1 + iOS port artifacts. Restored after the m2 cache so it
# overwrites any stale com/codenameone subtree pulled in by the broader
# m2 cache (whose key is keyed on POMs, not source).
- name: Cache built CN1 + iOS port artifacts
id: cn1_built
uses: actions/cache@v4
with:
path: |
~/.m2/repository/com/codenameone
Themes
Ports/iOSPort/nativeSources
key: cn1-built-${{ runner.os }}-${{ steps.src_hash.outputs.hash }}

- name: Setup workspace
if: steps.cn1_built.outputs.cache-hit != 'true'
run: ./scripts/setup-workspace.sh -q -DskipTests
timeout-minutes: 40

- name: Build iOS port
if: steps.cn1_built.outputs.cache-hit != 'true'
run: ./scripts/build-ios-port.sh -q -DskipTests
timeout-minutes: 40

- name: Report cache outcome
run: |
if [ "${{ steps.cn1_built.outputs.cache-hit }}" = "true" ]; then
echo "cn1-built cache HIT for key cn1-built-${{ runner.os }}-${{ steps.src_hash.outputs.hash }} — setup-workspace and build-ios-port were skipped."
else
echo "cn1-built cache MISS for key cn1-built-${{ runner.os }}-${{ steps.src_hash.outputs.hash }} — built fresh."
fi
49 changes: 35 additions & 14 deletions .github/workflows/ios-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
paths:
- '.github/workflows/ios-packaging.yml'
- '.github/workflows/_build-ios-port.yml'
- 'maven/codenameone-maven-plugin/**'
- 'vm/ByteCodeTranslator/**'
- 'Ports/iOSPort/**'
Expand All @@ -17,6 +18,7 @@ on:
branches: [ master ]
paths:
- '.github/workflows/ios-packaging.yml'
- '.github/workflows/_build-ios-port.yml'
- 'maven/codenameone-maven-plugin/**'
- 'vm/ByteCodeTranslator/**'
- 'Ports/iOSPort/**'
Expand All @@ -28,16 +30,18 @@ on:
- '!docs/**'

jobs:
build-port:
uses: ./.github/workflows/_build-ios-port.yml

packaging:
needs: build-port
permissions:
contents: read
runs-on: macos-15
timeout-minutes: 75
timeout-minutes: 45
# Exercises both CocoaPods and SPM in a single Xcode project. Catches
# regressions in either dependency manager (each pathway runs end to end)
# and additionally validates that they coexist correctly. The pods-only
# and spm-only matrix entries previously here were proper subsets of this
# configuration, so they were dropped to halve macOS runner consumption.
# and additionally validates that they coexist correctly.
env:
IOS_DEPENDENCY_ARGS: >-
-Dcodename1.arg.ios.dependencyManager=both
Expand Down Expand Up @@ -75,9 +79,24 @@ jobs:
id: setup_hash
run: |
set -euo pipefail
SETUP_HASH=$(shasum -a 256 scripts/setup-workspace.sh | awk '{print $1}')
IOS_PORT_HASH=$(find Ports/iOSPort/src -type f -name '*.java' | sort | xargs shasum -a 256 | shasum -a 256 | awk '{print $1}')
echo "hash=${SETUP_HASH}-${IOS_PORT_HASH}" >> "$GITHUB_OUTPUT"
echo "hash=$(shasum -a 256 scripts/setup-workspace.sh | awk '{print $1}')" >> "$GITHUB_OUTPUT"

- name: Compute CN1 source hash
id: src_hash
run: |
set -euo pipefail
SRC_HASH=$(find CodenameOne/src Ports/iOSPort vm/JavaAPI vm/ByteCodeTranslator Themes \
-type f \( -name '*.java' -o -name '*.m' -o -name '*.h' -o -name '*.xml' -o -name '*.properties' -o -name '*.css' \) 2>/dev/null \
| sort | xargs shasum -a 256 | shasum -a 256 | awk '{print $1}')
POM_HASH=$(find . -name 'pom.xml' -not -path './scripts/*' 2>/dev/null \
| sort | xargs shasum -a 256 | shasum -a 256 | awk '{print $1}')
SCRIPT_HASH=$(shasum -a 256 \
scripts/setup-workspace.sh \
scripts/build-ios-port.sh \
scripts/build-native-themes.sh \
.github/workflows/_build-ios-port.yml \
| shasum -a 256 | awk '{print $1}')
echo "hash=${SRC_HASH:0:16}-${POM_HASH:0:16}-${SCRIPT_HASH:0:16}" >> "$GITHUB_OUTPUT"

- name: Set TMPDIR
run: echo "TMPDIR=${{ runner.temp }}" >> $GITHUB_ENV
Expand Down Expand Up @@ -106,13 +125,15 @@ jobs:
restore-keys: |
cn1-binaries-${{ runner.os }}-

- name: Setup workspace
run: ./scripts/setup-workspace.sh -q -DskipTests
timeout-minutes: 40

- name: Build iOS port
run: ./scripts/build-ios-port.sh -q -DskipTests
timeout-minutes: 40
- name: Restore built CN1 + iOS port artifacts
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository/com/codenameone
Themes
Ports/iOSPort/nativeSources
key: cn1-built-${{ runner.os }}-${{ steps.src_hash.outputs.hash }}
fail-on-cache-miss: true

- name: Build sample iOS app
id: build_ios_app
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/parparvm-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: ParparVM Java Tests
on:
pull_request:
paths:
- '.github/workflows/parparvm-tests.yml'
- 'vm/**'
- 'Ports/JavaScriptPort/**'
- '!vm/**/README.md'
Expand All @@ -11,6 +12,7 @@ on:
push:
branches: [ master, main ]
paths:
- '.github/workflows/parparvm-tests.yml'
- 'vm/**'
- 'Ports/JavaScriptPort/**'
- '!vm/**/README.md'
Expand Down
41 changes: 33 additions & 8 deletions .github/workflows/scripts-ios-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
paths:
- '.github/workflows/scripts-ios-native.yml'
- '.github/workflows/_build-ios-port.yml'
- 'scripts/setup-workspace.sh'
- 'scripts/build-ios-port.sh'
- 'scripts/build-ios-app.sh'
Expand All @@ -30,6 +31,7 @@ on:
branches: [ master ]
paths:
- '.github/workflows/scripts-ios-native.yml'
- '.github/workflows/_build-ios-port.yml'
- 'scripts/setup-workspace.sh'
- 'scripts/build-ios-port.sh'
- 'scripts/build-ios-app.sh'
Expand All @@ -54,11 +56,15 @@ on:
- '!maven/core-unittests/**'

jobs:
build-port:
uses: ./.github/workflows/_build-ios-port.yml

native-ios:
needs: build-port
permissions:
contents: read
runs-on: macos-15
timeout-minutes: 65
timeout-minutes: 45
concurrency:
group: mac-ci-${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
Expand Down Expand Up @@ -98,6 +104,23 @@ jobs:
set -euo pipefail
echo "hash=$(shasum -a 256 scripts/setup-workspace.sh | awk '{print $1}')" >> "$GITHUB_OUTPUT"

- name: Compute CN1 source hash
id: src_hash
run: |
set -euo pipefail
SRC_HASH=$(find CodenameOne/src Ports/iOSPort vm/JavaAPI vm/ByteCodeTranslator Themes \
-type f \( -name '*.java' -o -name '*.m' -o -name '*.h' -o -name '*.xml' -o -name '*.properties' -o -name '*.css' \) 2>/dev/null \
| sort | xargs shasum -a 256 | shasum -a 256 | awk '{print $1}')
POM_HASH=$(find . -name 'pom.xml' -not -path './scripts/*' 2>/dev/null \
| sort | xargs shasum -a 256 | shasum -a 256 | awk '{print $1}')
SCRIPT_HASH=$(shasum -a 256 \
scripts/setup-workspace.sh \
scripts/build-ios-port.sh \
scripts/build-native-themes.sh \
.github/workflows/_build-ios-port.yml \
| shasum -a 256 | awk '{print $1}')
echo "hash=${SRC_HASH:0:16}-${POM_HASH:0:16}-${SCRIPT_HASH:0:16}" >> "$GITHUB_OUTPUT"

- name: Set TMPDIR
run: echo "TMPDIR=${{ runner.temp }}" >> $GITHUB_ENV

Expand Down Expand Up @@ -125,13 +148,15 @@ jobs:
restore-keys: |
cn1-binaries-${{ runner.os }}-

- name: Setup workspace
run: ./scripts/setup-workspace.sh -q -DskipTests
timeout-minutes: 40

- name: Build iOS port
run: ./scripts/build-ios-port.sh -q -DskipTests
timeout-minutes: 40
- name: Restore built CN1 + iOS port artifacts
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository/com/codenameone
Themes
Ports/iOSPort/nativeSources
key: cn1-built-${{ runner.os }}-${{ steps.src_hash.outputs.hash }}
fail-on-cache-miss: true

- name: Build sample iOS app
id: build_ios_app
Expand Down
Loading
Loading