Skip to content

Commit

Permalink
Merge pull request #1 from Indicio-tech/feature/cicd
Browse files Browse the repository at this point in the history
feat: add ci/cd
  • Loading branch information
dbluhm authored Oct 15, 2021
2 parents bb9044a + 33d1b1b commit 81046e3
Show file tree
Hide file tree
Showing 5 changed files with 312 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .github/workflows/code-quality-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Code Quality Check

on:
push:
branches: [ main ]
pull_request:

env:
FLAKE8_VERSION: 3.9.2
BLACK_VERSION: 21.8b0

jobs:
format:
name: Format and Lint Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Cache python environment
id: cache-env
uses: actions/cache@v2
with:
path: env
key: ${{ runner.os }}-format-lint-${{ env.FLAKE8_VERSION }}-${{ env.BLACK_VERSION }}-${{ hashFiles('.github/workflows/code-quality-check.yml') }}
- name: create virtual environment
if: steps.cache-env.outputs.cache-hit != 'true'
run: |
python -m venv env
- name: Install dependencies
if: steps.cache-env.outputs.cache-hit != 'true'
run: |
env/bin/python -m pip install black==${{ env.BLACK_VERSION }}
env/bin/python -m pip install flake8==${{ env.FLAKE8_VERSION }}
- name: Black Format Check
run: |
env/bin/python -m black --check echo_agent tests
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
env/bin/python -m flake8 . --exclude=env --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
env/bin/python -m flake8 . --exclude=env --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
64 changes: 64 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Tests
on:
push:
branches: [ main ]
pull_request:

env:
POETRY_VERSION: 1.1.7

jobs:
test:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache poetry installation
id: cache-poetry
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-${{ runner.os }}-${{ matrix.python-version }}-${{ env.POETRY_VERSION }}-${{ hashFiles('.github/workflows/code-quality-check.yml') }}
- name: Install poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: |
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python - --version=${{ env.POETRY_VERSION }}
- name: Setup poetry environment
id: setup-poetry-env
run: |
poetry env use $(which python)
echo "::set-output name=poetry-env::$(poetry env info --path)"
- name: Cache poetry virtual environment
id: cache-poetry-venv
uses: actions/cache@v2
with:
path: ${{ steps.setup-poetry-env.outputs.poetry-env }}
key: poetry-env-${{ runner.os }}-${{ matrix.python-version }}-${{ env.POETRY_VERSION }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('.github/workflows/code-quality-check.yml') }}
- name: Install dependencies
if: steps.cache-poetry-venv.outputs.cache-hit != 'true'
run: |
poetry install
- name: Run unit tests with pytest
run: |
poetry run pytest
# int:
# name: Integration Tests
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Run integration tests
# run: |
# docker-compose -f int/docker-compose.yml run tests
# - name: Clean up integration tests
# if: always()
# run: |
# docker-compose -f int/docker-compose.yml down
Loading

0 comments on commit 81046e3

Please sign in to comment.