Skip to content

Commit fc23bf2

Browse files
committed
feature: github actions integration (lints and tests)
1 parent ac47a08 commit fc23bf2

6 files changed

Lines changed: 136 additions & 674 deletions

File tree

.github/workflows/audit.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Security audit
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 1 * *'
6+
push:
7+
paths:
8+
- '**/Cargo.toml'
9+
- '**/poetry.lock'
10+
pull_request:
11+
12+
jobs:
13+
audit-rust:
14+
name: Run cargo security audit
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: actions-rs/audit-check@v1
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
22+
audit-python:
23+
name: Check for python security issues
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: Install poetry
28+
run: |
29+
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
30+
31+
- name: Install virtualenv
32+
run: |
33+
sudo apt-get install python3-venv
34+
35+
- name: Install dependencies
36+
run: |
37+
python3 -m venv /tmp/venv
38+
source /tmp/venv/bin/activate
39+
env PATH="${PATH}:${HOME}/.poetry/bin" poetry install
40+
41+
- name: Run bandit
42+
run: |
43+
source /tmp/venv/bin/activate
44+
env PATH="${PATH}:${HOME}/.poetry/bin" poetry run bandit -r streamson/
45+
46+
- name: Run safety
47+
run: |
48+
source /tmp/venv/bin/activate
49+
env PATH="${PATH}:${HOME}/.poetry/bin" poetry run safety check

.github/workflows/code-quality.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
on: [push]
2+
3+
name: Code Quality
4+
5+
jobs:
6+
pre-commit:
7+
name: Run pre-commit Lints
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- name: Install rust nightly toolchain
13+
uses: actions-rs/toolchain@v1
14+
with:
15+
profile: minimal
16+
toolchain: nightly
17+
override: true
18+
components: rustfmt, clippy
19+
20+
- name: Setup python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: "3.8.x"
24+
25+
- name: Install poetry
26+
run: |
27+
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
28+
29+
- name: Install virtualenv
30+
run: |
31+
sudo apt-get install python3-venv
32+
33+
- name: Install dependencies
34+
run: |
35+
env PATH="${PATH}:${HOME}/.poetry/bin" poetry install
36+
37+
- name: Run pre-commit checks
38+
run: |
39+
env RUSTFLAGS="-D unused_crate_dependencies" PATH="${PATH}:${HOME}/.poetry/bin" poetry run pre-commit run --hook-stage push --all-files
40+
41+
tests-python:
42+
name: Python ${{ matrix.python-version }} ${{ matrix.os }} tests
43+
strategy:
44+
matrix:
45+
os: [ubuntu-latest]
46+
python-version: ['3.6', '3.7', '3.8']
47+
runs-on: ${{ matrix.os}}
48+
steps:
49+
- uses: actions/checkout@v2
50+
- name: Install rust nightly toolchain
51+
uses: actions-rs/toolchain@v1
52+
with:
53+
profile: minimal
54+
toolchain: nightly
55+
override: true
56+
- name: Setup python
57+
uses: actions/setup-python@v2
58+
with:
59+
python-version: ${{ matrix.python-version }}
60+
- name: Install poetry
61+
run: |
62+
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
63+
64+
- name: Install dependencies
65+
run: |
66+
env PATH="${PATH}:${HOME}/.poetry/bin" poetry install
67+
68+
- name: Build the project
69+
run: |
70+
env PATH="${PATH}:${HOME}/.poetry/bin" poetry run maturin develop
71+
72+
- name: Run tests
73+
run: |
74+
env PATH="${PATH}:${HOME}/.poetry/bin" poetry run pytest tests/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.swo
44
*.swp
55
.mypy_cache/
6+
poetry.lock

.pre-commit-config.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ repos:
1111
- repo: local
1212
hooks:
1313
- id: black
14-
name: Black formatter
14+
name: "Python: Black formatter"
1515
entry: poetry run black --check
1616
language: system
1717
types: [python]
1818
- id: flake8
19-
name: Flake8 linter
19+
name: "Python: Flake8 linter"
2020
entry: poetry run flake8
2121
language: system
2222
types: [python]
2323
- id: isort
24-
name: isort formatter
24+
name: "Python: isort formatter"
2525
entry: poetry run isort -rc -c
2626
language: system
2727
types: [python]
2828
- id: mypy
29-
name: mypy linter
29+
name: "Python: mypy linter"
3030
entry: poetry run mypy --config-file mypy.ini
3131
language: system
3232
types: [python]
@@ -35,5 +35,8 @@ repos:
3535
rev: master
3636
hooks:
3737
- id: fmt
38+
name: "Rust: fmt"
3839
- id: cargo-check
40+
name: "Rust: check"
3941
- id: clippy
42+
name: "Rust: clippy"

0 commit comments

Comments
 (0)