Skip to content

Commit

Permalink
actions: add initial workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
abn committed Jul 23, 2020
1 parent b40e20e commit a924c4b
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Code Quality

on:
push:
branches:
- master
pull_request:
branches:
- '**'

jobs:
flake8:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8
architecture: x64
- uses: actions/checkout@v2
- name: Install flake8
run: pip install flake8
- name: Run flake8
uses: suo/flake8-github-action@releases/v1
with:
checkName: 'flake8'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Black
uses: lgeiger/black-action@master
with:
args: --check src/ tests/
71 changes: 71 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Test Suite

on:
push:
branches:
- master
pull_request:
branches:
- '**'

jobs:
tests:
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [Ubuntu]
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Get full python version
id: full-python-version
shell: bash
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Install poetry
shell: bash
run: |
pip install poetry
echo "::set-env name=PATH::$HOME/.poetry/bin:$PATH"
- name: Upgrade pip
shell: bash
run: poetry run pip install --upgrade pip

- name: Configure poetry
shell: bash
run: poetry config virtualenvs.in-project true

- name: Set up cache
uses: actions/cache@v2
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
shell: bash
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv

- name: Install dependencies
shell: bash
run: poetry install

- name: Install gnmi_target
shell: bash
run: |
go get -u github.com/google/gnxi/gnmi_target
go install -v github.com/google/gnxi/gnmi_target
echo "::set-env name=PATH::`go env GOPATH`/bin:$PATH"
- name: Run tests
shell: bash
run: poetry run pytest tests/
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release

on:
push:
tags:
- '*.*.*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
- name: Configure pypi credentials
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry config http-basic.pypi __token__ "$PYPI_API_TOKEN"
- name: Publish release to pypi
run: |
poetry publish --build
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ tests/integration/deps:
##### execute tests
.PHONY: tests
tests: | tests/integration/deps
@pytest tests/
@poetry run pytest tests/

0 comments on commit a924c4b

Please sign in to comment.