Skip to content

Commit 59a2b92

Browse files
🔨 Update the pytest environment and add various fix
1 parent e2210cc commit 59a2b92

File tree

10 files changed

+168
-123
lines changed

10 files changed

+168
-123
lines changed

docs/toolbox.md renamed to docs/index.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# toolbox.sh
22

3-
**toolbox.sh** is a utility script for installing the SonarQube dev environment.
4-
53
## Overview
64

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

129127
* **0**: If successful.
130-
* **1**: If an error is encountered when push the release.
128+
* **1**: If the last commit tag does not match the last git tag.
131129

132130
### display_help
133131

docs/utils_bash.md

Lines changed: 0 additions & 61 deletions
This file was deleted.

mkdocs.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ site_name: ecoCode-java
22
repo_url: https://github.com/green-code-initiative/ecoCode-java/
33
site_description: Documentation based on ecoCode bash scripts
44
nav:
5-
- Home:
6-
- toolbox.md
7-
- utils_bash.md
5+
- index.md
86
theme:
97
name: material
108
palette:

poetry.lock

Lines changed: 145 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ mkdocs-include-dir-to-nav = "^1.2.0"
2121
[tool.poetry.group.test]
2222
[tool.poetry.group.test.dependencies]
2323
pytest = "^8.2.2"
24-
pytest-shell = "^0.3.2"
24+
pytest-shell-utilities = "^1.9.0"

tests/test_toolbox.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import inspect
22
import os
3+
import pytest
4+
import unittest
35

4-
current_dir: str = "./"
5-
if os.getenv('ENV') == "docker":
6+
7+
current_dir: str = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
8+
if os.environ['HOME'] == "/app":
69
current_dir = "/app/tests"
7-
else:
8-
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
9-
script: str = os.path.abspath(f"{current_dir}/../toolbox.sh")
1010

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

12-
def test_function_not_exist(bash):
13-
with bash() as s:
14-
s.auto_return_code_error = False
15-
assert s.run_script(script, ['test_function']) == "Function with name test_function does not exist"
16-
assert s.last_return_code == 1
13+
def test_function_not_exist(shell):
14+
ret = shell.run(script, "test_function")
15+
assert ret.returncode == 1
16+
assert "Function with name test_function does not exist" in ret.stderr

toolbox.Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.12-alpine3.20 as builder
1+
FROM python:3.12-alpine3.20 AS builder
22

33
ENV POETRY_NO_INTERACTION=1 \
44
POETRY_VIRTUALENVS_IN_PROJECT=1 \
@@ -9,15 +9,15 @@ ENV POETRY_NO_INTERACTION=1 \
99
PYTHONHASHSEED=random \
1010
PIP_DISABLE_PIP_VERSION_CHECK=on \
1111
PIP_DEFAULT_TIMEOUT=100 \
12-
POETRY_VERSION=1.7.1
12+
POETRY_VERSION=1.8.3
1313

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

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

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

3333
# Create user
3434
RUN addgroup -g 1000 app \
35-
&& adduser -G app -u 1000 app -D
35+
&& adduser --home /app -G app -u 1000 app -D
3636
USER app
3737
WORKDIR /app
3838

0 commit comments

Comments
 (0)