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
80 changes: 39 additions & 41 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,30 @@ jobs:
name: linters
strategy:
matrix:
python-version: [ '3.8' ]
python-version: [ '3.9' ]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v1
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install Poetry
uses: snok/install-poetry@v1
- name: Setup uv
uses: astral-sh/setup-uv@v6.8.0
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Cache Poetry virtualenv
uses: actions/cache@v2
id: cached-poetry-dependencies
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
# Glob pattern to match files relative to the repository root to control the cache.
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
# Suffix for the cache key
cache-suffix: venv-${{ runner.os }}-${{ hashFiles('**/uv.lock') }}

- name: Install Dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: uv sync
if: steps.setup-uv.outputs.cache-hit != 'true'

- name: Run black
run: make black
Expand All @@ -48,45 +45,40 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ '3.8', '3.9', '3.10' ]
python-version: [ '3.9', '3.10' ]
platform: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v1
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Cache Poetry virtualenv
uses: actions/cache@v2
id: cached-poetry-dependencies
- name: Setup uv
uses: astral-sh/setup-uv@v6.8.0
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
if: ${{ matrix.platform != 'windows-latest' }} # windows hangs if using a cached venv
# Glob pattern to match files relative to the repository root to control the cache.
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
# Suffix for the cache key
cache-suffix: venv-${{ matrix.python-version }}-${{ runner.os }}-${{ hashFiles('**/uv.lock') }}

- name: Install Dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: uv sync
if: steps.setup-uv.outputs.cache-hit != 'true'

- name: Force using UTF-8 encoding for windows tests
run: poetry run python -m pytest -vs
run: uv run python -m pytest -vs
if: ${{ matrix.platform == 'windows-latest' }}
env:
PYTHONIOENCODING: utf-8

- name: Run pytest
run: make pytest
if: ${{ matrix.platform != 'windows-latest' }}

release:
name: Releasing to pypi
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
Expand All @@ -95,25 +87,31 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v1
uses: actions/setup-python@v6
with:
python-version: 3.9

- uses: astral-sh/setup-uv@v6.8.0
with:
python-version: 3.8

- name: Install Poetry
uses: snok/install-poetry@v1
# Glob pattern to match files relative to the repository root to control the cache.
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
# Suffix for the cache key
cache-suffix: venv-${{ runner.os }}-${{ hashFiles('**/uv.lock') }}

- name: prepare release
run: make fiximageurls

- name: build release
run: poetry build
run: uv build

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

- uses: actions/upload-artifact@v3
with:
name: build
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ IMG_URL=https://raw.githubusercontent.com/INSRapperswil/gitlabtree/main/doc/imgs
# Run pytest
.PHONY: pytest
pytest:
poetry run pytest --cov-report term --cov=gitlabtree -vs ${ARGS}
uv run pytest --cov-report term --cov=gitlabtree -vs ${ARGS}

# Check if the python code needs to be reformatted
# Check if the python code needs to be reformatted
.PHONY: black
black:
poetry run black --check ${CODE_DIRS}
uv run black --check ${CODE_DIRS}

# Python type check
.PHONY: mypy
mypy:
poetry run mypy ${CODE_DIRS}
uv run mypy ${CODE_DIRS}

# Runn pytest, black and mypy
.PHONY: tests
Expand All @@ -24,9 +24,9 @@ tests: pytest black mypy
# use "make bump ARGS=patch" to bump the version. ARGS can be patch, minor or major.
.PHONY: bump
bump:
poetry version ${ARGS}
sed -i -E "s|\"\b[0-9]+.\b[0-9]+.\b[0-9]+\" # From Makefile|\"`poetry version -s`\" # From Makefile|g" ${PROJECT}/__init__.py
sed -i -E "s|\"\b[0-9]+.\b[0-9]+.\b[0-9]+\" # From Makefile|\"`poetry version -s`\" # From Makefile|g" tests/test_${PROJECT}.py
uv version ${ARGS}
sed -i -E "s|\"\b[0-9]+.\b[0-9]+.\b[0-9]+\" # From Makefile|\"`uv version --short`\" # From Makefile|g" ${PROJECT}/__init__.py
sed -i -E "s|\"\b[0-9]+.\b[0-9]+.\b[0-9]+\" # From Makefile|\"`uv version --short`\" # From Makefile|g" tests/test_${PROJECT}.py

# Used in the pipeline to change the image urls befor publishing it on pypi.org
.PHONY: fiximageurls
Expand All @@ -38,6 +38,6 @@ fiximageurls:
tag:
git checkout main
git pull
git tag -a "v`poetry version -s`" -m "Version v`poetry version -s`"
git tag -a "v`uv version --short`" -m "Version v`uv version --short`"
git push --tags
git checkout -
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ GitLabTree is a CLI tool for retrieving information from a GitLab server. Mainly
pip install gitlabtree
```

Or run directly with `uv` (requires [uv](https://github.com/astral-sh/uv)):
```
uvx gitlabtree
```

From source:
```
git clone
cd gitlabtree
poetry install
uv sync
```

## Features
Expand All @@ -37,4 +42,3 @@ poetry install
### Visibility

![help](doc/imgs/gitlabtree_visibility.png)

1 change: 1 addition & 0 deletions gitlabtree/gitlab_helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
GitLab Helper and RequestDriver to interact with the GitLab API
"""

from typing import Type, Any
import requests

Expand Down
1 change: 1 addition & 0 deletions gitlabtree/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Pydantic models with __rich__ for easy printing with rich
"""

from typing import List, Optional
from pydantic import BaseModel, Field, ConfigDict
from rich.panel import Panel
Expand Down
1 change: 1 addition & 0 deletions gitlabtree/permissions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Helper functions for the runners cli subcommand
"""

from typing import Dict, Any, List

from rich.table import Table
Expand Down
1 change: 1 addition & 0 deletions gitlabtree/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Helper functions for the pipeline cli subcommand
"""

from typing import Dict, Any, List

from .gitlab_helper import GitLabHelper
Expand Down
1 change: 1 addition & 0 deletions gitlabtree/rich_helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Helper functions using rich
"""

from typing import Optional
from rich.panel import Panel
from rich.tree import Tree
Expand Down
1 change: 1 addition & 0 deletions gitlabtree/runner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Helper functions for the runners cli subcommand
"""

from typing import Dict, Any, List
from rich.panel import Panel

Expand Down
1 change: 1 addition & 0 deletions gitlabtree/tree_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Tree Helper object to download the data and create the free
The objects from gitlabtree.models will be used for the tree
"""

from typing import Any, Dict, List, Callable, Optional

from .models import Group, Repository, Info
Expand Down
1 change: 1 addition & 0 deletions gitlabtree/visibility.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Visibility Helper to get visibility information from GitLabAPI for projects and groups
"""

from typing import Any, List, Dict

from .gitlab_helper import GitLabHelper
Expand Down
Loading
Loading