aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/android.yml
blob: efc6e0c364c7d1df8839035973d3b7d6b13c9625 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Android
on:
  workflow_call:
    inputs:
      profile:
        required: false
        default: "release"
        type: string
  workflow_dispatch:
    inputs:
      profile:
        required: false
        default: "release"
        type: choice
        options: ["release", "debug", "production"]

env:
  RUST_BACKTRACE: 1
  SHELL: /bin/bash
  SCCACHE_GHA_ENABLED: "true"
  RUSTC_WRAPPER: "sccache"
  CCACHE: "sccache"
  CARGO_INCREMENTAL: 0

jobs:
  build:
    name: Android Build
    runs-on: ubuntu-22.04
    strategy:
      matrix:
        arch: ['aarch64-linux-android', 'armv7-linux-androideabi', 'i686-linux-android', 'x86_64-linux-android']
    steps:
      - uses: actions/checkout@v4
        if: github.event_name != 'issue_comment' && github.event_name != 'pull_request_target'
        with:
          fetch-depth: 2
      # This is necessary to checkout the pull request if this run was triggered
      # via an `issue_comment` action on a pull request.
      - uses: actions/checkout@v4
        if: github.event_name == 'issue_comment' || github.event_name == 'pull_request_target'
        with:
          ref: refs/pull/${{ github.event.issue.number || github.event.number }}/head
          fetch-depth: 2
      - name: Run sccache-cache
        uses: mozilla-actions/sccache-action@v0.0.4
      - name: Install taplo
        uses: baptiste0928/cargo-install@v3
        with:
          crate: taplo-cli
          locked: true
      - name: Install cargo-deny
        uses: baptiste0928/cargo-install@v3
        with:
          crate: cargo-deny
          locked: true
      - name: Bootstrap Python
        run: python3 -m pip install --upgrade pip virtualenv
      - name: Bootstrap dependencies
        run: sudo apt update && python3 ./mach bootstrap
      - name: Set up JDK 17
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'temurin'
      - name: Setup Android SDK
        uses: android-actions/setup-android@v3
        with:
          packages: 'tools platform-tools platforms;android-33'
      - name: Install Android NDK
        uses: nttld/setup-ndk@v1
        id: setup-ndk
        with:
          ndk-version: r25c
      - name: Build (arch ${{ matrix.arch }} profile ${{ inputs.profile }})
        env:
          ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
        run: |
          python3 ./mach build --locked --android --target ${{ matrix.arch }} --${{ inputs.profile }}
          cp -r target/cargo-timings target/cargo-timings-android-${{ matrix.arch }}
      # TODO: This is disabled since APK crashes during startup.
      # See https://github.com/servo/servo/issues/31134
      # - name: Script tests
      #   run: ./mach test-android-startup
      - name: Archive build timing
        uses: actions/upload-artifact@v4
        with:
          name: cargo-timings-android-${{ matrix.arch }}
          # Using a wildcard here ensures that the archive includes the path.
          path: target/cargo-timings-*
      - name: Upload APK artifact for mach package
        uses: actions/upload-artifact@v4
        with:
          name: ${{ inputs.profile }}-binary-android-${{ matrix.arch }}
          path: target/android/${{ matrix.arch }}/${{ inputs.profile }}/servoapp.apk