Skip to content
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
15 changes: 15 additions & 0 deletions .github/docker-build-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"components": [
{
"name": "qubership-testing-platform-python-runner",
"file": "./Dockerfile",
"context": "."
},
{
"name": "qubership-testing-platform-python-runner-transfer",
"file": "docker-transfer/Dockerfile",
"context": "."
}
],
"platforms": "linux/amd64"
}
133 changes: 133 additions & 0 deletions .github/workflows/docker-build-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Build and Publish Release Docker Image
run-name: "Dev build repository: ${{ github.ref_name }} #${{ github.run_number }}"

on:
workflow_dispatch:
inputs:
version_type:
description: 'Version type to release'
type: choice
options:
- 'major'
- 'minor'
- 'patch'
required: true
default: 'patch'

permissions:
contents: write
packages: write

jobs:
load-docker-build-components:
runs-on: ubuntu-latest
outputs:
component: ${{ steps.load_component.outputs.components }}
platforms: ${{ steps.load_component.outputs.platforms }}
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false

- name: Load Docker Configuration
id: load_component
run: |
verify=$(cat "$GITHUB_WORKSPACE/.github/docker-build-config.json" | jq '
def verify_structure:
.components as $components
| .platforms as $platforms
| ($components | type == "array")
and (all($components[]; has("name") and has("file") and has("context")))
and ($platforms | type == "string");
verify_structure
| if . then true else false end
')
if [ ${verify} == 'true' ]; then
echo "✅ $GITHUB_WORKSPACE/.github/docker-build-config.json file is valid"
components=$(jq -c ".components" "$GITHUB_WORKSPACE/.github/docker-build-config.json")
platforms=$(jq -c ".platforms" "$GITHUB_WORKSPACE/.github/docker-build-config.json")
else
echo "❗ $GITHUB_WORKSPACE/.github/docker-build-config.json file is invalid"
echo "❗ $GITHUB_WORKSPACE/.github/docker-build-config.json file is invalid" >> $GITHUB_STEP_SUMMARY
exit 1
fi
echo "components=${components}" >> $GITHUB_OUTPUT
echo "platforms=${platforms}" >> $GITHUB_OUTPUT

docker-build:
needs: [load-docker-build-components]
name: "Build and Publish Docker Image"
permissions:
packages: write
contents: read
outputs:
metadata: "${{ steps.metadata.outputs.result }}"
tags: "${{ steps.prepare_tags.outputs.new_tag }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component: ${{ fromJson(needs.load-docker-build-components.outputs.component) }}
steps:
- name: "Checkout code"
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

- name: "Prepare tags"
id: prepare_tags
run: |
echo "Check current tag"
git fetch --tags
TAG=$(git tag --list 'v*' --sort=-v:refname | tr -d '\r' | head -n 1)
TAG=${TAG#v}
echo "Current tag: $TAG"

if [[ -z "$TAG" ]]; then
NEW_TAG="1.0.0"
else
MAJOR=$(echo "$TAG" | cut -d. -f1)
MINOR=$(echo "$TAG" | cut -d. -f2)
PATCH=$(echo "$TAG" | cut -d. -f3)
if [ "$version_type" == "major" ]; then
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
elif [ "$version_type" == "minor" ]; then
MINOR=$((MINOR + 1))
PATCH=0
else
PATCH=$((PATCH + 1))
fi
NEW_TAG="$MAJOR.$MINOR.$PATCH"
fi

echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
echo "New version will be: $NEW_TAG"

- name: "Summary step"
run: |
echo "**Tags:** ${{ steps.prepare_tags.outputs.new_tag }}" >> $GITHUB_STEP_SUMMARY

- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
submodules: recursive

- name: Build and Publish Docker Image
uses: netcracker/qubership-workflow-hub/actions/docker-action@396774180000abdb825cbf150b56cc59c6913db8 #v2.0.5
with:
ref: ${{ github.ref }}
component: ${{ toJson(matrix.component) }}
platforms: ${{ needs.load-docker-build-components.outputs.platforms }}
dry-run: false
tags: v${{ steps.prepare_tags.outputs.new_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

github-release:
needs: [docker-build]
if: ${{ needs.docker-build.result == 'success' }}
uses: netcracker/qubership-workflow-hub/.github/workflows/release-drafter.yml@396774180000abdb825cbf150b56cc59c6913db8 #v2.0.5
with:
version: ${{ needs.docker-build.outputs.tags }}
publish: true
105 changes: 105 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Build and Publish Docker Image

on:
push:
branches-ignore:
- "**release*"
- "prettier/**"
- "dependabot/**"
paths-ignore:
- "docs/**"
- "README.md"
- ".github/**"
workflow_dispatch: {}
pull_request:
branches: [main]
types:
[opened, reopened, synchronize]

permissions: {}

jobs:
load-docker-build-components:
runs-on: ubuntu-latest
outputs:
component: ${{ steps.load_component.outputs.components }}
platforms: ${{ steps.load_component.outputs.platforms }}
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false

- name: Load Docker Configuration
id: load_component
run: |
verify=$(cat "$GITHUB_WORKSPACE/.github/docker-build-config.json" | jq '
def verify_structure:
.components as $components
| .platforms as $platforms
| ($components | type == "array")
and (all($components[]; has("name") and has("file") and has("context")))
and ($platforms | type == "string");
verify_structure
| if . then true else false end
')
if [ ${verify} == 'true' ]; then
echo "✅ $GITHUB_WORKSPACE/.github/docker-build-config.json file is valid"
components=$(jq -c ".components" "$GITHUB_WORKSPACE/.github/docker-build-config.json")
platforms=$(jq -c ".platforms" "$GITHUB_WORKSPACE/.github/docker-build-config.json")
else
echo "❗ $GITHUB_WORKSPACE/.github/docker-build-config.json file is invalid"
echo "❗ $GITHUB_WORKSPACE/.github/docker-build-config.json file is invalid" >> $GITHUB_STEP_SUMMARY
exit 1
fi
echo "components=${components}" >> $GITHUB_OUTPUT
echo "platforms=${platforms}" >> $GITHUB_OUTPUT

build-and-push:
permissions:
contents: read
packages: write
security-events: write
pull-requests: write
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component: ${{ fromJson(needs.load-docker-build-components.outputs.component) }}
needs: [ load-docker-build-components ]
steps:
- name: Checkout Repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

- name: Replace slash in service branch
id: replace_slash
run: |
service_branch="$GITHUB_REF_NAME"

if [[ "$service_branch" == *"/"* ]]; then
service_branch="${service_branch//\//_}"
fi
echo "Branch is: $service_branch"
echo "SERVICE_BRANCH=$service_branch" >> $GITHUB_ENV

- name: Metadata
id: metadata
uses: netcracker/qubership-workflow-hub/actions/metadata-action@396774180000abdb825cbf150b56cc59c6913db8 #v2.0.5
with:
default-template: '{{ref-name}}-{{timestamp}}'

- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
submodules: recursive

- name: Build and Publish Docker Image
uses: netcracker/qubership-workflow-hub/actions/docker-action@396774180000abdb825cbf150b56cc59c6913db8 #v2.0.5
with:
ref: ${{ github.ref }}
tags: ${{steps.metadata.outputs.result}}, ${{ env.SERVICE_BRANCH }}_latest
component: ${{ toJson(matrix.component) }}
platforms: ${{ needs.load-docker-build-components.outputs.platforms }}
dry-run: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "scripts"]
path = scripts
url = https://github.com/Netcracker/qubership-testing-platform-common-scripts
53 changes: 28 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
FROM debian:trixie-slim
FROM python:3.14-alpine3.22

ENV HOME_EX=/app

RUN groupadd -g 1007 runner && \
useradd -u 1007 -g runner -d "$HOME_EX" -s /bin/bash runner && \
mkdir -p "$HOME_EX" && \
chown -R runner:runner "$HOME_EX"

WORKDIR $HOME_EX

COPY requirements.txt $HOME_EX/requirements.txt

RUN set -eux; \
apt-get update && \
apt-get install -y --no-install-recommends \
curl=8.14.1-2 \
wget=1.25.0-2 \
bash=5.2.37-2+b5 \
unzip=6.0-29 \
nano=8.4-1 \
inotify-tools=4.23.9.0-2+b1 \
jq=1.7.1-6+deb13u1 \
python3=3.13.5-1 \
python3-pip=25.1.1+dfsg-1 \
python3-requests=2.32.3+dfsg-5 \
python3-urllib3=2.3.0-3 \
python3-certifi=2025.1.31+ds-1 && \
RUN echo "https://dl-cdn.alpinelinux.org/alpine/v3.22/community/" >/etc/apk/repositories && \
echo "https://dl-cdn.alpinelinux.org/alpine/v3.22/main/" >>/etc/apk/repositories && \
apk add --update --no-cache --no-check-certificate \
curl=8.14.1-r2 \
wget=1.25.0-r1 \
bash=5.2.37-r0 \
unzip=6.0-r15 \
nano=8.4-r0 \
inotify-tools=4.23.9.0-r0 \
jq=1.8.1-r0 \
build-base=0.5-r3 \
python3-dev=3.12.12-r0 \
musl-dev=1.2.5-r10 \
libffi-dev=3.4.8-r0 \
py3-requests=2.32.5-r0 \
py3-urllib3=1.26.20-r1 \
py3-certifi=2025.4.26-r0 && \
rm -rf /var/lib/apt/lists/*

RUN wget -q -O /tmp/s5cmd.tar.gz \
Expand All @@ -35,6 +28,15 @@ RUN wget -q -O /tmp/s5cmd.tar.gz \
chmod +x /usr/local/bin/s5cmd && \
rm -rf /tmp/s5cmd*

RUN addgroup -g 1007 runner && \
adduser -u 1007 -G runner -D -h "$HOME_EX" runner && \
mkdir -p "$HOME_EX" && \
chown -R runner:runner "$HOME_EX"

WORKDIR $HOME_EX

COPY requirements.txt $HOME_EX/requirements.txt

RUN pip install --no-cache-dir --break-system-packages -r requirements.txt \
--timeout=120

Expand All @@ -46,3 +48,4 @@ COPY --chown=runner:runner --chmod=755 entrypoint.sh $HOME_EX/entrypoint.sh
USER 1007

ENTRYPOINT ["/app/entrypoint.sh"]

Loading
Loading