Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,23 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.13
uses: actions/setup-python@v4
with:
python-version: "3.13"
- uses: actions/checkout@v4
- name: Install just
run: |
sudo apt update
sudo snap install --edge --classic just
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install

- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Lint
run: |
just lint
just python_version="3.13" lint

lint-commit:
runs-on: ubuntu-latest
name: "Lint commit message"
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install commitizen
run: |
python -m pip install --upgrade pip
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow will publish our package on pypi
# This workflow will publish our package on pypi, dockerhub, and create the release notes

name: Publish

Expand All @@ -11,23 +11,28 @@ permissions:
contents: write

jobs:
push_to_pypi:
publish_to_pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Publish python package
uses: JRubics/[email protected]
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
poetry_install_options: "--without dev"
version: "0.6.3"
- name: Publish to PyPi
run: |
uv build
uv publish
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}

push_to_docker_hub:
needs: push_to_pypi
needs: publish_to_pypi
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v2
Expand Down
42 changes: 29 additions & 13 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,31 @@ on:
branches: ["main"]

jobs:
generate-dependencies-file:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Create dependencies file
run: |
UV_PROJECT_ENVIRONMENT=.venv uv sync
UV_PROJECT_ENVIRONMENT=.venv uv pip freeze > requirements.txt
- uses: actions/upload-artifact@v4
with:
name: requirements
path: requirements.txt
overwrite: true

osv-scanner:
needs: generate-dependencies-file
runs-on: ubuntu-latest
container:
image: ghcr.io/google/osv-scanner:v1.9.2
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v4
with:
name: requirements
- name: Run OSV Scanner
run: |
/osv-scanner --skip-git --format table -r .
Expand All @@ -23,24 +42,21 @@ jobs:
container:
image: returntocorp/semgrep:latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run Semgrep
run: |
semgrep scan --config auto
twyn:
needs: generate-dependencies-file
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
python-version: "3.13"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install --only main
name: requirements
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Run Twyn against our dependencies
run: |
poetry run twyn --version
poetry run twyn run -vv
uv run twyn --version
uv run twyn run -vv
16 changes: 4 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,13 @@ jobs:
runs-on: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v4
- name: Install just
run: |
sudo apt update
sudo snap install --edge --classic just
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install

- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Test with pytest
run: |
just test
just python_version=${{ matrix.python-version }} test
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ For new feature proposals, please create first an issue to start a discussion ab

git clone [email protected]:<username>/twyn.git
cd twyn/
3. Make sure to have [poetry](https://python-poetry.org/) installed in your system, as well as [just](https://github.com/casey/just).
3. Make sure to have [uv](https://docs.astral.sh/uv/getting-started/installation/) installed in your system, as well as [just](https://github.com/casey/just).
4. Set up your working environment: create a virtual environment and install the project dependencies.
The following command will do both:

Expand Down
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
FROM python:3.13-slim

ARG USER=twyn
ARG GROUP=twyn

WORKDIR /app

RUN pip install twyn

RUN groupadd -g 1001 ${GROUP} && \
useradd -m -u 1001 -g ${GROUP} -s /bin/bash ${USER}

USER ${USER}:${GROUP}

ENTRYPOINT ["twyn"]
43 changes: 20 additions & 23 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# VARIABLE DEFINITIONS
venv := ".venv"
bin := venv + "/bin"
python := bin + "/python"
python_version := "python3.13"
python_version :="3.13"
target_dirs := "src tests"


# SENTINELS
venv-exists := path_exists(venv)

# ALIASES
alias t := test

Expand All @@ -19,32 +13,35 @@ alias t := test
help:
just --list --unsorted

# Generate the virtual environment.
venv:
@if ! {{ venv-exists }}; \
then \
POETRY_VIRTUALENVS_IN_PROJECT=1 poetry env use {{ python_version }}; \
poetry install; \
fi
# Cleans all artifacts generated while running this project, including the virtualenv.
venv:
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv sync

# Cleans all artifacts generated while running this project, including the virtualenv.
clean:
@rm -f .coverage*
@rm -rf {{ venv }}

# Runs the tests with the specified arguments (any path or pytest argument).
test *test-args='': venv
poetry run pytest {{ test-args }} --no-cov
test *test-args='':
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv run pytest {{ test-args }} --no-cov

# Runs all tests including coverage report.
test-all: venv
poetry run pytest
test-all:
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv run pytest

# Format all code in the project.
format: venv
poetry run ruff check {{ target_dirs }} --fix
format:
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv run ruff check {{ target_dirs }} --fix

# Lint all code in the project.
lint: venv
poetry run ruff check {{ target_dirs }}
poetry run mypy {{ target_dirs }}
lint:
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv run ruff check {{ target_dirs }}
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv run mypy {{ target_dirs }}


# Generate requirements.txt file
dependencies:
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv sync
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv pip freeze > requirements.txt

Loading