Skip to content

Commit 61e140a

Browse files
author
Etienne Maheux
committed
[CI] Move several config files for ci in dedicated folder and add a script to check expectations of test files for pytest
1 parent 9e5c709 commit 61e140a

File tree

6 files changed

+38
-5
lines changed

6 files changed

+38
-5
lines changed

.gitlab-ci.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ update_conda_linux:
4040
- conda
4141
# leave this job for latter deploy jobs (executed on linux only & using conda)
4242

43+
check_tests:
44+
stage: .pre
45+
script:
46+
- bash "ci/check_tests.sh"
47+
tags:
48+
- bash # no matter macos or linux
49+
rules:
50+
- if: $CI_COMMIT_BRANCH # job not needed for latter deploy jobs (executed on linux only)
51+
4352
# Base job for jobs looping on Python environment and testing different OS
4453
.one_for_each_python_version_and_runner_os:
4554
parallel:
@@ -114,7 +123,7 @@ pages:
114123
rules:
115124
- if: $CI_COMMIT_BRANCH # == $CI_DEFAULT_BRANCH
116125
tags:
117-
- bash # arbitrary choice...
126+
- shell # arbitrary choice...
118127
dependencies:
119128
- tests
120129
script:
@@ -132,7 +141,7 @@ prepare_metadata:
132141
rules:
133142
- if: $CI_COMMIT_TAG
134143
tags:
135-
- bash # arbitrary choice...
144+
- shell # arbitrary choice...
136145
variables:
137146
VERSION_PYTHON_FILE: leaspy/__init__.py
138147
VERSION_REGEX: '^__version__\s*=\s*[\x27"](.+)[\x27"].*$' # \x27 is for single quote
@@ -196,5 +205,5 @@ releases:
196205
PKG_VERSION: $PKG_VERSION
197206
PKG_VERSION_WITHOUT_DEV_SUFFIX: $PKG_VERSION_WITHOUT_DEV_SUFFIX
198207
trigger:
199-
include: .releases.gitlab-ci.yml
208+
include: ci/releases.gitlab-ci.yml
200209
strategy: depend

.mdlrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
style ".mdlrc.style"
1+
style "ci/.mdlrc.style"
File renamed without changes.
File renamed without changes.

ci/check_tests.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
for test_dir in unit_tests functional_tests; do
4+
# check no missing __init__.py file
5+
nb_init=$(find tests/$test_dir -type f -name "__init__.py" | wc -l)
6+
nb_folder=$(find tests/$test_dir -type d -not -name "__*" | wc -l)
7+
if (( $nb_init != $nb_folder )); then
8+
echo "Missing a '__init__.py' in a test subfolder from $test_dir."
9+
exit 1
10+
fi
11+
12+
# check that all tests files begin with test_*
13+
files_not_beginning_by_test=$(find tests/$test_dir -name "*.py" -not -name "test_*" -not -name "__init__.py")
14+
nb_not_beginning_by_test=$(find tests/$test_dir -name "*.py" -not -name "test_*" -not -name "__init__.py" | wc -l)
15+
if (( $nb_not_beginning_by_test != 0 )); then
16+
echo "Test files not matching 'test_*.py' in $test_dir: $files_not_beginning_by_test"
17+
exit 1
18+
fi
19+
20+
# TODO? check that all tests classes import LeaspyTestCase?
21+
done
22+
23+
echo "Tests seems OK!"
24+
exit 0

.releases.gitlab-ci.yml renamed to ci/releases.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ check_env:
4040
- echo $TAG_WITHOUT_PREFIX
4141
- echo $PKG_VERSION
4242
- echo $PKG_VERSION_WITHOUT_DEV_SUFFIX
43-
- envsubst < .pypirc.in > .pypirc # substitute environment variables in template .pypirc
43+
- envsubst < ci/.pypirc.in > .pypirc # substitute environment variables in template .pypirc
4444
# update all packages in conda deploy env for later steps
4545
- conda upgrade --all --yes
4646
- '[[ "$CI_DEBUG" == "1" ]] && conda info || true'

0 commit comments

Comments
 (0)