Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize repo #710

Merged
merged 16 commits into from
Jan 23, 2024
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
23 changes: 23 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
changelog:
exclude:
authors:
- dependabot
categories:
- title: Breaking Changes
labels:
- "breaking-change"
- title: Bug Fixes
labels:
- "bug"
- title: New Features
labels:
- "enhancement"
- title: Documentation
labels:
- "documentation"
- title: Dependency Updates
labels:
- "dependencies"
- title: Other Changes
labels:
- "*"
33 changes: 0 additions & 33 deletions .github/workflows/lint.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Publish Python 🐍 distribution 📦 to PyPI

on:
push:
tags:
- '*'

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Print environment
run: |
python --version

- name: Install pypa/build
run: python3 -m pip install build

- name: Build a binary wheel and a source tarball
run: python3 -m build

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/kinto-attachment
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
105 changes: 60 additions & 45 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
on:
push:
branches:
- main
pull_request:
name: Run CI checks

on: pull_request

name: Unit Testing
jobs:
chore:
name: Unit Tests
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4

- name: Run linting and formatting checks
run: make lint

unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
services:
postgres:
image: postgres
Expand All @@ -22,35 +30,52 @@ jobs:
--health-retries 5
ports:
- 5432:5432

strategy:
matrix:
toxenv: [py38, kinto-main, upload-download-scripts]
include:
- toxenv: py38
python-version: "3.8"
- toxenv: upload-download-scripts
python-version: "3.8"
- toxenv: kinto-main
python-version: "3.8"

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v2
- name: Create database
env:
PGPASSWORD: postgres
run: |
psql -c "CREATE DATABASE testdb ENCODING 'UTF8' TEMPLATE template0;" -U postgres -h localhost

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml

- name: Install virtualenv
run: |
pip install virtualenv
virtualenv --python=python3 .venv
- name: Install dependencies
run: make install

- name: Print environment
- name: Run moto
run: |
source .venv/bin/activate
python --version
pip --version
make run-moto &

- name: Run unit tests
run: make test

functional-tests:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Create database
env:
Expand All @@ -59,24 +84,14 @@ jobs:
psql -c "CREATE DATABASE testdb ENCODING 'UTF8' TEMPLATE template0;" -U postgres -h localhost

- name: Install dependencies
run: |
make install
run: make install

- name: Run moto
run: |
make run-moto &

- name: Run Kinto
run: |
make run-kinto &
- name: Run kinto
run: make run-kinto & sleep 5

- name: Tox
run: |
source .venv/bin/activate
tox -e ${{ matrix.toxenv }}

- name: Coveralls
uses: AndreMiras/coveralls-python-action@develop
if: matrix.toxenv == 'py38'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run functional tests
run: make functional
6 changes: 3 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Changelog
=========

6.4.0 (unreleased)
------------------
>= 6.4.0
--------

- Nothing changed yet.
Since version 6.4.0, we use `Github releases <https://github.com/Kinto/kinto-attachment/releases>`_ and autogenerated changelogs.


6.3.2 (2023-11-14)
Expand Down
16 changes: 0 additions & 16 deletions MANIFEST.in

This file was deleted.

87 changes: 49 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,56 +1,67 @@
VIRTUALENV = virtualenv --python python3.8
VENV := $(shell echo $${VIRTUAL_ENV-.venv})
PYTHON = $(VENV)/bin/python
VENV := $(shell echo $${VIRTUAL_ENV-$$PWD/.venv})
INSTALL_STAMP = $(VENV)/.install.stamp
TEMPDIR := $(shell mktemp -d)

.IGNORE: clean distclean maintainer-clean
.PHONY: all install virtualenv tests
.IGNORE: clean
.PHONY: all install virtualenv tests tests-once

OBJECTS = .venv .coverage

all: install
install: $(INSTALL_STAMP)
$(INSTALL_STAMP): $(PYTHON) setup.py
$(VENV)/bin/pip install -U pip
$(VENV)/bin/pip install -Ur dev-requirements.txt
$(VENV)/bin/pip install -Ue . -c requirements.txt
touch $(INSTALL_STAMP)

virtualenv: $(PYTHON)
$(PYTHON):
$(VIRTUALENV) $(VENV)
$(VENV)/bin/python:
python -m venv $(VENV)

build-requirements:
$(VIRTUALENV) $(TEMPDIR)
$(TEMPDIR)/bin/pip install -U pip
$(TEMPDIR)/bin/pip install -Ue .
$(TEMPDIR)/bin/pip freeze | grep -v -- '^-e' > requirements.txt
install: $(INSTALL_STAMP) pyproject.toml requirements.txt
$(INSTALL_STAMP): $(VENV)/bin/python pyproject.toml requirements.txt
$(VENV)/bin/pip install -r requirements.txt
$(VENV)/bin/pip install ".[dev]"
touch $(INSTALL_STAMP)

run-moto:
$(VENV)/bin/moto_server s3bucket_path -H 0.0.0.0 -p 6000
lint: install
$(VENV)/bin/ruff check src tests
$(VENV)/bin/ruff format --check src tests

tests-once: install
$(VENV)/bin/py.test kinto_attachment/tests --cov-report term-missing --cov-fail-under 100 --cov kinto_attachment
format: install
$(VENV)/bin/ruff check --fix src tests
$(VENV)/bin/ruff format src tests

flake8:
$(VENV)/bin/pip install -U flake8
$(VENV)/bin/flake8 kinto_attachment
requirements.txt: requirements.in
pip-compile requirements.in

tests:
$(VENV)/bin/tox
tests: test
tests-once: test
test: install
$(VENV)/bin/py.test --cov-report term-missing --cov-fail-under 100 --cov kinto_attachment

clean:
find . -name '*.pyc' -delete
find . -name '__pycache__' -type d | xargs rm -fr
find src/ -name '*.pyc' -delete
find src/ -name '__pycache__' -type d -exec rm -fr {} \;
rm -rf $(OBJECTS) *.egg-info .pytest_cache .ruff_cache build dist

distclean: clean
rm -fr *.egg *.egg-info/
run-kinto: install
python -m http.server -d $(TEMPDIR) 8000 &
$(VENV)/bin/kinto migrate --ini tests/config/functional.ini
$(VENV)/bin/kinto start --ini tests/config/functional.ini

need-kinto-running:
@curl http://localhost:8888/v0/ 2>/dev/null 1>&2 || (echo "Run 'make run-kinto' before starting tests." && exit 1)

run-moto: install
$(VENV)/bin/moto_server s3bucket_path -H 0.0.0.0 -p 6000

maintainer-clean: distclean
rm -fr $(OBJECTS) .tox/ dist/ build/
need-moto-running:
@curl http://localhost:6000 2>/dev/null 1>&2 || (echo "Run 'make run-moto' before starting tests." && exit 1)

run-kinto:
cd /tmp; python -m http.server 8000 &
$(VENV)/bin/kinto migrate --ini kinto_attachment/tests/config/functional.ini
$(VENV)/bin/kinto start --ini kinto_attachment/tests/config/functional.ini
functional: install need-kinto-running need-moto-running
/usr/bin/openssl rand -base64 -out $(TEMPDIR)/image1.png 3000
/usr/bin/openssl rand -base64 -out $(TEMPDIR)/image2.png 3000
/usr/bin/openssl rand -base64 -out $(TEMPDIR)/image3.png 3000
$(VENV)/bin/python scripts/create_account.py --server=http://localhost:8888/v1 --auth=my-user:my-secret
$(VENV)/bin/python scripts/upload.py --server=http://localhost:8888/v1 --bucket=services --collection=logs --auth=my-user:my-secret $(TEMPDIR)/image1.png $(TEMPDIR)/image2.png $(TEMPDIR)/image3.png
$(VENV)/bin/python scripts/download.py --server=http://localhost:8888/v1 --bucket=services --collection=logs --auth=my-user:my-secret -f $(TEMPDIR)
$(VENV)/bin/python scripts/delete.py --server=http://localhost:8888/v1 --bucket=services --collection=logs --auth=my-user:my-secret
$(VENV)/bin/python scripts/upload.py --server=http://localhost:8888/v1 --bucket=services --collection=app --auth=my-user:my-secret $(TEMPDIR)/image1.png $(TEMPDIR)/image2.png $(TEMPDIR)/image3.png
$(VENV)/bin/python scripts/download.py --server=http://localhost:8888/v1 --bucket=services --collection=app --auth=my-user:my-secret -f $(TEMPDIR)/kintoapp
/bin/rm $(TEMPDIR)/image1.png $(TEMPDIR)/image2.png $(TEMPDIR)/image3.png
/bin/rm -rf $(TEMPDIR)/kinto*
Loading
Loading