Skip to content

Commit

Permalink
Merge branch 'morosi-cookiecutter' into 'master'
Browse files Browse the repository at this point in the history
Use the cookiecutter template in e3-core

See merge request it/e3-core!11
  • Loading branch information
adanaja committed Sep 26, 2024
2 parents 589c18f + 02cc89d commit 0f0bf66
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 99 deletions.
95 changes: 36 additions & 59 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
### GENERAL ###

variables:
GITLAB_REMOTE:
description: "The remote gitlab URL used."
Expand All @@ -14,9 +12,9 @@ variables:
value: "3.12"

stages:
- Checks
- Tests Linux
- Tests Windows
- checks
- tests linux
- tests windows

default:
services:
Expand All @@ -38,7 +36,6 @@ default:
.linux-image:
services:
- image:all-pythons
- cpu:4
before_script:
- source /it/activate-py${PYTHON_VERSION:0:1}${PYTHON_VERSION:2:2}
- python -m pip install -U pip
Expand All @@ -53,8 +50,8 @@ default:

# Stage: Checks

Style:
stage: Checks
check:
stage: checks
extends: .linux-common
needs: []
before_script:
Expand All @@ -72,42 +69,16 @@ Style:
- !reference [.linux-common, script]
variables:
PYTHON_VERSION: ${LATEST_PYTHON}
CI_TOX_ENV: mypy
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"

Security:
stage: Checks
needs: []
extends: .linux-common
variables:
PYTHON_VERSION: ${LATEST_PYTHON}
CI_TOX_ENV: security
CI_TOX_ENV: check
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"

Documentations:
stage: Checks
needs: ["Style"]
extends: .linux-common
variables:
PYTHON_VERSION: ${LATEST_PYTHON}
CI_TOX_ENV: docs
only:
refs:
- merge_requests
changes:
- docs/**/*
- pyproject.toml
- setup.cfg
- tox.ini
- .gitlab-ci.yml

# Stage: Tests

.test-linux:
stage: Tests Linux
stage: tests linux
extends: .linux-common
services:
- !reference [.linux-common, services]
- cpu:4
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
parallel:
matrix:
Expand All @@ -122,23 +93,23 @@ Documentations:
path: coverage.xml
junit: pytest-report.xml

Linux Python:
linux python:
extends: .test-linux
needs: ["Style"]
needs: ["check"]
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"

# A job tiggered by 'Run Linux tests'. This jobs will run without waiting any others
# A job triggered by 'run linux tests'. This jobs will run without waiting any others
# jobs.
Linux Python (always):
linux python (always):
extends: .test-linux
needs: []
rules:
- if: $CI_PIPELINE_SOURCE == "parent_pipeline" && $CI_MERGE_REQUEST_ID && $CI_PROJECT_NAME == "e3-core" && $ALWAYS_LINUX_TESTS == "y"

# A manual jobs to run Linux tests even if "Style" jobs has been failed
Run Linux tests:
stage: Tests Linux
# A manual job to run Linux tests even if "check" job has failed
run linux tests:
stage: tests linux
needs: []
trigger:
include: .gitlab-ci.yml
Expand Down Expand Up @@ -182,36 +153,32 @@ Run Linux tests:
- !reference [.windows-image, before_script]
- !reference [.tox-common, before_script]

# Stage: Checks

#--- Nothing to do during this stage ---#

# Stage: Tests

.test-windows:
stage: Tests Windows
stage: tests windows
extends: .windows-common
parallel:
matrix:
- PYTHON_VERSION: ["3.9", "3.10", "3.11", "3.12"]

Windows Python:
# Stage: Tests

windows python:
extends: .test-windows
needs: ["Style"]
needs: ["check"]
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"

# A job tiggered by 'Run Windows tests'. This jobs will run without waiting any others
# jobs.
Windows Python (always):
windows python (always):
extends: .test-windows
needs: []
rules:
- if: $CI_PIPELINE_SOURCE == "parent_pipeline" && $CI_MERGE_REQUEST_ID && $CI_PROJECT_NAME == "e3-core" && $ALWAYS_WINDOWS_TESTS == "y"

# A manual jobs to run Windows tests even if previous jobs has been failed
Run Windows tests:
stage: Tests Windows
# A manual job to run Windows tests even if previous jobs have failed
run windows tests:
stage: tests windows
needs: []
trigger:
include: .gitlab-ci.yml
Expand All @@ -233,3 +200,13 @@ Run Windows tests:
# Are you sure you want to run Windows tests?
#
# This is only useful if the previous stages have failed and you still want to run the tests.

documentations:
stage: checks
needs: ["check"]
extends: .linux-common
variables:
PYTHON_VERSION: ${LATEST_PYTHON}
CI_TOX_ENV: docs
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ check = [
"types-requests",
"types-setuptools",
]
doc = [
"sphinx",
"sphinx-autoapi",
"sphinx_rtd_theme==1.3.0",
]

[project.scripts]
e3 = "e3.sys:main"
Expand Down
66 changes: 26 additions & 40 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,63 +1,49 @@
[tox]
envlist = py311-cov-xdist
isolated_build = True
envlist =
py311-cov-xdist,
check
isolated_build=True

[testenv]
passenv = CI,GITHUB_*,CODECOV_*

deps =
xdist: pytest-xdist[psutil]
cov: pytest-cov
cov: coverage

passenv = CI,GITHUB_*,CODECOV_*
extras =
config
test
codecov: codecov
extras = test

# Run testsuite with coverage when '-cov' is in the env name
# Run testsuite with coverage when '-cov' and with multi-threading when '-xdist'
# is in the env name
commands=
pytest --ignore=build -vv --html=pytest-report.html --self-contained-html \
pytest -vv --ignore=build -v --html=pytest-report.html \
--junit-xml=pytest-report.xml --self-contained-html \
xdist: -n auto \
cov: --e3-cov-rewrite {envsitepackagesdir} src \
cov: --cov={envsitepackagesdir}/e3 --cov-branch \
cov: --cov {envsitepackagesdir}/e3 --cov-branch \
[]
codecov: codecov

[testenv:mypy]
# Run mypy
extras =
config
check
[testenv:check]
extras = check
commands =
mypy -- {toxinidir}/src


[testenv:security]
# Run pip audit, and bandit
extras =
config
check
commands =
# Accept yaml.load(), pickle, and exec since this
# is needed by e3. Also temporarily accept sha1 usage until this is replaced by
# more secure alternative. There is also e3.env.tmp_dir that returns the TMPDIR
# Run bandit checks. Accept yaml.load(), pickle, and exec since this
# is needed by e3. There is also e3.env.tmp_dir that returns the TMPDIR
# environment variable. Don't check for that.
# B202: should be investigated see https://github.com/AdaCore/e3-core/issues/694
bandit -r src/e3 -ll -ii -s B102,B108,B202,B301,B303,B506
# Ignore B324 that is no longer similar to B303 since Python3.9.
bandit -r {toxinidir}/src -ll -ii -s B102,B108,B301,B506,B303,B324,B202
mypy {toxinidir}/src

[testenv:docs]
deps =
sphinx
sphinx-autoapi
sphinx_rtd_theme==1.3.0
changedir = docs
extras = doc
commands =
python -msphinx -M html {toxinidir}/docs/source {toxinidir}/docs/build
sphinx-build -q -b html -d build/doctrees source build/html

[flake8]
exclude = .git,__pycache__,build,dist,.tox
# Ignored:
# A005: the module is shadowing a Python builtin module. We have many modules
# doing that (logging, json ...)
ignore = A003, A005, C901, E203, E266, E501, W503,D100,D101,D102,D102,D103,D104,D105,D106,D107,D203,D403,D213,B028,B906,B907,E704
ignore = B301,C901,E203,E266,E501,W503,D100,D101,D102,D102,D103,D104,D105,D106,D107,D203,D403,D213,E704,A003,A005,B028,B906,B907
# line length is intentionally set to 80 here because black uses Bugbear
# See https://github.com/psf/black/blob/master/README.md#line-length for more details
max-line-length = 80
select = A,ANN,B,B9,BLK,C,D,E,F,ISC,RST,T4,W
select = B,C,D,E,F,W,T4,B9,A,ANN,BLK,ISC,RST

0 comments on commit 0f0bf66

Please sign in to comment.