Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
anis-next
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
anis
anis-next
Commits
52edeb7c
Commit
52edeb7c
authored
2 years ago
by
François Agneray
Browse files
Options
Downloads
Patches
Plain Diff
Add test + sonar for services subproject
parent
4115ae30
No related branches found
No related tags found
1 merge request
!72
Develop
Pipeline
#9377
failed
2 years ago
Stage: trigger-child-pipelines
Pipeline: anis-next
#9378
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+4
-0
4 additions, 0 deletions
Makefile
services/.gitlab-ci.yml
+28
-0
28 additions, 0 deletions
services/.gitlab-ci.yml
services/tests/anis_services/test_utils.py
+20
-0
20 additions, 0 deletions
services/tests/anis_services/test_utils.py
with
52 additions
and
0 deletions
Makefile
+
4
−
0
View file @
52edeb7c
...
...
@@ -24,6 +24,7 @@ list:
@
echo
" phpcs > Run php code sniffer test suite"
@
echo
" install_services > install services dependencies (virtualenv)"
@
echo
" shell_services > Shell into python services"
@
echo
" test_services > Starts the services unit tests"
@
echo
" install_tasks > install tasks dependencies (virtualenv)"
@
echo
" shell_tasks > Shell into python tasks"
@
echo
" create-db > Create a database for dev only (need token_enabled=0)"
...
...
@@ -95,6 +96,9 @@ install_services:
shell_services
:
@
docker-compose
exec
services bash
test_services
:
@
docker-compose
exec
services /bin/bash
-c
"source ./venv/bin/activate && pytest"
install_tasks
:
@
docker run
--init
-it
--rm
--user
$(
UID
)
:
$(
GID
)
-v
$(
CURDIR
)
/tasks:/project
-w
/project python:3.8 /bin/bash
-c
"python3 -m venv venv && source /project/venv/bin/activate && pip install -r requirements.txt"
...
...
This diff is collapsed.
Click to expand it.
services/.gitlab-ci.yml
+
28
−
0
View file @
52edeb7c
stages
:
-
test
-
sonar
-
dockerize
-
deploy
...
...
@@ -6,6 +8,32 @@ variables:
VERSION
:
"
3.7"
SONARQUBE_URL
:
https://sonarqube.lam.fr
test
:
image
:
python:3.8
stage
:
test
script
:
-
cd services
-
export PYTHONPATH=/builds/anis/anis-next/services/src
-
/bin/bash -c "python3 -m venv venv && source ./venv/bin/activate && pip install -r requirements.txt"
-
/bin/bash -c "source ./venv/bin/activate && pytest --cov=src --cov-report xml:report/coverage.xml --junitxml=report/pytest.xml"
artifacts
:
paths
:
-
services/report
sonar_scanner
:
image
:
sonarsource/sonar-scanner-cli:latest
stage
:
sonar
script
:
-
cd services
-
sonar-scanner
-Dsonar.projectKey=anis-services
-Dsonar.sources=src
-Dsonar.projectVersion=$VERSION
-Dsonar.host.url=$SONARQUBE_URL
-Dsonar.login=$SONAR_TOKEN_SERVICES
-Dsonar.python.coverage.reportPaths=report/coverage.xml
-Dsonar.python.xunit.reportPath=report/pytest.xml
dockerize
:
image
:
docker:stable
stage
:
dockerize
...
...
This diff is collapsed.
Click to expand it.
services/tests/anis_services/test_utils.py
0 → 100644
+
20
−
0
View file @
52edeb7c
import
os
from
unittest
import
mock
from
unittest.mock
import
call
import
pytest
from
anis_services.utils
import
*
class
Object
(
object
):
pass
class
MockJWT
:
def
decode
(
self
,
*
args
):
pass
class
TestIfsctoolsUtils
:
@mock.patch.dict
(
os
.
environ
,
{},
clear
=
True
)
def
test_check_config
(
self
):
with
pytest
.
raises
(
ConfigKeyNotFound
):
check_config
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment