Skip to content

Build Runner

Build Runner #69

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
# This is Test CI Pipeline against Performance environment when merging to main
name: Build Runner
on:
workflow_run:
workflows: ["AAA"]
types:
- completed
workflow_dispatch:
# on:
# push:
# branches: [ main ]
# Ensures that only one deploy task per branch/environment will run at a time.
concurrency:
group: performance-environment
cancel-in-progress: false
jobs:
pypi_upload:
name: pypi_upload
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: 🔨 Build and publish distribution 📦 to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
python setup.py sdist bdist_wheel
twine upload dist/*
pypi_validate:
name: pypi_validate
needs: [pypi_upload]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Validate upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
echo '⌛ Wait till package will be updated in PyPI'
# Verify and wait till latest benchmark-runner version will be updated in Pypi (timeout 900 seconds)
timeout=900
sleep_time=30
pip --no-cache-dir install setuptools benchmark-runner --upgrade
expected_version=$(python3 setup.py --version)
build=$(pip freeze | grep benchmark-runner | sed 's/==/=/g')
actual_version="$(cut -d'=' -f2 <<<"$build")"
current_wait_time=0
while [[ $current_wait_time < $timeout ]]; do
if [[ "$expected_version" = "$actual_version" ]]; then
echo 'benchmark runner version: ' $expected_version 'was updated in Pypi'
break;
else
# sleep for x seconds
echo 'wait' "$((current_wait_time+sleep_time))" 'seconds'
sleep $sleep_time
current_wait_time="$((current_wait_time+sleep_time))"
pip --no-cache-dir install benchmark-runner --upgrade
build=$(pip freeze | grep benchmark-runner | sed 's/==/=/g')
actual_version="$(cut -d'=' -f2 <<<"$build")"
if (( $current_wait_time == $timeout )); then
echo "Benchamrk runner lastet version did not update in Pypi after 900 seconds - raise failure"
exit 1
fi
fi
done
private_quay_upload:
name: private_quay_upload
needs: [ pypi_upload, pypi_validate]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: ⌛ Build and Upload 🐋 to quay.io
run: |
pip install setuptools
version=$(python3 setup.py --version)
sudo docker build --build-arg VERSION=$version -t ${{ secrets.QUAY_PRIVATE_BENCHMARK_RUNNER_REPOSITORY }}:v$version .
sudo docker build --build-arg VERSION=latest -t ${{ secrets.QUAY_PRIVATE_BENCHMARK_RUNNER_REPOSITORY }}:latest .
sudo docker login quay.io -u ${{ secrets.QUAY_ROBOT_USER }} -p ${{ secrets.QUAY_ROBOT_PASSWORD }}
sudo docker push ${{ secrets.QUAY_PRIVATE_BENCHMARK_RUNNER_REPOSITORY }}:v$version
sudo docker push ${{ secrets.QUAY_PRIVATE_BENCHMARK_RUNNER_REPOSITORY }}:latest
echo '⌛ Wait 30 sec till image will be updated in quay.io'
sleep 30
public_quay_upload:
name: public_quay_upload
needs: [ pypi_upload, pypi_validate ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: ⌛ Build and Upload 🐋 to quay.io
run: |
sudo docker build --build-arg VERSION=latest -t ${{ secrets.QUAY_BENCHMARK_RUNNER_REPOSITORY }}:latest .
sudo docker login quay.io -u ${{ secrets.QUAY_ROBOT_BENCHMARK_RUNNER_USER }} -p ${{ secrets.QUAY_ROBOT_BENCHMARK_RUNNER_PASSWORD }}
sudo docker push ${{ secrets.QUAY_BENCHMARK_RUNNER_REPOSITORY }}:latest
echo '⌛ Wait 30 sec till image will be updated in quay.io'
sleep 30
bump_version:
name: bump_version
needs: [pypi_upload, pypi_validate, private_quay_upload, public_quay_upload]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: ⚙ Set START CI TIME
run: echo "START_CI=${{ needs.test.outputs.start_time_output }}" >> "$GITHUB_ENV"
- name: Install latest benchmark-runner
run: |
python -m pip install --upgrade pip
pip install benchmark-runner
- name: ⚙️ Set Kubeconfig
env:
KUBECONFIG: ${{ secrets.PERF_KUBECONFIG }}
RUNNER_PATH: ${{ secrets.RUNNER_PATH }}
run: |
mkdir -p "$RUNNER_PATH/.kube/"
echo "$KUBECONFIG" > "$RUNNER_PATH/.kube/config"
echo "KUBECONFIG_PATH=$RUNNER_PATH/.kube/config" >> "$GITHUB_ENV"
- name: 🎁 Bump Version
run: |
pip install setuptools bumpversion
version=$(python3 setup.py --version)
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git config pull.rebase false # merge (the default strategy)
bumpversion patch
# GITHUB_REPOSITORY already taken => GIT_REPOSITORY
git commit .bumpversion.cfg setup.py -m 'bump version to exist version v'$version
git push
git push --tag