diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..6f38465 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,34 @@ +name: Docker Build and Push + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ chaimabenomrane2001 }} + password: ${{ dckr_pat_KzQgqOgvAhVlW2nkBFS2-uSUPAw }} + + - name: Build Docker image + run: | + docker build -t ChaimaBenOmrane/Python-To-Do-List:${{ github.sha }} . + docker tag ChaimaBenOmrane/Python-To-Do-List:${{ github.sha }} ChaimaBenOmrane/Python-To-Do-List:latest + + - name: Push Docker image + run: | + docker push ChaimaBenOmrane/Python-To-Do-List:${{ github.sha }} + docker push ChaimaBenOmrane/Python-To-Do-List:latest \ No newline at end of file diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..1168bd9 --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,39 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python application + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e5912be --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# Utiliser une image Python officielle comme base +FROM python:3.11-slim + +# Définir le répertoire de travail dans le conteneur +WORKDIR /app + +# Copier le fichier Python dans le conteneur +COPY todo.py . + +# Créer un utilisateur non-root pour la sécurité +RUN groupadd -r todouser && useradd -r -g todouser todouser + +# Changer la propriété du répertoire de travail +RUN chown -R todouser:todouser /app + +# Passer à l'utilisateur non-root +USER todouser + +# Définir la commande par défaut pour exécuter l'application +CMD ["python", "todo.py"] + +# Optionnel: Ajouter des métadonnées +LABEL maintainer="votre-email@example.com" +LABEL version="1.0" +LABEL description="Simple Todo List Application" \ No newline at end of file diff --git a/test_1.py b/test_1.py new file mode 100644 index 0000000..fd96042 --- /dev/null +++ b/test_1.py @@ -0,0 +1,2 @@ +def tester(): + assert True \ No newline at end of file diff --git a/test_tester.py b/test_tester.py new file mode 100644 index 0000000..fd96042 --- /dev/null +++ b/test_tester.py @@ -0,0 +1,2 @@ +def tester(): + assert True \ No newline at end of file