Skip to content

vaas-python-ci

vaas-python-ci #310

Workflow file for this run

name: vaas-python-ci
on:
push:
branches:
- main
paths:
- "python/**"
- ".github/workflows/ci-python.yaml"
tags:
- "py*"
pull_request:
branches:
- main
paths:
- "python/**"
- ".github/workflows/ci-python.yaml"
workflow_dispatch:
inputs:
environment:
type: choice
description: "Test environment"
options:
- production
- staging
default: "production"
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ (inputs.environment == 'production' || inputs.environment == null || startsWith(github.ref, 'refs/tags/py')) && secrets.CLIENT_SECRET || secrets.STAGING_CLIENT_SECRET }}
VAAS_URL: ${{ (inputs.environment == 'production' || inputs.environment == null || startsWith(github.ref, 'refs/tags/py')) && 'wss://gateway.production.vaas.gdatasecurity.de' || 'wss://gateway.staging.vaas.gdatasecurity.de' }}
TOKEN_URL: ${{ (inputs.environment == 'production' || inputs.environment == null || startsWith(github.ref, 'refs/tags/py')) && 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token' || 'https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token' }}
VAAS_CLIENT_ID: ${{ secrets.VAAS_CLIENT_ID }}
VAAS_USER_NAME: ${{ secrets.VAAS_USER_NAME }}
VAAS_PASSWORD: ${{ (inputs.environment == 'production' || inputs.environment == null || startsWith(github.ref, 'refs/tags/py')) && secrets.VAAS_PASSWORD || secrets.STAGING_VAAS_PASSWORD }}
jobs:
build-python:
name: Build & Test Python SDK
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
working-directory: python
- name: run tests
run: python -m unittest -v tests/test_*
working-directory: python
- name: install example requirements
run: pip install -r requirements.txt
working-directory: python/examples/VaasExample
- name: run example scan file
env:
SCAN_PATH: "main.py"
run: python main.py
working-directory: python/examples/VaasExample
- name: run example scan url
run: python main_url.py
working-directory: python/examples/VaasExample
- name: extract version
if: startsWith(github.ref, 'refs/tags/py')
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/py}" >> $GITHUB_ENV
echo $RELEASE_VERSION
- name: set version
if: startsWith(github.ref, 'refs/tags/py')
run: |
sed -i "s/version = 0.0.0/version = $RELEASE_VERSION/g" ./python/setup.cfg
cat ./python/setup.cfg
- name: build wheel
run: python -m build
working-directory: python
- name: publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: startsWith(github.ref, 'refs/tags/py')
with:
packages_dir: python/dist
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
- name: Microsoft Teams Notification
uses: skitionek/notify-microsoft-teams@master
if: failure()
with:
webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}
overwrite: "{title: `Failed workflow on for VaaS-SDK ${workflow}`, sections: [{activityTitle: 'build failed', activitySubtitle: `Failed workflow on for VaaS-SDK ${workflow}`, activityImage: 'https://adaptivecards.io/content/cats/3.png'}], themeColor: '#ff0000'}"