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

Fix CI #17

Merged
merged 2 commits into from
Apr 15, 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
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ __pycache__/
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
Expand Down
71 changes: 54 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,62 @@
name: CI

on:
push:
branches:
- '**'
workflow_dispatch: null

name: CI

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: nicknovitski/nix-develop@v1
- name: Lint with flake8
run: |
flake8 --version
flake8
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: nicknovitski/nix-develop@v1
- name: Build
run: |
python -m build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: nicknovitski/nix-develop@v1
- uses: actions/download-artifact@v4
with:
name: dist
path: tests/dist
- name: Integration tests
run: |
cd tests
pytest
release:
name: Create Release
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
environment: release
needs: [lint, test]
permissions:
id-token: write
steps:
- uses: actions/checkout@v2
- uses: DeterminateSystems/nix-installer-action@main
- uses: nicknovitski/nix-develop@v1
- name: Lint with flake8
run: |
cd src
flake8 --version
flake8
- name: Test with pytest
run: |
cd src/tests
pytest --version
pytest
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/-publish@release/v1
58 changes: 0 additions & 58 deletions .github/workflows/release.yml

This file was deleted.

11 changes: 0 additions & 11 deletions Dockerfile

This file was deleted.

17 changes: 12 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,24 @@ Development setup
Running CI linter and tests locally
-----------------------------------

1. [Install nix](https://github.com/DeterminateSystems/nix-installer)
1. `Install nix`_

2. Enter devshell: `nix develop`

3. Run linter::
3. Build package::

python -m build

4. Run linter::

cd src/
flake8

4. Run tests::
5. Run tests::

cp -r dist tests

cd tests

cd src/tests
pytest


Expand All @@ -98,3 +104,4 @@ Released under the terms of the Apache License 2.0

.. _pretix: https://github.com/pretix/pretix
.. _pretix development setup: https://docs.pretix.eu/en/latest/development/setup.html
.. _Install nix: https://github.com/DeterminateSystems/nix-installer
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
packages = with pkgs;[
podman-compose
(python3.withPackages (ps: with ps; [
build
pytest
flake8
requests
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/setup.py → setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

try:
with open(
os.path.join(os.path.dirname(__file__), "../README.rst"), encoding="utf-8"
os.path.join(os.path.dirname(__file__), "README.rst"), encoding="utf-8"
) as f:
long_description = f.read()
except: # NOQA
Expand Down
9 changes: 9 additions & 0 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM docker.io/pretix/standalone:stable
USER root
WORKDIR /pretix-ldap/
COPY dist/pretix_ldap*.whl .
RUN PYTHONPATH=$PYTHONPATH:/pretix/src pip3 install pretix_ldap*.whl
USER pretixuser
RUN cd /pretix/src && make production


2 changes: 1 addition & 1 deletion src/tests/docker-compose.yml → tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
container_name: redis

pretix:
build: ./../..
build: ./.
container_name: pretix
volumes:
- ./pretix/etc/pretix:/etc/pretix
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions src/tests/test_pretix-ldap.py → tests/test_pretix-ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@

@pytest.fixture(scope="module")
def start_pretix():
import os

print(os.getcwd())
print(os.system("ls"))
print("start pretix")
subprocess.Popen(["podman-compose", "up"])
print("started pretix")
yield
print("stop pretix")
subprocess.run(["podman-compose", "down"])
print("stopped pretix")


@pytest.fixture(scope="module")
Expand Down