mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-30 06:47:33 +00:00
detekt sees one file at a time, so it only reports private code and never catch parameters: unused public functions such as getGdriveFolderUri and an unread catch (e: Exception) went through. tools/unused-code reads every module's sources with the Kotlin parser and fails on a non-private declaration or enum entry whose name nothing references (Kotlin, XML, ProGuard rules, Gradle scripts and the Rust JNI side) and on a catch parameter its block never reads. It runs from source as part of detektAll, so the pre-commit hook and CI get it. Remove what it found: the Google Drive folder and other unused preferences, unused DAO queries and trust score helpers, the empty BunkerResponseWorker, RawJson, BunkerPermissionCard, TagItem, TrustScoreChip, Color.light, the desktop normalizePermissionType and D-Bus closeNotification, and the strings only they used. Unused catch parameters are now _.
189 lines
6.4 KiB
YAML
189 lines
6.4 KiB
YAML
name: Test/Build Desktop
|
|
|
|
# Lints, tests and packages the Compose for Desktop signer (:desktop) on every
|
|
# OS it ships for, and uploads the installers so each change can be tried out.
|
|
# desktop-release.yml calls it with the release version. The packaged version
|
|
# itself always comes from amberVersionName in gradle/libs.versions.toml.
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [master]
|
|
paths: &desktop-paths
|
|
- 'desktop/**'
|
|
- 'common/**'
|
|
- 'tools/unused-code/**'
|
|
- 'gradle/**'
|
|
- '*.gradle.kts'
|
|
- 'gradle.properties'
|
|
- '.github/workflows/desktop.yml'
|
|
push:
|
|
# Branches only: tag pushes are built by desktop-release.yml.
|
|
branches: ['**']
|
|
paths: *desktop-paths
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
inputs:
|
|
version:
|
|
description: 'Release version (X.Y.Z) used to name the installers; must match amberVersionName in gradle/libs.versions.toml'
|
|
type: string
|
|
default: ''
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: desktop-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
env:
|
|
RELEASE_VERSION: ${{ inputs.version }}
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Set up JDK 21
|
|
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: 21
|
|
|
|
- name: Cache Gradle
|
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: ${{ runner.os }}-desktop-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'gradle/libs.versions.toml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-desktop-gradle-
|
|
|
|
- name: Create keystore.properties
|
|
run: touch keystore.properties
|
|
|
|
- name: Linter (gradle)
|
|
run: ./gradlew :common:ktlintCheck :common:detektMain :common:detektTest :desktop:ktlintCheck :desktop:detektMain :desktop:detektTest :unusedCode --no-daemon
|
|
|
|
build:
|
|
name: build (${{ matrix.name }})
|
|
needs: lint
|
|
runs-on: ${{ matrix.os }}
|
|
timeout-minutes: 45
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- name: linux-x86_64
|
|
os: ubuntu-latest
|
|
- name: windows-x64
|
|
os: windows-latest
|
|
- name: macos-arm64
|
|
os: macos-latest
|
|
- name: macos-x64
|
|
os: macos-15-intel
|
|
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
persist-credentials: false
|
|
|
|
# The installers bundle this JDK's runtime, so it must be the official
|
|
# Temurin archive (what the eclipse-temurin image that reproduces a
|
|
# release ships), not the runner's preinstalled copy, which differs in
|
|
# jrt-fs.jar. An empty tool cache makes setup-java download it.
|
|
- name: Set up JDK 21
|
|
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6
|
|
env:
|
|
RUNNER_TOOL_CACHE: ${{ runner.temp }}/toolcache
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: 21
|
|
|
|
- name: Cache Gradle
|
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: ${{ runner.os }}-${{ runner.arch }}-desktop-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'gradle/libs.versions.toml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ runner.arch }}-desktop-gradle-
|
|
|
|
- name: Create keystore.properties
|
|
run: touch keystore.properties
|
|
|
|
# Names the installers: the release version, or the commit for CI builds.
|
|
- name: Set installer version
|
|
run: echo "DIST_VERSION=${RELEASE_VERSION:-dev-${GITHUB_SHA::7}}" >> "$GITHUB_ENV"
|
|
|
|
- name: Install Linux packaging tools
|
|
if: runner.os == 'Linux'
|
|
run: sudo apt-get update -qq && sudo apt-get install -y -qq rpm xvfb
|
|
|
|
- name: Test (gradle)
|
|
run: ./gradlew :common:test :desktop:test --no-daemon
|
|
|
|
# .deb/.rpm on Linux, .msi/.exe on Windows (WiX is fetched by the
|
|
# Compose plugin), .dmg on macOS (unsigned).
|
|
- name: Package (gradle)
|
|
run: ./gradlew :desktop:packageDistributionForCurrentOs --no-daemon
|
|
|
|
# Distro-independent bundles from the standalone app image (packageDeb/Rpm
|
|
# build from a temporary one).
|
|
- name: Package AppImage and tar.xz
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
./gradlew :desktop:createDistributable --no-daemon
|
|
desktop/packaging/linux.sh "$DIST_VERSION" dist
|
|
|
|
# Start the AppImage on a virtual display and make sure it is still alive
|
|
# after a while, i.e. it doesn't crash on startup. HOME points at an
|
|
# empty dir so it boots like a first launch.
|
|
- name: Smoke test AppImage
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
export HOME="$RUNNER_TEMP/amber-home" AMBER_DISABLE_TRAY=1 APPIMAGE_EXTRACT_AND_RUN=1
|
|
mkdir -p "$HOME"
|
|
xvfb-run -a dist/Amber-*.AppImage > "$RUNNER_TEMP/amber.log" 2>&1 &
|
|
sleep 30
|
|
cat "$RUNNER_TEMP/amber.log"
|
|
pgrep -f 'usr/lib/amber/bin/Amber' > /dev/null || { echo "::error::Amber exited during startup"; exit 1; }
|
|
pkill -f 'usr/lib/amber/bin/Amber' || true
|
|
|
|
# Name every installer Amber-<version>-<platform>.<ext>: the macOS DMGs
|
|
# of both architectures would otherwise collide in the release.
|
|
- name: Collect installers
|
|
run: |
|
|
mkdir -p dist
|
|
for f in desktop/build/compose/binaries/main/*/*.{deb,rpm,msi,exe,dmg}; do
|
|
[ -e "$f" ] || continue
|
|
cp "$f" "dist/Amber-$DIST_VERSION-${{ matrix.name }}.${f##*.}"
|
|
done
|
|
ls -l dist
|
|
|
|
- name: Upload installers
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
with:
|
|
name: amber-desktop-${{ matrix.name }}
|
|
path: dist/*
|
|
retention-days: 14
|
|
if-no-files-found: error
|
|
|
|
- name: Upload test reports
|
|
if: failure()
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
with:
|
|
name: desktop-test-reports-${{ matrix.name }}
|
|
path: desktop/build/reports
|