|
| 1 | +name: PR CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + types: |
| 8 | + - opened |
| 9 | + - synchronize |
| 10 | + - reopened |
| 11 | + - ready_for_review |
| 12 | + push: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + merge_group: |
| 16 | + workflow_dispatch: |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: pr-ci-${{ github.event.pull_request.number || github.ref }} |
| 23 | + cancel-in-progress: true |
| 24 | + |
| 25 | +jobs: |
| 26 | + build-and-test: |
| 27 | + if: github.event_name != 'pull_request' || !github.event.pull_request.draft |
| 28 | + strategy: |
| 29 | + fail-fast: false |
| 30 | + matrix: |
| 31 | + os: |
| 32 | + - ubuntu-latest |
| 33 | + - windows-latest |
| 34 | + - macos-15 |
| 35 | + - macos-15-intel |
| 36 | + |
| 37 | + runs-on: ${{ matrix.os }} |
| 38 | + name: Build and test (${{ matrix.os }}) |
| 39 | + |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - uses: dtolnay/rust-toolchain@stable |
| 44 | + |
| 45 | + - name: Use crates.io in CI |
| 46 | + shell: bash |
| 47 | + run: | |
| 48 | + mkdir -p .cargo |
| 49 | + cat > .cargo/config.toml <<'EOF' |
| 50 | + [registries.crates-io] |
| 51 | + protocol = "sparse" |
| 52 | +
|
| 53 | + [net] |
| 54 | + git-fetch-with-cli = true |
| 55 | + EOF |
| 56 | +
|
| 57 | + - name: Cache cargo artifacts |
| 58 | + uses: Swatinem/rust-cache@v2 |
| 59 | + |
| 60 | + - name: Install Linux dependencies |
| 61 | + if: runner.os == 'Linux' |
| 62 | + run: | |
| 63 | + sudo apt-get update |
| 64 | + sudo apt-get install -y \ |
| 65 | + libayatana-appindicator3-dev \ |
| 66 | + libgtk-3-dev \ |
| 67 | + libxdo-dev \ |
| 68 | + libxkbcommon-dev \ |
| 69 | + libxcb-render0-dev \ |
| 70 | + libxcb-shape0-dev \ |
| 71 | + libxcb-xfixes0-dev \ |
| 72 | + libssl-dev \ |
| 73 | + pkg-config |
| 74 | +
|
| 75 | + - name: Run library tests |
| 76 | + run: cargo test --release --locked --lib |
| 77 | + |
| 78 | + - name: Build app binary |
| 79 | + run: cargo build --release --locked --bin linuxdo-accelerator |
| 80 | + |
| 81 | + build-android: |
| 82 | + if: github.event_name != 'pull_request' || !github.event.pull_request.draft |
| 83 | + strategy: |
| 84 | + fail-fast: false |
| 85 | + matrix: |
| 86 | + include: |
| 87 | + - abi: arm64-v8a |
| 88 | + rust_target: aarch64-linux-android |
| 89 | + - abi: x86_64 |
| 90 | + rust_target: x86_64-linux-android |
| 91 | + |
| 92 | + runs-on: ubuntu-latest |
| 93 | + name: Build Android APK (${{ matrix.abi }}) |
| 94 | + |
| 95 | + steps: |
| 96 | + - uses: actions/checkout@v4 |
| 97 | + |
| 98 | + - uses: actions/setup-java@v4 |
| 99 | + with: |
| 100 | + distribution: temurin |
| 101 | + java-version: "17" |
| 102 | + |
| 103 | + - uses: android-actions/setup-android@v3 |
| 104 | + |
| 105 | + - uses: gradle/actions/setup-gradle@v4 |
| 106 | + |
| 107 | + - uses: dtolnay/rust-toolchain@stable |
| 108 | + with: |
| 109 | + targets: ${{ matrix.rust_target }} |
| 110 | + |
| 111 | + - name: Use crates.io in CI |
| 112 | + shell: bash |
| 113 | + run: | |
| 114 | + mkdir -p .cargo |
| 115 | + cat > .cargo/config.toml <<'EOF' |
| 116 | + [registries.crates-io] |
| 117 | + protocol = "sparse" |
| 118 | +
|
| 119 | + [net] |
| 120 | + git-fetch-with-cli = true |
| 121 | + EOF |
| 122 | +
|
| 123 | + - name: Cache cargo artifacts |
| 124 | + uses: Swatinem/rust-cache@v2 |
| 125 | + |
| 126 | + - name: Install Android SDK / NDK |
| 127 | + shell: bash |
| 128 | + run: | |
| 129 | + yes | sdkmanager --licenses > /dev/null || true |
| 130 | + sdkmanager --install \ |
| 131 | + "platform-tools" \ |
| 132 | + "platforms;android-35" \ |
| 133 | + "build-tools;35.0.0" \ |
| 134 | + "ndk;27.2.12479018" |
| 135 | +
|
| 136 | + - name: Install cargo-ndk |
| 137 | + run: cargo install cargo-ndk --locked |
| 138 | + |
| 139 | + - name: Build Android APK |
| 140 | + shell: bash |
| 141 | + env: |
| 142 | + ANDROID_ABI: ${{ matrix.abi }} |
| 143 | + RUST_TARGET: ${{ matrix.rust_target }} |
| 144 | + ANDROID_BUILD_TYPE: release |
| 145 | + APK_OUTPUT_NAME: linuxdo-accelerator-${{ matrix.abi }}.apk |
| 146 | + run: | |
| 147 | + export ANDROID_NDK_HOME="${ANDROID_SDK_ROOT}/ndk/27.2.12479018" |
| 148 | + ./scripts/build-android-apk.sh |
0 commit comments