Skip to content

Setting up the OCA TypeQL Schema #411

Setting up the OCA TypeQL Schema

Setting up the OCA TypeQL Schema #411

name: Stix ORM
on:
push:
branches:
- '*'
pull_request:
branches:
jobs:
build:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
# Service containers to run with `container-job`
services:
# Label used to access the service container
typedb:
# Docker Hub image
image: vaticle/typedb
# Set health checks to wait until vaticle typedb has started
ports: ['1729:1729']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
poetry run flake8 . --count --exit-zero --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --format=html --htmldir=flake8_report
- name: Run Bandit Security Check
run: |
poetry run bandit -r stixorm -f json -o bandit_report.json || echo "##[error]Bandit security check failed."
- name: Run pytest with coverage
run: |
poetry run pytest -n 5 --verbose --cov=stixorm --cov-report=html --html=report.html --self-contained-html test/ --log-level=WARNING
- name: Upload pytest report
if: always()
uses: actions/upload-artifact@v3
with:
name: test-report-${{ matrix.python-version }}
path: |
report.html
Stix-ORM/htmlcov
- name: Upload Bandit Report
uses: actions/upload-artifact@v3
with:
name: bandit-report-${{ matrix.python-version }}
path: bandit_report.json
- name: Upload Flake8 report
if: always()
uses: actions/upload-artifact@v3
with:
name: flake-8-report--${{ matrix.python-version }}
path: flake8_report
build-package:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Poetry
run: |
pip install poetry
- name: Build Package
run: |
poetry install --no-dev
poetry build
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: stixorm-0.1.0-py3-none-any
path: dist/
test-package:
needs: build-package
strategy:
fail-fast: false
matrix:
python-version: [ "3.9", "3.10", "3.11" ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
# Service containers to run with `container-job`
services:
# Label used to access the service container
typedb:
# Docker Hub image
image: vaticle/typedb
# Set health checks to wait until vaticle typedb has started
ports: [ '1729:1729' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: stixorm-0.1.0-py3-none-any
- name: Create environment with package
run: |
ls
cd test_package
python -m venv venv
source venv/bin/activate
pip install pytest
cd ../
pip install stixorm-0.1.0-py3-none-any.whl
- name: Run pytest for package
run: |
cd test_package
source venv/bin/activate
pytest --verbose test/ --log-level=WARNING --log-cli-level=WARNING