hammer-editor/.github/workflows/build.yml
renovate[bot] 4acb0073f6
Update actions/cache action to v6 (#638)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-23 16:36:06 -07:00

217 lines
8.4 KiB
YAML

name: Build CI
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew buildDebug
# Compiles + packages the Android instrumented (androidTest) source set without a device.
# buildDebug does not touch androidTest, so stale instrumented tests rot silently otherwise.
- name: Compile Android instrumented tests
run: ./gradlew :android:assembleDebugAndroidTest
- name: Run Kover
run: ./gradlew koverXmlReport
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
# Explicit gate for the server unit tests (incl. EntityHashSensitivityTest). These otherwise
# only run as a side-effect of koverXmlReport, which is fragile - a kover config change would
# silently stop running them.
- name: Run Server Unit Tests
run: ./gradlew :server:test
- name: Run JavaScript Unit Tests
run: ./gradlew :server:jsTest
- name: Run Server Migration Tests
run: ./gradlew :server:verifySqlDelightMigration
- name: Run Round-Trip Sync Integration Tests
id: integration-tests
run: ./gradlew :integrationTests:jvmTest
- name: Upload integration test report on failure
if: failure() && steps.integration-tests.outcome == 'failure'
uses: actions/upload-artifact@v7
with:
name: integration-tests-report
path: |
integrationTests/build/reports/tests/jvmTest/
integrationTests/build/test-results/jvmTest/
android-instrumented-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# The hardware-accelerated emulator needs KVM, which ubuntu-latest exposes once permissioned.
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
# Cache the emulator system image + AVD snapshot so subsequent runs skip the slow cold
# boot. Keyed on every parameter that defines the AVD - bump the key if any `with:` value
# below changes, or the cached snapshot won't match.
- name: AVD cache
uses: actions/cache@v6
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-api34-x86_64-google_apis-pixel_6
# On a cache miss, cold-boot once and let the action save a snapshot for the cache. No tests here.
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2.37.0
with:
api-level: 34
arch: x86_64
target: google_apis
profile: pixel_6
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: echo "Generated AVD snapshot for caching."
- name: Run instrumented tests on emulator
id: instrumented-tests
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2.37.0
with:
api-level: 34
arch: x86_64
target: google_apis
profile: pixel_6
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: ./gradlew :android:connectedDebugAndroidTest
- name: Upload instrumented test report on failure
if: failure() && steps.instrumented-tests.outcome == 'failure'
uses: actions/upload-artifact@v7
with:
name: instrumented-tests-report
path: |
android/build/reports/androidTests/connected/
android/build/outputs/androidTest-results/connected/
# Compile gate for Kotlin/Native — the ubuntu `build` job never compiles the
# iOS targets, so Native-only breakage in commonMain slips through otherwise.
ios-compile:
name: iOS compile check
runs-on: macos-latest
steps:
- uses: actions/checkout@v7
- name: set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Compile iOS Kotlin targets
run: ./gradlew :composeUi:compileKotlinIosArm64 :composeUi:compileKotlinIosSimulatorArm64
# ios:
# runs-on: macos-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: check Xcode version
# run: /usr/bin/xcodebuild -version
#
# - name: Get swift version
# run: swift --version
#
# - name: set up JDK 21
# uses: actions/setup-java@v4
# with:
# java-version: '21'
# distribution: 'temurin'
# cache: gradle
#
# - name: Grant execute permission for gradlew
# run: chmod +x gradlew
#
# - name: Install the Apple certificate and provisioning profile
# env:
# BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
# P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
# BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
# KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
# run: |
# # create variables
# CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
# PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
# KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
#
# # import certificate and provisioning profile from secrets
# echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o "$CERTIFICATE_PATH"
# echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o "$PP_PATH"
#
# # create temporary keychain
# security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
# security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
# security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
#
# # import certificate to keychain
# security import "$CERTIFICATE_PATH" -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH"
# security list-keychain -d user -s "$KEYCHAIN_PATH"
#
# # apply provisioning profile
# mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
# cp "$PP_PATH" ~/Library/MobileDevice/Provisioning\ Profiles
#
# - name: Set Default Scheme
# run: |
# cd ios
# default="ios"
# echo $default | cat >default
# echo Using default scheme: $default
#
# - name: Build
# env:
# scheme: ${{ 'default' }}
# platform: ${{ 'iOS Simulator' }}
# run: |
# cd ios
# # xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959)
# device=`xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//"`
# if [ $scheme = default ]; then scheme=$(cat default); fi
# if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi
# file_to_build=`echo $file_to_build | awk '{$1=$1;print}'`
# xcodebuild build-for-testing -scheme "$scheme" -sdk iphoneos -allowProvisioningUpdates