Skip to content
Open
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
51 changes: 51 additions & 0 deletions .github/workflows/build-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Build envsub tarballs for supported python.

name: "Build artifact"

on:
workflow_call:
inputs:
release-version:
required: true
type: string
dry-run:
required: true
type: boolean
python-version:
required: true
type: string
pull_request:
paths:
# When we change pyproject.toml, we want to ensure that the maturin builds still work.
- pyproject.toml
# And when we change this workflow itself...
- .github/workflows/build-artifacts.yml

concurrency:
group: sdist-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
sdist:
name: Build artifact for ${{ inputs.release-version }} ${{ inputs.dry-run && '(dry-run)' || '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install the project
run: uv sync

- name: Build tarball
run: uv build

- name: "Upload sdist"
uses: actions/upload-artifact@v4
with:
name: pypi_files
path: dist/*
35 changes: 35 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Publish a release to PyPI.
#
name: "Publish to PyPI"

on:
workflow_call:
inputs:
release-version:
required: true
type: string
dry-run:
required: true
type: boolean

jobs:
pypi-publish:
name: Upload to PyPI ${{ inputs.release-version }} ${{ inputs.dry-run && '(dry-run)' || '' }}
runs-on: ubuntu-latest
if: ${{ !inputs.dry-run }}
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: pypi_files
path: dist
merge-multiple: true

- uses: pdm-project/setup-pdm@v4
with:
python-version: 3.12

- name: Publish package distributions to PyPI
run: pdm publish --no-build
87 changes: 87 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Release

on:
push:
tags:
- 'v*' # Automatically trigger on version tags
- 'dry-run'

workflow_dispatch:
inputs:
tag:
description: "Release Tag"
required: true
default: "dry-run"
type: string

env:
PYTHON_VERSION: "3.12"


jobs:
plan:
runs-on: ubuntu-latest
outputs:
release_version: ${{ steps.release-version.outputs.release_version }}
dry-run: ${{ steps.release-version.outputs.dry_run }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set Release Version
id: release-version
run: |
if [ "${{ github.event_name }}" == "push" ]; then
echo "release_version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
if [ "${{ github.ref_name }}" == "dry-run" ]; then
echo "dry_run=true" >> $GITHUB_OUTPUT
else
echo "dry_run=false" >> $GITHUB_OUTPUT
fi
else
version="${{ github.event.inputs.tag || 'dry-run' }}"
if [ "${version}" == "dry-run" ]; then
echo "release_version=latest" >> $GITHUB_OUTPUT
echo "dry_run=true" >> $GITHUB_OUTPUT
else
echo "release_version=${version}" >> $GITHUB_OUTPUT
echo "dry_run=false" >> $GITHUB_OUTPUT
fi
fi
- name: Display Release Version
run: echo "The release version is ${{ steps.release-version.outputs.release_version }}"

unit-tests:
uses: ./.github/workflows/tests.yml

build-artifacts:
needs:
- plan
- unit-tests
uses: ./.github/workflows/build-artifacts.yml
with:
release-version: ${{ needs.plan.outputs.release_version }}
dry-run: ${{ needs.plan.outputs.dry-run == 'true' }}
python-version: '3.12'

tests-artifacts:
needs:
- plan
- build-artifacts
uses: ./.github/workflows/tests-artifacts.yml
with:
release-version: ${{ needs.plan.outputs.release_version }}
dry-run: ${{ needs.plan.outputs.dry-run == 'true' }}

publish-pypi:
needs:
- plan
- tests-artifacts
uses: ./.github/workflows/publish-pypi.yml
with:
release-version: ${{ needs.plan.outputs.release_version }}
dry-run: ${{ needs.plan.outputs.dry-run == 'true' }}
permissions:
contents: read
id-token: write
34 changes: 34 additions & 0 deletions .github/workflows/tests-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: tests artifacts

# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_call:
inputs:
release-version:
required: true
type: string
description: "release number"
dry-run:
required: true
type: boolean
description: "blank run means that the release will not be pushed"

jobs:
test-sdist:
name: test tarball archive of ${{ inputs.release-version }} ${{ inputs.dry-run && '(dry-run)' || '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: pypi_files
path: dist
merge-multiple: true

- name: "Install"
run: |
pip install dist/pyramid_kvs-*.whl --force-reinstall

- name: "Test sdist"
run: |
python -c "from pyramid_kvs import __version__; print(__version__, end='')"
52 changes: 52 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: tests

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

workflow_dispatch:

workflow_call:

jobs:
CI:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install the project
run: uv sync --group dev

# - name: Check types
# run: |
# uv run mypy src/pyramid_kvs/

- name: Run tests
run: |
uv run pytest tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml --cov=pyramid_kvs --cov-report=xml --cov-report=html

- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: pytest-results-${{ matrix.python-version }}
path: junit/test-results-${{ matrix.python-version }}.xml

- name: Codecov
if: matrix.python-version == '3.12' && github.event_name != 'workflow_dispatch'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

55 changes: 55 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package := 'pyramid_kvs'
default_test_suite := 'tests'

install:
uv sync --group dev

lint:
uv run ruff check .

test: lint unittest

unittest test_suite=default_test_suite:
uv run pytest -sxv {{test_suite}}

lf:
uv run pytest -sxvvv --lf

cov test_suite=default_test_suite:
rm -f .coverage
rm -rf htmlcov
uv run pytest --cov-report=html --cov={{package}} {{test_suite}}
xdg-open htmlcov/index.html

mypy:
uv run mypy src/ tests/

fmt:
uv run ruff check --fix .
uv run ruff format src tests

release major_minor_patch: test && changelog
uvx --with=pdm,pdm-bump --python-preference system pdm bump {{major_minor_patch}}
uv sync --group dev --group pyramid --frozen

changelog:
uv run python scripts/write_changelog.py
cat CHANGELOG.rst >> CHANGELOG.rst.new
rm CHANGELOG.rst
mv CHANGELOG.rst.new CHANGELOG.rst
$EDITOR CHANGELOG.rst

publish:
git commit -am "Release $(uv run scripts/get_version.py)"
git push
git tag "v$(uv run scripts/get_version.py)"
git push origin "v$(uv run scripts/get_version.py)"

#[doc("write eggs for testing")]
write_eggs:
#!/bin/bash
for app in tests/dummy_packages/*; do
pushd . > /dev/null
cd $app && python setup.py egg_info
popd > /dev/null
done
24 changes: 4 additions & 20 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
pyramid_kvs
===========

.. image:: https://travis-ci.org/Gandi/pyramid_kvs.svg?branch=master
:target: https://travis-ci.org/Gandi/pyramid_kvs
.. image:: https://github.com/mardiros/pyramid-kvs2/actions/workflows/tests.yml/badge.svg
:target: https://github.com/mardiros/pyramid-kvs2/actions/workflows/tests.yml

Some Key Value Store basics for pyramid:

Expand All @@ -16,8 +16,6 @@ Here are the provides features:
- An application cache, shared by every request.
- A session manager
- A rate limit per session holder
- A perl session reader (except you are migrating a perl website,
you probably don't want to use it).

Every of this components are optional, they exists if they are set in the
configuration like below.
Expand Down Expand Up @@ -95,23 +93,9 @@ following http headers:
- ``X-RateLimit-Remaining``: current remaining queries in that period.


perlsess
========

This permit to read a session from a perl that use `storable`_ session.

_`storable`: http://search.cpan.org/~ams/Storable-2.45/Storable.pm

Here is an example.

::


# declare the perlsess
kvs.perlsess = {"type": "memcached"}


Usage:
Usage
=====

Declare the addons in the ``pyramid.includes`` in your config, then
tweak the settings like above.
Expand Down
Loading
Loading