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
144 changes: 144 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Python Poetry Application

on:
push:
branches: ["main"]
tags:
- "v*"
pull_request:
branches: ["main"]

permissions:
contents: read
pull-requests: write # Needed for commenting on PRs

env:
PYTHON_VERSION: "3.13"
POETRY_VERSION: "2.1.2"

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Cache Poetry
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-${{ github.runner.os }}-${{ env.POETRY_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true

- name: Cache Dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: .venv
key: deps-${{ github.runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Dependencies
run: poetry install --no-interaction
if: steps.cache-deps.outputs.cache-hit != 'true'

- name: Run Pre-commit Checks
run: poetry run pre-commit run --all-files

- name: Run Tests with Coverage
run: poetry run pytest --cov=docker_volume_analyzer --cov-report=xml --cov-report=term

- name: Comment Coverage on PR
if: ${{ github.event_name == 'pull_request' }}
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-xml-coverage-path: ./coverage.xml

- name: Upload Coverage to Codecov
if: github.ref == 'refs/heads/main'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

release:
name: Build & Release
runs-on: ubuntu-latest
needs: test
if: startsWith(github.ref, 'refs/tags/v')

steps:
- uses: actions/checkout@v4

- name: Extract version from Git tag and set in pyproject.toml
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
poetry version $VERSION

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Cache Poetry
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-${{ github.runner.os }}-${{ env.POETRY_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true

- name: Cache Dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: .venv
key: deps-${{ github.runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Dependencies
run: poetry install --no-dev --no-interaction
if: steps.cache-deps.outputs.cache-hit != 'true'

- name: Build Distribution
run: poetry build

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.VERSION }}
files: |
dist/*.whl
dist/*.tar.gz

- name: Docker Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker Image
run: docker build \
--build-arg APP_VERSION=${{ env.VERSION }} \
-t glefer/docker-volumes-analyzer:${{ env.VERSION }} \
-t glefer/docker-volumes-analyzer:latest .

- name: Push Docker Image
run: |
docker push glefer/docker-volumes-analyzer:${{ env.VERSION }}
docker push glefer/docker-volumes-analyzer:latest
70 changes: 0 additions & 70 deletions .github/workflows/tests.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
__pycache__
htmlcov/
.coverage
.vscode/
.vscode/
dist/
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM python:3.13-slim AS builder

ENV PYTHONUNBUFFERED=1 \
POETRY_VERSION=2.1.2

RUN pip install "poetry==$POETRY_VERSION"

WORKDIR /build

COPY pyproject.toml poetry.lock ./
RUN poetry install --only main --no-interaction --no-ansi --no-root
COPY . .

RUN poetry build

FROM python:3.13-slim AS runtime

WORKDIR /app
ENV PYTHONUNBUFFERED=1

ARG APP_VERSION='undefined'
ENV APP_VERSION=${APP_VERSION}

COPY --from=builder /build/dist/*.whl ./dist/

RUN pip install ./dist/*.whl

CMD ["start"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [year] [fullname]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
116 changes: 116 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,119 @@ This project aims to make Docker volume management more intuitive and user-frien
[![Build Status](https://github.com/glefer/docker-volumes-analyzer/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/glefer/docker-volumes-analyzer/actions)
[![codecov](https://codecov.io/gh/glefer/docker-volumes-analyzer/branch/main/graph/badge.svg?token=JRjmc0emjT)](https://codecov.io/gh/glefer/docker-volumes-analyzer)
![Python](https://img.shields.io/badge/python-3.13-blue)


## Installation

### Prérequis

- **Python** `>=3.13,<4.0.0`
- **Poetry** `>=2.1.2` installé globalement ([lien d’installation](https://python-poetry.org/docs/#installation))
- Docker en local (si tu veux analyser des volumes)

---

### 1. Cloner le projet

```bash
git clone https://github.com/glefer/docker-volumes-analyzer.git
cd docker-volumes-analyzer
```

### 2. Installer les dépendances

```bash
poetry install
```

### 3. Lancer l'application

```bash
poetry run start
```

> ⚠️ L'application utilise le socket Docker à l'emplacement standard : `/var/run/docker.sock`

---

## 🐳 Utilisation via Docker

Pas envie d’installer Python ? Utilise simplement l’image Docker :

```bash
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -ti glefer/docker-volumes-analyzer:latest
```

### Utiliser une version spécifique

```bash
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -ti glefer/docker-volumes-analyzer:0.1.0
```

---

## Lancer les tests

```bash
poetry run pytest
```

Avec couverture :

```bash
poetry run pytest --cov=docker_volume_analyzer
```

---

## 🛠 Développement

Lance un shell virtuel :

```bash
poetry shell
```

Formatage et vérifications :

```bash
poetry run pre-commit run --all-files
```

---

## 🔧 Structure du projet

```
.
├── src/
│ └── docker_volume_analyzer/
│ └── main.py # Point d’entrée
├── tests/
├── README.md
├── pyproject.toml
└── poetry.lock
```

## Contributing

Contributions are welcome! If you'd like to contribute, please follow these steps:

1. Fork the repository.
2. Create a new branch (`git checkout -b feature/my-feature`).
3. Commit your changes (`git commit -m 'Add some feature'`).
4. Push to the branch (`git push origin feature/my-feature`).
5. Open a pull request.

For major changes, please open an issue first to discuss what you would like to change.

---

## 📝 Licence

Ce projet est sous licence **MIT** — voir le fichier [LICENSE](./LICENSE).

---

## 👨‍💻 Auteur
[github.com/glefer](https://github.com/glefer)
Loading
Loading