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
20 changes: 17 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ on:
types: [released]
permissions: read-all
jobs:
lint:
name: Lint code
runs-on: ubuntu-latest
steps:
- name: Checkout the Git repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.13
cache: "pip"
- name: Lint code
shell: bash
run: make lint format
test-image:
name: Generate test ext4 image
runs-on: ubuntu-latest
Expand Down Expand Up @@ -59,11 +73,11 @@ jobs:
cache: "pip"
- name: Run test
shell: bash
run: ./test.sh
run: make test
build:
name: Build pip package
runs-on: ubuntu-latest
needs: [test]
needs: [test, lint]
steps:
- name: Checkout the Git repository
uses: actions/checkout@v4
Expand All @@ -75,7 +89,7 @@ jobs:
- name: Install build tool
run: pip install build
- name: Building package
run: python -m build
run: make release
- uses: actions/upload-artifact@v4
with:
name: pip
Expand Down
87 changes: 87 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
.DEFAULT_GOAL := all
VERSION := $(shell grep -m 1 version pyproject.toml | tr -s ' ' | tr -d "'\":" | cut -d' ' -f3)
PACKAGE := $(shell grep -m 1 name pyproject.toml | tr -s ' ' | tr -d "'\":" | cut -d' ' -f3)
Comment thread
coderabbitai[bot] marked this conversation as resolved.

OBJ := $(wildcard ${PACKAGE}/**)
OBJ += requirements.txt
OBJ += pyproject.toml
OBJ += README.md
OBJ += LICENSE

SHELL := /bin/bash
ifeq ($(OS),Windows_NT)
ifeq ($(VENV_BIN_ACTIVATE),)
VENV_BIN_ACTIVATE := .venv/Scripts/activate
endif
else
ifeq ($(VENV_BIN_ACTIVATE),)
VENV_BIN_ACTIVATE := .venv/bin/activate
endif
endif

ifeq ($(PYTHON),)
PYTHON := python
endif

clean:
git clean --force -dX

build: wheel

release: wheel sdist

sdist: dist/${PACKAGE}-${VERSION}.tar.gz

wheel: dist/${PACKAGE}-${VERSION}-py3-none-any.whl

dist:
mkdir -p dist

dist/${PACKAGE}-${VERSION}.tar.gz: ${VENV_BIN_ACTIVATE} dist $(OBJ)
. ${VENV_BIN_ACTIVATE}; \
$(PYTHON) -m build --sdist

dist/${PACKAGE}-${VERSION}-py3-none-any.whl: ${VENV_BIN_ACTIVATE} dist $(OBJ)
. ${VENV_BIN_ACTIVATE}; \
$(PYTHON) -m build --wheel

${VENV_BIN_ACTIVATE}: requirements.txt
@echo "Setting up development virtual env in .venv"
$(PYTHON) -m venv .venv
. ${VENV_BIN_ACTIVATE}; \
$(PYTHON) -m pip install wheel build ruff; \
$(PYTHON) -m pip install \
-r requirements.txt

test: ${VENV_BIN_ACTIVATE}
$(SHELL) test.sh

all: release

lint: $(VENV_BIN_ACTIVATE)
. $(VENV_BIN_ACTIVATE); \
$(PYTHON) -m ruff check

lint-fix: $(VENV_BIN_ACTIVATE)
. $(VENV_BIN_ACTIVATE); \
$(PYTHON) -m ruff check --fix

format: $(VENV_BIN_ACTIVATE)
. $(VENV_BIN_ACTIVATE); \
$(PYTHON) -m ruff format --diff

format-fix: $(VENV_BIN_ACTIVATE)
. $(VENV_BIN_ACTIVATE); \
$(PYTHON) -m ruff format

.PHONY: \
all \
build \
clean \
sdist \
wheel \
test \
lint \
lint-fix \
format \
format-fix
4 changes: 3 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
set -e
python -m venv .venv
if ! [ -d .venv ];then
python -m venv .venv
fi
if [ -f .venv/Scripts/activate ]; then
. .venv/Scripts/activate
elif [ -f .venv/bin/activate ]; then
Expand Down
Loading