Skip to content

Commit

Permalink
Merge pull request #3 from brendancsmith/dev
Browse files Browse the repository at this point in the history
v0.2.0
  • Loading branch information
brendancsmith authored Apr 10, 2024
2 parents f8c3bc6 + 1d57806 commit 343c56d
Show file tree
Hide file tree
Showing 41 changed files with 1,322 additions and 713 deletions.
108 changes: 53 additions & 55 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,66 @@ name: Python package

on:
push:
branches: [ "main" ]
branches: [main]
pull_request:
branches: [ "main" ]
branches: [main]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
environment: test
env:
DIFFBOT_TOKEN: ${{ secrets.DIFFBOT_TOKEN }}
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
max-parallel: 4
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repo
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
#----------------------------------------------
# install & configure poetry
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-in-project: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# run linter
#----------------------------------------------
- name: Lint with ruff
run: |
source .venv/bin/activate
# stop the build if there are Python syntax errors or undefined names
ruff check . --select=E9,F63,F7,F82 --output-format=full --no-fix --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
ruff check . --select=E501,C901 --line-length=127 --exit-zero --no-fix --statistics
#----------------------------------------------
# run tests
#----------------------------------------------
- name: Test with pytest
run: |
source .venv/bin/activate
pytest
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repo
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
#----------------------------------------------
# install & configure poetry
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-in-project: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# run tests
#----------------------------------------------
- name: Test with pytest
run: |
source .venv/bin/activate
pytest
34 changes: 16 additions & 18 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,21 @@ permissions:

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# ----- diffbot-kg -----
19 changes: 0 additions & 19 deletions .pre-commit-config.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
tmp
13 changes: 13 additions & 0 deletions .trunk/configs/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Autoformatter friendly markdownlint config (all formatting rules disabled)
default: true
blank_lines: false
bullet: false
html: false
indentation: false
line_length: false
no-duplicate-heading:
siblings_only: true
no-trailing-punctuation: false
spaces: false
url: false
whitespace: false
7 changes: 7 additions & 0 deletions .trunk/configs/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ["{|}"]
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
2 changes: 2 additions & 0 deletions .trunk/configs/bandit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
assert_used:
skips: [./tests/*.py]
5 changes: 5 additions & 0 deletions .trunk/configs/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Generic, formatter-friendly config.
select = ["B", "D3", "E", "F"]

# Never enforce `E501` (line length violations). This should be handled by formatters.
ignore = ["E501"]
63 changes: 63 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.21.0
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.4.5
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
enabled:
- node@18.12.1
- python@3.10.8
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
ignore:
- linters: [ALL]
paths:
# Ignore generated files
- tests/functional/**/cassettes/*.yaml
definitions:
- name: bandit
direct_configs: [bandit.yaml]
commands:
- name: lint
run: bandit --exit-zero -c bandit.yaml --format json --output ${tmpfile} ${target}
- name: trufflehog
commands:
- name: lint
run: trufflehog filesystem --json --fail --exclude-paths=/.gitignore ${target}
enabled:
- actionlint@1.6.27
- bandit@1.7.8
- checkov@3.2.53
- git-diff-check
- markdownlint@0.39.0
- osv-scanner@1.7.0
- prettier@3.2.5
- ruff@0.3.5
- semgrep@1.67.0
- sourcery@1.16.0
- taplo@0.8.1
- trivy@0.50.1
- trufflehog-git@3.72.0
# - trufflehog@3.71.0
- yamllint@1.35.1
disabled:
- trufflehog
- black
- isort
actions:
enabled:
- commitizen
- commitlint
- git-lfs
- trufflehog-pre-commit
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
- trunk-upgrade-available
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["trunk.io"]
}
30 changes: 30 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"editor.defaultFormatter": "trunk.io",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"git.suggestSmartCommit": true,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/*.pyc": true,
"**/.trunk/*actions/": true,
"**/.trunk/*logs/": true,
"**/.trunk/*notifications/": true,
"**/.trunk/*out/": true,
"**/.trunk/*plugins/": true,
"**/__pycache__": true,
".ruff_cache": true,
".pytest_cache": true,
".aider.*": true,
".python-version": true
},
"explorerExclude.backup": {},
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ["@commitlint/config-conventional"] };
Loading

0 comments on commit 343c56d

Please sign in to comment.