Skip to content

Commit

Permalink
🔨 Update the pytest environment and add various fix
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlouet committed Jul 19, 2024
1 parent e2210cc commit 59a2b92
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 123 deletions.
4 changes: 1 addition & 3 deletions docs/toolbox.md → docs/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# toolbox.sh

**toolbox.sh** is a utility script for installing the SonarQube dev environment.

## Overview

This toolbox enables you to install the SonarQube dev environment.
Expand Down Expand Up @@ -127,7 +125,7 @@ Create a push and a new branch with commits previously prepared
#### Exit codes

* **0**: If successful.
* **1**: If an error is encountered when push the release.
* **1**: If the last commit tag does not match the last git tag.

### display_help

Expand Down
61 changes: 0 additions & 61 deletions docs/utils_bash.md

This file was deleted.

4 changes: 1 addition & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ site_name: ecoCode-java
repo_url: https://github.com/green-code-initiative/ecoCode-java/
site_description: Documentation based on ecoCode bash scripts
nav:
- Home:
- toolbox.md
- utils_bash.md
- index.md
theme:
name: material
palette:
Expand Down
179 changes: 145 additions & 34 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ mkdocs-include-dir-to-nav = "^1.2.0"
[tool.poetry.group.test]
[tool.poetry.group.test.dependencies]
pytest = "^8.2.2"
pytest-shell = "^0.3.2"
pytest-shell-utilities = "^1.9.0"
20 changes: 10 additions & 10 deletions tests/test_toolbox.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import inspect
import os
import pytest
import unittest

current_dir: str = "./"
if os.getenv('ENV') == "docker":

current_dir: str = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
if os.environ['HOME'] == "/app":
current_dir = "/app/tests"
else:
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
script: str = os.path.abspath(f"{current_dir}/../toolbox.sh")

script: str = os.path.abspath(f"{current_dir}/../toolbox.sh")

def test_function_not_exist(bash):
with bash() as s:
s.auto_return_code_error = False
assert s.run_script(script, ['test_function']) == "Function with name test_function does not exist"
assert s.last_return_code == 1
def test_function_not_exist(shell):
ret = shell.run(script, "test_function")
assert ret.returncode == 1
assert "Function with name test_function does not exist" in ret.stderr
10 changes: 5 additions & 5 deletions toolbox.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12-alpine3.20 as builder
FROM python:3.12-alpine3.20 AS builder

ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
Expand All @@ -9,15 +9,15 @@ ENV POETRY_NO_INTERACTION=1 \
PYTHONHASHSEED=random \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=1.7.1
POETRY_VERSION=1.8.3

RUN pip install "poetry==$POETRY_VERSION"
RUN apk add --update --no-cache gcc libc-dev
RUN apk add --update --no-cache gcc libc-dev musl-dev linux-headers python3-dev
WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --no-root --no-ansi

FROM python:3.12-alpine3.20 as runtime
FROM python:3.12-alpine3.20 AS runtime

ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
Expand All @@ -32,7 +32,7 @@ RUN make install -C /tmp/shdoc

# Create user
RUN addgroup -g 1000 app \
&& adduser -G app -u 1000 app -D
&& adduser --home /app -G app -u 1000 app -D
USER app
WORKDIR /app

Expand Down
Loading

0 comments on commit 59a2b92

Please sign in to comment.