aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/ohos.yml
blob: 513efc3c84de4980370c13c94e01aac1066d335c (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
95
96
97
98
99
100
101
102
103
104
name: OpenHarmony
on:
  workflow_call:
    inputs:
      profile:
        required: false
        default: "release"
        type: string
  workflow_dispatch:
    inputs:
      profile:
        required: false
        default: "release"
        type: choice
        description: "Cargo build profile"
        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: OpenHarmony Build
    runs-on: ubuntu-22.04
    strategy:
      matrix:
        arch: ['aarch64-unknown-linux-ohos', 'x86_64-unknown-linux-ohos']
    steps:
      - uses: actions/checkout@v4
        if: github.event_name != 'pull_request_target'
        with:
          fetch-depth: 2
      # This is necessary to checkout the pull request if this run was triggered via a
      # `pull_request_target` event.
      - uses: actions/checkout@v4
        if: github.event_name == 'pull_request_target'
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          fetch-depth: 2
      - name: Run sccache-cache
        uses: mozilla-actions/sccache-action@v0.0.4
      - name: Install crown
        run: cargo install --path support/crown
      - name: Bootstrap Python
        run: python3 -m pip install --upgrade pip virtualenv
      - name: Bootstrap dependencies
        run: sudo apt update && python3 ./mach bootstrap --skip-lints
      - name: Setup OpenHarmony SDK
        id: setup_sdk
        uses: openharmony-rs/setup-ohos-sdk@v0.1
        with:
          version: "4.1"
          components: "native;toolchains;ets;js;previewer"
          fixup-path: true
      - name: Install node for hvigor
        uses: actions/setup-node@v4
        with:
          node-version: 18
      - name: Install hvigor modules
        run: |
          mkdir ~/hvigor-installation
          cd ~/hvigor-installation
          echo "@ohos:registry=https://repo.harmonyos.com/npm/" > .npmrc
          npm install "@ohos/hvigor@5" "@ohos/hvigor-ohos-plugin@5"
          echo "HVIGOR_PATH=$PWD" >> $GITHUB_ENV
      - name: "Setup HAP signing config"
        env:
          SIGNING_MATERIAL: ${{ secrets.SERVO_OHOS_SIGNING_MATERIAL }}
        if: ${{ env.SIGNING_MATERIAL != '' }} # Allows the build to pass on forks.
        run: |
          cd ~
          echo "${SIGNING_MATERIAL}" | base64 -d > servo-ohos-material.zip
          unzip servo-ohos-material.zip
          echo "SERVO_OHOS_SIGNING_CONFIG=${PWD}/servo-ohos-material/signing-configs.json" >> $GITHUB_ENV
      - name: Build (arch ${{ matrix.arch }} profile ${{ inputs.profile }})
        env:
          OHOS_SDK_NATIVE: ${{ steps.setup_sdk.outputs.ohos_sdk_native }}
          OHOS_BASE_SDK_HOME: ${{ steps.setup_sdk.outputs.ohos-base-sdk-home }}
        run: |
          python3 ./mach build --locked --target ${{ matrix.arch }} --${{ inputs.profile }}
          cp -r target/cargo-timings target/cargo-timings-ohos-${{ matrix.arch }}
      - name: Archive build timing
        uses: actions/upload-artifact@v4
        with:
          name: cargo-timings-ohos-${{ matrix.arch }}
          # Using a wildcard here ensures that the archive includes the path.
          path: target/cargo-timings-*
      - name: Upload signed HAP artifact
        if: ${{ env.SERVO_OHOS_SIGNING_CONFIG != '' }} # Build output has different name if not signed.
        uses: actions/upload-artifact@v4
        with:
          name: ${{ inputs.profile }}-binary-ohos-${{ matrix.arch }}
          path: target/openharmony/${{ matrix.arch }}/${{ inputs.profile }}/entry/build/default/outputs/default/servoshell-default-signed.hap
      - name: Upload unsigned HAP artifact
        if: ${{ env.SERVO_OHOS_SIGNING_CONFIG == '' }} # Build output has different name if not signed.
        uses: actions/upload-artifact@v4
        with:
          name: ${{ inputs.profile }}-binary-ohos-${{ matrix.arch }}
          path: target/openharmony/${{ matrix.arch }}/${{ inputs.profile }}/entry/build/default/outputs/default/servoshell-default-unsigned.hap