From 800ea548621d5aebd5f095a8fd482cc17c3b5c28 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Sat, 5 Oct 2024 22:45:49 +0200 Subject: [PATCH 1/2] Refactor github outputs into install script This allows removing some globbing in favor of the respective variables. Signed-off-by: Jonathan Schwender --- action.yml | 32 +++++--------------------------- install_ohos_sdk.sh | 24 +++++++++++++++++++++++- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/action.yml b/action.yml index 785c3a4..e1b2cc5 100644 --- a/action.yml +++ b/action.yml @@ -24,19 +24,19 @@ inputs: outputs: sdk-path: description: "Root directory of the OpenHarmony SDK installation" - value: ${{ steps.set_outputs.outputs.sdk-path }} + value: ${{ steps.install_ohos_sdk.outputs.sdk-path }} ohos_sdk_native: description: "The `native` directory inside the OpenHarmony SDK" - value: ${{ steps.set_outputs.outputs.ohos_sdk_native }} + value: ${{ steps.install_ohos_sdk.outputs.ohos_sdk_native }} sdk-version: description: "Specific version of the OpenHarmony SDK (e.g. 4.1.7.5)" - value: ${{ steps.set_outputs.outputs.sdk-version }} + value: ${{ steps.install_ohos_sdk.outputs.sdk-version }} api-version: description: "OpenHarmony API version of the SDK" - value: ${{ steps.set_outputs.outputs.api-version }} + value: ${{ steps.install_ohos_sdk.outputs.api-version }} ohos-base-sdk-home: description: "Path to the OpenHarmony SDK for the host platform" - value: ${{ steps.set_outputs.outputs.ohos-base-sdk-home }} + value: ${{ steps.install_ohos_sdk.outputs.ohos-base-sdk-home }} runs: using: "composite" steps: @@ -66,26 +66,4 @@ runs: INPUT_FIXUP_PATH: ${{ inputs.fixup-path }} INPUT_MIRROR: "${{ inputs.mirror }}" GH_TOKEN: "${{ github.token }}" - - name: Set Outputs - id: set_outputs - shell: bash - env: - INPUT_FIXUP_PATH: ${{ inputs.fixup-path }} - run: | - echo "sdk-path=$HOME/ohos-sdk" >> "$GITHUB_OUTPUT" - OHOS_BASE_SDK_HOME=$(cd $HOME/ohos-sdk/*/ && pwd) - if [ "${INPUT_FIXUP_PATH}" = "true" ]; then - OHOS_SDK_NATIVE="$(cd $HOME/ohos-sdk/*/*/native && pwd)" - else - OHOS_SDK_NATIVE="$(cd $HOME/ohos-sdk/*/native && pwd)" - fi - cd "${OHOS_SDK_NATIVE}" - SDK_VERSION="$(jq -r .version < oh-uni-package.json )" - API_VERSION="$(jq -r .apiVersion < oh-uni-package.json )" - echo "OHOS_BASE_SDK_HOME=${OHOS_BASE_SDK_HOME}" >> "$GITHUB_ENV" - echo "ohos-base-sdk-home=${OHOS_BASE_SDK_HOME}" >> "$GITHUB_OUTPUT" - echo "OHOS_SDK_NATIVE=${OHOS_SDK_NATIVE}" >> "$GITHUB_ENV" - echo "ohos_sdk_native=${OHOS_SDK_NATIVE}" >> "$GITHUB_OUTPUT" - echo "sdk-version=${SDK_VERSION}" >> "$GITHUB_OUTPUT" - echo "api-version=${API_VERSION}" >> "$GITHUB_OUTPUT" diff --git a/install_ohos_sdk.sh b/install_ohos_sdk.sh index db837cf..c3a3d7e 100755 --- a/install_ohos_sdk.sh +++ b/install_ohos_sdk.sh @@ -27,7 +27,9 @@ else exit 1 fi -cd "${HOME}" +WORK_DIR="${HOME}/setup-ohos-sdk" +mkdir -p "${WORK_DIR}" +cd "${WORK_DIR}" MIRROR_DOWNLOAD_SUCCESS=false if [[ "${INPUT_MIRROR}" == "true" || "${INPUT_MIRROR}" == "force" ]]; then @@ -69,6 +71,7 @@ else fi rm "${OS_FILENAME}" "${OS_FILENAME}.sha256" cd ohos-sdk +echo "sdk-path=$PWD" >> "${GITHUB_OUTPUT}" if [[ "${OS}" == "linux" ]]; then rm -rf windows @@ -80,11 +83,15 @@ else cd darwin fi +OHOS_BASE_SDK_HOME="$PWD" + IFS=";" read -ra COMPONENTS <<< "${INPUT_COMPONENTS}" for COMPONENT in "${COMPONENTS[@]}" do echo "Extracting component ${COMPONENT}" + echo "::group::Unzipping archive" unzip "${COMPONENT}"-*.zip + echo "::endgroup::" API_VERSION=$(cat "${COMPONENT}/oh-uni-package.json" | jq -r '.apiVersion') if [ "$INPUT_FIXUP_PATH" = "true" ]; then mkdir -p "${API_VERSION}" @@ -92,3 +99,18 @@ do fi done rm ./*.zip + +if [ "${INPUT_FIXUP_PATH}" = "true" ]; then + OHOS_SDK_NATIVE="${OHOS_BASE_SDK_HOME}/${API_VERSION}/native" +else + OHOS_SDK_NATIVE="${OHOS_BASE_SDK_HOME}/native" +fi +cd "${OHOS_SDK_NATIVE}" +SDK_VERSION="$(jq -r .version < oh-uni-package.json )" +API_VERSION="$(jq -r .apiVersion < oh-uni-package.json )" +echo "OHOS_BASE_SDK_HOME=${OHOS_BASE_SDK_HOME}" >> "$GITHUB_ENV" +echo "ohos-base-sdk-home=${OHOS_BASE_SDK_HOME}" >> "$GITHUB_OUTPUT" +echo "OHOS_SDK_NATIVE=${OHOS_SDK_NATIVE}" >> "$GITHUB_ENV" +echo "ohos_sdk_native=${OHOS_SDK_NATIVE}" >> "$GITHUB_OUTPUT" +echo "sdk-version=${SDK_VERSION}" >> "$GITHUB_OUTPUT" +echo "api-version=${API_VERSION}" >> "$GITHUB_OUTPUT" From 926ef6a0445166179d0ec8618f9e830f3eddb2d6 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Sun, 6 Oct 2024 14:10:06 +0200 Subject: [PATCH 2/2] Add build-result job for CI Signed-off-by: Jonathan Schwender --- .github/workflows/workflow.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 4dd3939..0957d9e 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -59,3 +59,17 @@ jobs: API_VERSION: "${{ steps.sdk-with-fixup.outputs.api-version }}" run: | ${SDK_PATH}/*/${API_VERSION}/native/llvm/bin/clang --version + + + build_result: + name: Result + runs-on: ubuntu-latest + needs: ["build"] + if: ${{ always() }} + steps: + - name: Mark the job as successful + if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} + run: exit 0 + - name: Mark the job as unsuccessful + if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} + run: exit 1 \ No newline at end of file