Skip to content

Route e2e test to "large-disk" labeled ci-runner #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .ci/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# need to check whether ubuntu22.04 is supported operation system for the self-hosted runners
# https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners#linux
FROM ubuntu:20.04@sha256:0b897358ff6624825fb50d20ffb605ab0eaea77ced0adb8c6a4b756513dec6fc
LABEL maintainer="OpenVINO XAI Toolkit Development Team"

ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG NO_PROXY

# Setup proxies
ENV http_proxy=$HTTP_PROXY
ENV https_proxy=$HTTPS_PROXY
ENV no_proxy=$NO_PROXY

# to ignore interactive setup while running 'apt-get install'
ENV DEBIAN_FRONTEND="noninteractive"

# hadolint ignore=DL3008
RUN apt-get update && apt-get install --no-install-recommends -y \
software-properties-common \
curl \
unzip \
cron \
ffmpeg \
libpython3.10 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# set /tmp folder cleaning schedule at 7PM every day which is older than a day
RUN echo "0 19 * * * find /tmp/* -mtime +1 -exec rm -rf {} \;" >> ./cron_clean_tmp.txt && \
crontab cron_clean_tmp.txt && \
# create a non-root user to run gh actions-runner
adduser --disabled-login cibot


COPY entrypoint.sh /home/cibot
RUN chown cibot:cibot /home/cibot/entrypoint.sh
RUN chmod +x /home/cibot/entrypoint.sh

USER cibot
WORKDIR /home/cibot

RUN mkdir actions-runner && mv entrypoint.sh actions-runner
WORKDIR /home/cibot/actions-runner

ARG ACTIONS_RUNNER_VER=2.317.0
RUN curl -o actions-runner.tar.gz -L https://github.com/actions/runner/releases/download/v${ACTIONS_RUNNER_VER}/actions-runner-linux-x64-${ACTIONS_RUNNER_VER}.tar.gz && \
tar xzf ./actions-runner.tar.gz && rm actions-runner.tar.gz

ENTRYPOINT [ "/bin/bash", "-c" ]

CMD ["/home/cibot/actions-runner/entrypoint.sh"]
30 changes: 30 additions & 0 deletions .ci/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## How to build image

With all possible args

```bash
docker build \
--build-arg HTTP_PROXY="${http_proxy:?}" \
--build-arg HTTPS_PROXY="${https_proxy:?}" \
--build-arg NO_PROXY="${no_proxy:?}" \
--build-arg ACTIONS_RUNNER_VER="$ACTIONS_RUNNER_VER" \
--tag ci-runner/ov-xai:latest .
```

The simplest way using its defaults

```bash
docker build --tag ci-runner/ov-xai:latest .
```

## How to run a container

```bash
docker run -d --rm \
--ipc=host \
-e RUNNER_REPO_URL="https://github.com/openvinotoolkit/openvino_xai" \
-e RUNNER_NAME="ci-runner-ov-xai" \
-e RUNNER_LABELS="hello,labels" \
-e RUNNER_TOKEN= \
ci-runner/ov-xai:latest
```
48 changes: 48 additions & 0 deletions .ci/docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

ACTIONS_RUNNER_VER="2.317.0"
POSITIONAL=()

while [[ $# -gt 0 ]]; do
key="$1"

case $key in
-v|--version)
ACTIONS_RUNNER_VER="$2"
shift # past argument
shift # past value
;;
-h|--help)
DEFAULT="yes"
break
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done

set -- "${POSITIONAL[@]}" # restore positional parameters

if [ "$#" -lt 1 ] || [ "$DEFAULT" == "yes" ]; then
cat << EndofMessage
USAGE: $0 <tag> [Options]
Positional args
<tag> Tag name to be tagged to newly built image
Options
-v|--version Specify actions-runner version
-h|--help Print this message
EndofMessage
exit 0
fi

TAG=$1

docker build \
--build-arg HTTP_PROXY="${http_proxy:?}" \
--build-arg HTTPS_PROXY="${https_proxy:?}" \
--build-arg NO_PROXY="${no_proxy:?}" \
--build-arg ACTIONS_RUNNER_VER="$ACTIONS_RUNNER_VER" \
--tag ci-runner/ov-xai:"$TAG" .
18 changes: 18 additions & 0 deletions .ci/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

if [ -z "${RUNNER_NAME}" ] || [ -z "${RUNNER_LABELS}" ] || [ -z "${RUNNER_TOKEN}" ] || [ -z "${RUNNER_REPO_URL}" ]; then
echo "Missing one or more required environment variables."
echo "repo url(${RUNNER_REPO_URL}), name(${RUNNER_NAME}), labels(${RUNNER_LABELS}), and token are required."
exit 1
fi

./config.sh --url ${RUNNER_REPO_URL} \
--unattended \
--replace \
--labels ${RUNNER_LABELS} \
--name ${RUNNER_NAME} \
--token ${RUNNER_TOKEN}

unset RUNNER_LABELS RUNNER_NAME RUNNER_TOKEN RUNNER_REPO_URL

./run.sh
72 changes: 72 additions & 0 deletions .ci/docker/start-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash

ACTIONS_RUNNER_TAG="latest"
ACTIONS_RUNNER_NAME="ov-xai-ci-runner"
LABELS="large-disk"

POSITIONAL=()

while [[ $# -gt 0 ]]; do
key="$1"

case $key in
-n|--name)
ACTIONS_RUNNER_NAME="$2"
shift # past argument
shift # past value
;;
-l|--labels)
LABELS="$2"
shift # past argument
shift # past value
;;
-t|--tag)
ACTIONS_RUNNER_TAG="$2"
shift # past argument
shift # past value
;;
-h|--help)
DEFAULT="yes"
break
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done

set -- "${POSITIONAL[@]}" # restore positional parameters

if [ "$#" -lt 1 ] || [ "$DEFAULT" == "yes" ]; then
cat << EndofMessage
USAGE: $0 <gh-token> [Options]
Positional args
<gh-token> Github token string
Options
-n|--name Specify actions-runner name to be registered to the repository
-l|--labels Additional label string to set the actions-runner
-t|--tag Specify docker image tag to create container
-h|--help Print this message
EndofMessage
exit 0
fi

GITHUB_TOKEN=$1

docker run -d --rm \
--ipc=host \
-e RUNNER_REPO_URL="https://github.com/openvinotoolkit/openvino_xai" \
-e RUNNER_NAME="$ACTIONS_RUNNER_NAME" \
-e RUNNER_LABELS="$LABELS" \
-e RUNNER_TOKEN="$GITHUB_TOKEN" \
--name "$ACTIONS_RUNNER_NAME" \
ci-runner/ov-xai:"$ACTIONS_RUNNER_TAG"; RET=$?

if [ $RET -ne 0 ]; then
echo "failed to start ci container. $RET"
exit 1
fi

echo "Successfully started ci container - $ACTIONS_RUNNER_NAME"
55 changes: 55 additions & 0 deletions .ci/docker/stop-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
CONTAINER_NAME="ov-xai-ci-runner"
POSITIONAL=()
while [[ $# -gt 0 ]]; do
key="$1"

case $key in
-n|--name)
CONTAINER_NAME="$2"
shift # past argument
shift # past value
;;
-h|--help)
DEFAULT="yes"
break
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done

set -- "${POSITIONAL[@]}" # restore positional parameters

if [ "$#" -lt 1 ] || [ "$DEFAULT" == "yes" ]; then
cat << EndofMessage
USAGE: $0 <github-token> [Options]
Options
-n|--name Specify container ID or name to be stopped
-h|--help Print this message
EndofMessage
exit 0
fi

GITHUB_TOKEN=$1

echo "stopping $CONTAINER_NAME..."

docker inspect "$CONTAINER_NAME"; RET=$?

if [ $RET -eq 0 ]; then
docker exec -it "$CONTAINER_NAME" bash -c \
"./config.sh remove \
--token $GITHUB_TOKEN" ; RET=$?

if [ $RET -ne 0 ]; then
echo "failed to stop the runner. $RET"
exit 1
fi
else
echo "cannot find running $CONTAINER_NAME container"
exit 1
fi
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
uses: ./.github/workflows/pre_merge.yml

E2E-Test:
runs-on: ubuntu-22.04
runs-on: [large-disk]
needs: Sanity-Checks
timeout-minutes: 120
timeout-minutes: 240
# This is what will cancel the job concurrency
concurrency:
group: ${{ github.workflow }}-E2E-${{ github.ref }}
Expand Down
Loading