Merge branch 'docker-build-test'
Some checks failed
Amarillo/amarillo-gitea/amarillo-core/pipeline/head There was a failure building this commit
Some checks failed
Amarillo/amarillo-gitea/amarillo-core/pipeline/head There was a failure building this commit
This commit is contained in:
commit
8b9fd6ab25
|
|
@ -22,8 +22,13 @@ ENV METRICS_PASSWORD=''
|
|||
|
||||
EXPOSE 80
|
||||
|
||||
ARG PACKAGE_REGISTRY_URL
|
||||
ARG PLUGINS
|
||||
|
||||
COPY requirements.txt /app/requirements.txt
|
||||
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
||||
RUN --mount=type=secret,id=AMARILLO_REGISTRY_CREDENTIALS \
|
||||
pip install --no-cache-dir --upgrade --extra-index-url https://$(cat /run/secrets/AMARILLO_REGISTRY_CREDENTIALS)@${PACKAGE_REGISTRY_URL} ${PLUGINS}
|
||||
|
||||
COPY ./amarillo/app /app/amarillo/app
|
||||
COPY ./amarillo/plugins /app/amarillo/plugins
|
||||
|
|
|
|||
34
Jenkinsfile
vendored
34
Jenkinsfile
vendored
|
|
@ -3,10 +3,14 @@ pipeline {
|
|||
environment {
|
||||
GITEA_CREDS = credentials('AMARILLO-JENKINS-GITEA-USER')
|
||||
TWINE_REPO_URL = "https://git.gerhardt.io/api/packages/amarillo/pypi"
|
||||
REGISTRY_URL = 'https://git.gerhardt.io'
|
||||
PLUGINS_REPO_URL = "git.gerhardt.io/api/packages/amarillo/pypi/simple"
|
||||
DOCKER_REGISTRY_URL = 'https://git.gerhardt.io'
|
||||
OWNER = 'amarillo'
|
||||
IMAGE_NAME = "amarillo"
|
||||
IMAGE_NAME = 'amarillo'
|
||||
TAG = "${BUILD_NUMBER}"
|
||||
PLUGINS = 'amarillo-metrics amarillo-enhancer'
|
||||
DEPLOY_WEBHOOK_URL = 'https://amarillo.mfdz.de:8888/mitanand'
|
||||
DEPLOY_SECRET = credentials('AMARILLO-JENKINS-DEPLOY-SECRET')
|
||||
}
|
||||
stages {
|
||||
stage('Create virtual environment') {
|
||||
|
|
@ -20,14 +24,9 @@ pipeline {
|
|||
stage('Installing requirements') {
|
||||
steps {
|
||||
echo 'Installing packages'
|
||||
sh 'python3 -m pip install -r requirements.txt'
|
||||
sh 'python3 -m pip install --upgrade build'
|
||||
sh 'python3 -m pip install --upgrade twine'
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
steps {
|
||||
echo 'Testing'
|
||||
sh 'pip install -r requirements.txt'
|
||||
sh 'pip install --upgrade build'
|
||||
sh 'pip install --upgrade twine'
|
||||
}
|
||||
}
|
||||
stage('Build package') {
|
||||
|
|
@ -45,7 +44,8 @@ pipeline {
|
|||
steps {
|
||||
echo 'Building image'
|
||||
script {
|
||||
docker.build("${OWNER}/${IMAGE_NAME}:${TAG}")
|
||||
docker.build("${OWNER}/${IMAGE_NAME}:${TAG}",
|
||||
"--build-arg='PACKAGE_REGISTRY_URL=${PLUGINS_REPO_URL}' --build-arg='PLUGINS=${PLUGINS}' --secret id=AMARILLO_REGISTRY_CREDENTIALS,env=GITEA_CREDS .")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ pipeline {
|
|||
steps {
|
||||
echo 'Pushing image to registry'
|
||||
script {
|
||||
docker.withRegistry(REGISTRY_URL, 'AMARILLO-JENKINS-GITEA-USER'){
|
||||
docker.withRegistry(DOCKER_REGISTRY_URL, 'AMARILLO-JENKINS-GITEA-USER'){
|
||||
def image = docker.image("${OWNER}/${IMAGE_NAME}:${TAG}")
|
||||
image.push()
|
||||
image.push('latest')
|
||||
|
|
@ -61,6 +61,16 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
stage('Notify CD script') {
|
||||
steps {
|
||||
echo 'Triggering deploy webhook'
|
||||
script {
|
||||
def response = httpRequest contentType: 'APPLICATION_JSON',
|
||||
httpMode: 'POST', requestBody: '{}', authentication: 'AMARILLO-JENKINS-DEPLOY-SECRET',
|
||||
url: "${DEPLOY_WEBHOOK_URL}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
recursive-include amarillo/static/ *
|
||||
recursive-include amarillo/static/ *
|
||||
recursive-include amarillo/app/tests/ *
|
||||
0
amarillo/app/tests/__init__.py
Normal file
0
amarillo/app/tests/__init__.py
Normal file
5
amarillo/app/tests/stops.csv
Normal file
5
amarillo/app/tests/stops.csv
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
stop_id;stop_code;stop_lat;stop_lon;stop_name
|
||||
mfdz:x;x;52.11901;14.2;Stop x
|
||||
mfdz:y;y;53.1;14.01;Stop y
|
||||
mfdz:z;z;54.11;14.0;Stop z
|
||||
mfdz:Ang001;Ang001;53.11901;14.015776;Mitfahrbank Biesenbrow
|
||||
|
39
amarillo/app/tests/stops.json
Normal file
39
amarillo/app/tests/stops.json
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"data": {
|
||||
"pointsOfInterest": [
|
||||
{
|
||||
"id": "14622",
|
||||
"externalId": "bbnavi:12073:0001",
|
||||
"name": "Parkbank",
|
||||
"description": "Parkbank",
|
||||
"dataProvider": {
|
||||
"id": "1",
|
||||
"name": "Administrator"
|
||||
},
|
||||
"addresses": [
|
||||
{
|
||||
"street": "Hauptstrasse",
|
||||
"city": "Wittenberge",
|
||||
"zip": "12345",
|
||||
"geoLocation": {
|
||||
"latitude": 52.9932971109789,
|
||||
"longitude": 11.767383582547
|
||||
}
|
||||
}
|
||||
],
|
||||
"openStreetMap": {
|
||||
"capacity": 112,
|
||||
"capacityCharging": "2",
|
||||
"capacityDisabled": "",
|
||||
"fee": "No",
|
||||
"lit": "Yes",
|
||||
"parking": "",
|
||||
"shelter": "No",
|
||||
"surface": "",
|
||||
"utilization": "",
|
||||
"website": ""
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
24
amarillo/app/tests/test_stops_store.py
Normal file
24
amarillo/app/tests/test_stops_store.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
from amarillo.app.services import stops
|
||||
from amarillo.app.models.Carpool import StopTime
|
||||
|
||||
def test_load_stops_from_file():
|
||||
store = stops.StopsStore([{"url": "amarillo/app/tests/stops.csv", "vicinity": 50}])
|
||||
store.load_stop_sources()
|
||||
assert len(store.stopsDataFrames[0]['stops']) > 0
|
||||
|
||||
def test_load_csv_stops_from_web_():
|
||||
store = stops.StopsStore([{"url": "https://data.mfdz.de/mfdz/stops/custom.csv", "vicinity": 50}])
|
||||
store.load_stop_sources()
|
||||
assert len(store.stopsDataFrames[0]['stops']) > 0
|
||||
|
||||
def test_load_geojson_stops_from_web_():
|
||||
store = stops.StopsStore([{"url": "https://datahub.bbnavi.de/export/rideshare_points.geojson", "vicinity": 50}])
|
||||
store.load_stop_sources()
|
||||
assert len(store.stopsDataFrames[0]['stops']) > 0
|
||||
|
||||
def test_find_closest_stop():
|
||||
store = stops.StopsStore([{"url": "amarillo/app/tests/stops.csv", "vicinity": 50}])
|
||||
store.load_stop_sources()
|
||||
carpool_stop = StopTime(name="start", lat=53.1191, lon=14.01577)
|
||||
stop = store.find_closest_stop(carpool_stop, 1000)
|
||||
assert stop.name=='Mitfahrbank Biesenbrow'
|
||||
23
amarillo/app/tests/test_trip_store.py
Normal file
23
amarillo/app/tests/test_trip_store.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
from amarillo.app.tests.sampledata import cp1, carpool_repeating
|
||||
from amarillo.app.services.trips import TripStore
|
||||
from amarillo.app.services.stops import StopsStore
|
||||
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def test_trip_store_put_one_time_carpool():
|
||||
trip_store = TripStore(StopsStore())
|
||||
|
||||
t = trip_store.put_carpool(cp1)
|
||||
assert t != None
|
||||
assert len(t.stop_times) >= 2
|
||||
assert t.stop_times[0].stop_id == 'mfdz:12073:001'
|
||||
assert t.stop_times[-1].stop_id == 'de:12073:900340137::3'
|
||||
|
||||
def test_trip_store_put_repeating_carpool():
|
||||
trip_store = TripStore(StopsStore())
|
||||
|
||||
t = trip_store.put_carpool(carpool_repeating)
|
||||
assert t != None
|
||||
assert len(t.stop_times) >= 2
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[project]
|
||||
name = "amarillo-core"
|
||||
version = "0.0.10"
|
||||
version = "0.0.12"
|
||||
dependencies = [
|
||||
"fastapi[all]==0.104.0",
|
||||
"geopandas==0.14",
|
||||
|
|
@ -11,6 +11,7 @@ dependencies = [
|
|||
"requests==2.31.0",
|
||||
"pyproj==3.6.1",
|
||||
"geojson-pydantic==1.0.1",
|
||||
"pytest",
|
||||
]
|
||||
|
||||
[tool.setuptools.packages]
|
||||
|
|
|
|||
|
|
@ -6,4 +6,5 @@ protobuf==3.20.3
|
|||
starlette
|
||||
requests==2.31.0
|
||||
pyproj==3.6.1
|
||||
geojson-pydantic==1.0.1
|
||||
geojson-pydantic==1.0.1
|
||||
pytest
|
||||
Loading…
Reference in a new issue