Litmus and cluster events deprecation #933
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
pull_request: | |
permissions: | |
# https://github.community/t/permissions-nesecary-to-comment-on-a-pr/179047/5 | |
pull-requests: write | |
contents: write | |
jobs: | |
build: | |
name: Build & Test | |
strategy: | |
matrix: | |
#python-version: [ '3.9', '3.10', 'pypy3.9' ] | |
python-version: [ '3.9' ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create multi-node KinD cluster | |
uses: redhat-chaos/actions/kind@main | |
- name: get nodes | |
run: | | |
kubectl get nodes | |
- name: Install Helm & add repos | |
run: | | |
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash | |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts | |
helm repo add stable https://charts.helm.sh/stable | |
helm repo update | |
- name: Deploy prometheus | |
run: | | |
# nodePort mapping 30000 -> http://localhost:9090 | |
kubectl create namespace monitoring | |
helm install \ | |
--wait --timeout 360s \ | |
kind-prometheus \ | |
prometheus-community/kube-prometheus-stack \ | |
--namespace monitoring \ | |
--set prometheus.service.nodePort=30000 \ | |
--set prometheus.service.type=NodePort \ | |
--set grafana.service.nodePort=31000 \ | |
--set grafana.service.type=NodePort \ | |
--set alertmanager.service.nodePort=32000 \ | |
--set alertmanager.service.type=NodePort \ | |
--set prometheus-node-exporter.service.nodePort=32001 \ | |
--set prometheus-node-exporter.service.type=NodePort | |
- name: Deploy Elasticsearch | |
env: | |
ELASTIC_URL: ${{ vars.ELASTIC_URL }} | |
ELASTIC_PORT: ${{ vars.ELASTIC_PORT }} | |
ELASTIC_USER: ${{ vars.ELASTIC_USER }} | |
ELASTIC_PASSWORD: ${{ vars.ELASTIC_PASSWORD }} | |
run: | | |
echo "ELASTIC_URL: ${ELASTIC_URL}" | |
echo "ELASTIC_PORT: ${ELASTIC_PORT}" | |
echo "ELASTIC_USER: ${ELASTIC_USER}" | |
echo "ELASTIC_PASSWORD:${ELASTIC_PASSWORD}" | |
# nodePort mapping 32766 -> http://localhost:9091 | |
helm install \ | |
--wait --timeout 360s \ | |
elasticsearch \ | |
oci://registry-1.docker.io/bitnamicharts/elasticsearch \ | |
--set master.masterOnly=false \ | |
--set master.replicaCount=1 \ | |
--set data.replicaCount=0 \ | |
--set coordinating.replicaCount=0 \ | |
--set ingest.replicaCount=0 \ | |
--set service.type=NodePort \ | |
--set service.nodePorts.restAPI=32766 \ | |
--set security.elasticPassword=test \ | |
--set security.enabled=true \ | |
--set image.tag=7.17.23-debian-12-r0 \ | |
--set security.tls.autoGenerated=true | |
- name: Check out code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Update version number | |
run: | | |
# always replaces the version with the latest tag | |
# both for testing and version release | |
sed -i -e "s/0.0.0/$(git describe --tags --abbrev=0 | sed 's/^v//')/" pyproject.toml | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Check isort, black, and flake8 | |
run: | | |
pip install black flake8 isort | |
isort --profile black . | |
black --line-length 79 . | |
flake8 . | |
curl -sSL https://install.python-poetry.org | python3 - | |
- name: Install project dependencies | |
run: poetry install --no-interaction | |
- name: Run tests with coverage | |
env: | |
API_USER: ${{ secrets.API_USER }} | |
API_PASSWORD: ${{ secrets.API_PASSWORD }} | |
BUCKET_NAME: ${{ secrets.BUCKET_NAME }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
ELASTIC_URL: ${{ vars.ELASTIC_URL }} | |
ELASTIC_PORT: ${{ vars.ELASTIC_PORT }} | |
ELASTIC_USER: ${{ vars.ELASTIC_USER }} | |
ELASTIC_PASSWORD: ${{ vars.ELASTIC_PASSWORD }} | |
run: | | |
export TEST_WORKDIR=`pwd`/`date +%s` | |
mkdir $TEST_WORKDIR | |
poetry run python3 -m coverage run -a -m unittest discover -v src/krkn_lib/tests/ | |
poetry run python3 -m coverage html | |
poetry run python3 -m coverage json | |
- name: Publish coverage report to job summary | |
if: ${{ matrix.python-version == '3.9'}} | |
run: | | |
poetry run html2text --ignore-images --ignore-links -b 0 htmlcov/index.html >> $GITHUB_STEP_SUMMARY | |
- name: Build | |
run: poetry build | |
- name: Upload json coverage | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage.json | |
path: coverage.json | |
if-no-files-found: error | |
- name: Upload dist artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist | |
path: dist | |
if-no-files-found: error | |
- name: Upload coverage HTML artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage | |
path: htmlcov | |
if-no-files-found: error | |
doc: | |
name: Generate and Publish Docs | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Check out doc repo | |
uses: actions/checkout@master | |
with: | |
repository: krkn-chaos/krkn-lib-docs | |
path: krkn-lib-docs | |
ssh-key: ${{ secrets.KRKN_LIB_DOCS_PRIV_KEY }} | |
- name: Download json coverage | |
uses: actions/download-artifact@v3 | |
with: | |
name: coverage.json | |
- name: Update version number | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
sed -i -e "s/0.0.0/${GITHUB_REF##*/}/" pyproject.toml | |
sed -i -e "s/0.0.0/${GITHUB_REF##*/}/" ./docs/conf.py | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
- name: Install project dependencies | |
run: poetry install --no-interaction | |
- name: Generate documentation | |
run: | | |
poetry run sphinx-apidoc -o docs/ -f -a -e src/krkn_lib --doc-project "Krkn Foundation Library" | |
poetry run make -C docs html | |
- name: Copy documentation on GitHub Page Repo | |
env: | |
COLOR: red | |
run: | | |
find krkn-lib-docs/ -type f ! -name 'index.html' -type d ! -name '.git' -delete | |
cp -R docs/build/html/* krkn-lib-docs | |
# generate coverage badge on previously calculated total coverage | |
# and copy in the docs page | |
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") | |
[[ $TOTAL > 70 ]] && COLOR=green | |
echo "TOTAL: $TOTAL" | |
echo "COLOR: $COLOR" | |
curl "https://img.shields.io/badge/coverage-$TOTAL%25-$COLOR" > ./krkn-lib-docs/coverage_badge.svg | |
- name: Push updated HTML documentation | |
run: | | |
cd krkn-lib-docs | |
git add . | |
git config user.name "krkn-chaos" | |
git config user.email "<>" | |
git commit -m "[KRKN LIB] API documentation ${GITHUB_REF##*/}" || true | |
git push | |
publish: | |
name: Publish Library on PyPi | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist | |
path: dist | |
- name: Install twine | |
run: pip install -U twine | |
- name: Publish | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{secrets.PYPI_TOKEN}} | |
TWINE_NON_INTERACTIVE: true | |
run: twine upload dist/* | |
build_krkn: | |
name: Build Krkn Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Rebuild krkn | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
uses: redhat-chaos/actions/krkn@main | |
with: | |
QUAY_USER: ${{ secrets.RH_USERNAME }} | |
QUAY_TOKEN: ${{ secrets.RH_PASSWORD }} |