Add OpenHarmony support to mach and CI (#32507)

* Add ohos to mach

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

* Add OpenHarmony build to CI

* Rename ohos sdk action

I decided to rename the upstream ohos sdk action to
setup-ohos-sdk, making it clearer that is a github
action repository.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

* Remove commented line

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

---------

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
Jonathan Schwender 2024-06-17 13:27:23 +02:00 committed by GitHub
parent bea181f5d5
commit 3381f2a704
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 250 additions and 2 deletions

View file

@ -57,3 +57,10 @@ jobs:
secrets: inherit
with:
profile: ${{ inputs.profile }}
ohos:
if: ${{ inputs.workflow == 'ohos' }}
name: OpenHarmony
uses: ./.github/workflows/ohos.yml
with:
profile: ${{ inputs.profile }}

View file

@ -46,6 +46,13 @@ jobs:
profile: "release"
secrets: inherit
build-ohos:
name: OpenHarmony
if: ${{ github.event_name != 'pull_request' }}
uses: ./.github/workflows/ohos.yml
with:
profile: "release"
build-result:
name: Result
runs-on: ubuntu-latest
@ -56,6 +63,7 @@ jobs:
- "build-mac"
- "build-linux"
- "build-android"
- "build-ohos"
steps:
- name: Merge build timings
uses: actions/upload-artifact/merge@v4

72
.github/workflows/ohos.yml vendored Normal file
View file

@ -0,0 +1,72 @@
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']
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: Bootstrap Python
run: python3 -m pip install --upgrade pip virtualenv
- name: Bootstrap dependencies
run: sudo apt update && python3 ./mach bootstrap
- name: Setup OpenHarmony SDK
id: setup_sdk
uses: openharmony-rs/setup-ohos-sdk@v0.1
with:
version: "4.1"
- name: Build (arch ${{ matrix.arch }} profile ${{ inputs.profile }})
env:
OHOS_SDK_NATIVE: ${{ steps.setup_sdk.outputs.ohos_sdk_native }}
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-*