From 15f01988a435bf62b5a8534f314bda31d225b030 Mon Sep 17 00:00:00 2001 From: Kyle Harding Date: Fri, 12 Apr 2024 11:45:06 -0400 Subject: [PATCH] Add composite action to test the setup action Change-type: patch Signed-off-by: Kyle Harding --- .github/actions/test/action.yml | 22 ++++++++++++++++++++++ .github/workflows/flowzone.yml | 5 +++++ action.yml | 18 +++++------------- 3 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 .github/actions/test/action.yml diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml new file mode 100644 index 0000000..da5ece9 --- /dev/null +++ b/.github/actions/test/action.yml @@ -0,0 +1,22 @@ +# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action +name: "Test setup of balena CLI" +description: "Test setup of balena CLI composite action" +# this inputs are always provided by flowzone, so they must always be defined on the composite action +inputs: + json: + description: "JSON stringified object containing all the inputs from the calling workflow" + required: true + secrets: + description: "JSON stringified object containing all the secrets from the calling workflow" + required: true + variables: + description: "JSON stringified object containing all the variables from the calling workflow" + required: true +runs: + using: "composite" + steps: + - name: Test setup of balena CLI + uses: ./ + with: + cli-version: latest + balena-token: ${{ fromJSON(inputs.secrets).BALENA_API_KEY }} diff --git a/.github/workflows/flowzone.yml b/.github/workflows/flowzone.yml index e174c8b..a6906eb 100644 --- a/.github/workflows/flowzone.yml +++ b/.github/workflows/flowzone.yml @@ -23,3 +23,8 @@ jobs: github.event_name == 'pull_request_target' ) secrets: inherit + with: + custom_test_matrix: > + { + os: ["ubuntu-latest", "windows-latest", "macos-latest"] + } diff --git a/action.yml b/action.yml index 1cb5063..f417866 100644 --- a/action.yml +++ b/action.yml @@ -11,9 +11,6 @@ inputs: balena-token: description: "balenaCloud API token to login automatically" required: false - # balena-env: - # description: "balenaCloud environment to use" - # required: false # Builds and then runs as separate steps as default GitHub method does not allow passing build args runs: @@ -27,7 +24,7 @@ runs: Linux) echo "slug=linux" >> "${GITHUB_OUTPUT}" ;; Windows) echo "slug=windows" >> "${GITHUB_OUTPUT}" ;; macOS) echo "slug=macOS" >> "${GITHUB_OUTPUT}" ;; - *) echo "Unsupported OS: ${{ runner.os }} ; exit 1 ;; + *) echo "Unsupported OS: ${{ runner.os }}" ; exit 1 ;; esac - name: Check runner Arch @@ -37,7 +34,7 @@ runs: case ${{ runner.arch }} in X64) echo "slug=x64" >> "${GITHUB_OUTPUT}" ;; ARM64) echo "slug=arm64" >> "${GITHUB_OUTPUT}" ;; - *) echo "Unsupported Arch: ${{ runner.arch }} ; exit 1 ;; + *) echo "Unsupported Arch: ${{ runner.arch }}" ; exit 1 ;; esac - name: Check CLI version @@ -53,6 +50,7 @@ runs: *) echo "slug=v${INPUT/v/}" >> "${GITHUB_OUTPUT}" ;; esac + # e.g. https://github.com/balena-io/balena-cli/releases/download/v18.1.9/balena-cli-v18.1.9-linux-arm64-standalone.zip - name: Download balena CLI shell: bash env: @@ -60,26 +58,20 @@ runs: ARCH: ${{ steps.check_arch.outputs.slug }} VERSION: ${{ steps.check_version.outputs.slug }} run: | - curl -fsSL "https://github.com/balena-io/balena-cli/releases/download/v${VERSION}/balena-cli-v${VERSION}-${OS}-${ARCH}-standalone.zip" -o "${{ runner.temp }}/balena-cli.zip" + curl -fsSL "https://github.com/balena-io/balena-cli/releases/download/${VERSION}/balena-cli-${VERSION}-${OS}-${ARCH}-standalone.zip" -o "${{ runner.temp }}/balena-cli.zip" - name: Unpack balena CLI shell: bash env: GITHUB_ACTION_PATH: ${{ github.action_path }} run: | - unzip "${{ runner.temp }}/balena-cli.zip" -d "${GITHUB_ACTION_PATH}/balena-cli" + unzip "${{ runner.temp }}/balena-cli.zip" -d "${GITHUB_ACTION_PATH}" echo "${GITHUB_ACTION_PATH}/balena-cli" >> $GITHUB_PATH - name: Print balena CLI version shell: bash run: balena version - # - name: Setup balena environment - # if: inputs.balena-env != '' - # shell: bash - # run: | - # yq '.balenaUrl = "${{ inputs.balena-env}}"' ~/.balenarc.yml - - name: Login to balenaCloud if: inputs.balena-token != '' shell: bash