Skip to content

Commit

Permalink
pin device to release
Browse files Browse the repository at this point in the history
* build multi-arch image
* ghcr.io images

change-type: patch
  • Loading branch information
ab77 committed Nov 15, 2023
1 parent 4bcd68d commit 070fbfc
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 19 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/flowzone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,25 @@ on:
jobs:
flowzone:
name: Flowzone
if: |
(github.event.pull_request.head.repo.full_name == github.repository && github.event_name == 'pull_request') ||
(github.event.pull_request.head.repo.full_name != github.repository && github.event_name == 'pull_request_target')
if: |
(
github.event.pull_request.head.repo.full_name == github.repository &&
github.event_name == 'pull_request'
) || (
github.event.pull_request.head.repo.full_name != github.repository &&
github.event_name == 'pull_request_target'
)
uses: product-os/flowzone/.github/workflows/flowzone.yml@master
secrets: inherit
with:
repo_config: true
repo_description: "balenaCloud end-to-end tests (autohat)."
docker_images: balena/autohat
docker_images: |
balena/autohat,
ghcr.io/balena-io/autohat
docker_runs_on: >
{
"linux/amd64": ["self-hosted","distro:jammy","platform:linux/amd64"],
"linux/arm64": ["self-hosted","distro:jammy","platform:linux/arm64"]
}
30 changes: 18 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
# --- normalize image architectures
FROM balenalib/aarch64-node:19-bullseye-build AS cli-build-arm64
FROM balenalib/aarch64-python:3-bullseye-build AS qemu-build-arm64
FROM balenalib/aarch64-python:3-bullseye-run AS run-arm64
FROM balenalib/amd64-node:19-bullseye-build AS cli-build-amd64
FROM balenalib/amd64-python:3-bullseye-build AS qemu-build-amd64
FROM balenalib/amd64-python:3-bullseye-run AS run-amd64


# --- build balena-cli
ARG ARCH=amd64
FROM cli-build-${TARGETARCH} AS cli-build

FROM balenalib/${ARCH}-node:19-bullseye-build AS cli-build
ARG TARGETARCH

ARG BALENA_CLI_VERSION=15.2.0
ARG BALENA_CLI_VERSION=v17.4.1

WORKDIR /opt

RUN install_packages unzip

RUN wget -q "https://github.com/balena-io/balena-cli/releases/download/v${BALENA_CLI_VERSION}/balena-cli-v${BALENA_CLI_VERSION}-linux-x64-standalone.zip" \
&& unzip -q "balena-cli-v${BALENA_CLI_VERSION}-linux-x64-standalone.zip" \
&& rm -rf "balena-cli-v${BALENA_CLI_VERSION}-linux-x64-standalone.zip"
RUN set -x; arch=$(echo ${TARGETARCH} | sed 's/amd/x/g') \
&& wget -q "https://github.com/balena-io/balena-cli/releases/download/${BALENA_CLI_VERSION}/balena-cli-${BALENA_CLI_VERSION}-linux-${arch}-standalone.zip" \
&& unzip -q "balena-cli-${BALENA_CLI_VERSION}-linux-${arch}-standalone.zip" \
&& rm -rf "balena-cli-${BALENA_CLI_VERSION}-linux-${arch}-standalone.zip"


# --- build QEMU and Python venv
ARG ARCH=amd64

FROM balenalib/${ARCH}-python:3-bullseye-build AS qemu-build
FROM qemu-build-${TARGETARCH} AS qemu-build

ARG QEMU_VERSION=6.2.0

Expand Down Expand Up @@ -48,9 +56,7 @@ RUN wget -q https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz \


# --- runtime
ARG ARCH=amd64

FROM balenalib/${ARCH}-python:3-bullseye-run
FROM run-${TARGETARCH}

ENV VIRTUAL_ENV=/opt/venv

Expand Down
6 changes: 6 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
target "default" {
platforms = [
"linux/amd64",
"linux/arm64"
]
}
27 changes: 24 additions & 3 deletions resources/resincli.robot
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,28 @@ Get "${device_info}" of device "${device_uuid}"
Process ${result}
[Return] ${result.stdout}

Get "${application_info}" from application "${application_name}"
Get "${application_info}" from fleet "${application_name}"
[Documentation] Available values for argument ${application_info} are:
... ID, APP_NAME, DEVICE_TYPE, ONLINE_DEVICES, DEVICES_LENGTH
&{dictionary} = Create Dictionary ID=1 APP_NAME=2 DEVICE_TYPE=3 ONLINE_DEVICES=4 DEVICES_LENGTH=5
${result} = Run Process balena apps | grep -w "${application_name}" | awk '{print $${dictionary.${application_info}}}' shell=yes
&{dictionary} = Create Dictionary ID=1 APP_NAME=2 SLUG=3 DEVICE_TYPE=4 DEVICES_LENGTH=5 ONLINE_DEVICES=6
${result} = Run Process balena fleets | grep -w "${application_name}" | awk '{print $${dictionary.${application_info}}}' shell=yes
Process ${result}
[Return] ${result.stdout}

# FIXME: needs to select STATUS=success and IS FINAL=true
Get latest release from fleet "${application_name}"
${result} = Run Process balena releases "${application_name}" | head -n 2 | tail -n 1 | awk '{print $2}' shell=yes
Process ${result}
[Return] ${result.stdout}

# FIXME: needs to select STATUS=success and IS FINAL=true
Get previous release from fleet "${application_name}"
${result} = Run Process balena releases "${application_name}" | head -n 3 | tail -n 2 | tail -n 1 | awk '{print $2}' shell=yes
Process ${result}
[Return] ${result.stdout}

Pin device "${device_uuid}" to release "${release_uuid}"
${result} = Run Process balena device pin "${device_uuid}" "${release_uuid}" shell=yes
Process ${result}
[Return] ${result.stdout}

Expand All @@ -100,6 +117,10 @@ Device "${device_uuid}" is offline
${result} = Get "IS ONLINE" of device "${device_uuid}"
Should Contain ${result} false

Device "${device_uuid}" should be running commit ${commit}
${result} = Get "COMMIT" of device "${device_uuid}"
Should Contain ${result} ${commit}

Device "${device_uuid}" log should contain "${value}"
${result} = Run Buffered Process balena logs ${device_uuid} shell=yes
Process ${result}
Expand Down

0 comments on commit 070fbfc

Please sign in to comment.