Skip to content

Commit

Permalink
Merge branch 'development' into fix/small_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Arilith authored Dec 4, 2024
2 parents 2d471d8 + c8fa07b commit 495e653
Show file tree
Hide file tree
Showing 9 changed files with 266 additions and 425 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ on:
workflow_dispatch:

jobs:
build:
runs-on: ["self-hosted", "main"]
steps:
- name: Run compose script in Deployment repository.
uses: benc-uk/workflow-dispatch@v1
with:
workflow: Deploy Docker Images of R-OV
repo: R-OV-NL/Deploy
token: ${{ secrets.SHARED_PAT }}
ref: main
# build:
# runs-on: ["self-hosted", "main"]
# steps:
# - name: Run compose script in Deployment repository.
# uses: benc-uk/workflow-dispatch@v1
# with:
# workflow: Deploy Docker Images of R-OV
# repo: R-OV-NL/Deploy
# token: ${{ secrets.SHARED_PAT }}
# ref: main
77 changes: 53 additions & 24 deletions .github/workflows/main_test.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,65 @@
name: Test service on main
name: Test service and push

on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'

workflow_dispatch:

jobs:
build:
runs-on: ["self-hosted", "main"]
build_and_test:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.SHARED_PAT }}
submodules: recursive
- name: Rebuild Compose Images
run: docker compose -f docker-compose.test.yml build --no-cache
- name: Test image with Docker Compose
run: docker compose -f docker-compose.test.yml up --force-recreate --abort-on-container-exit --exit-code-from app
- name: Build and Push Docker Image
uses: mr-smithers-excellent/docker-build-push@v5
with:
image: arilith/r_ov
registry: docker.io
tags: gtfsrt
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
compose-down:
runs-on: ["self-hosted", "main"]
if: ${{ always() }}
needs: [build]

- name: Build and start services
run: |
docker compose -f docker-compose.test.yml up -d database
sleep 10 # Adjust sleep time as needed to allow services to start
- name: Wait for database to be ready
run: |
until docker compose -f docker-compose.test.yml exec -T database pg_isready -U postgres; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
- name: Start app service
run: docker compose -f docker-compose.test.yml up --force-recreate --build --exit-code-from app app --remove-orphans

- name: Clean up
if: always()
run: docker compose -f docker-compose.test.yml down
build_and_push:
needs: build_and_test
name: Build and push to ACR
runs-on: ubuntu-latest
steps:
- name: Docker compose down
run: docker compose -f docker-compose.test.yml down
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.SHARED_PAT }}
submodules: recursive
- name: Log in to Azure Container Registry
run: |
echo "${{ secrets.AZURE_PASSWORD }}" | docker login "${{ secrets.ACR_REGISTRY }}" --username "${{ secrets.AZURE_APP_ID }}" --password-stdin
- name: Set version
run: echo "VERSION=${{ github.run_number }}" >> $GITHUB_ENV

- name: Build Docker Image with both tags
run: |
docker build -t ${{ secrets.ACR_REGISTRY }}/tristanvantriest/gtfs-rt:latest \
-t ${{ secrets.ACR_REGISTRY }}/tristanvantriest/gtfs-rt:${{ env.VERSION }} \
-f Dockerfile .
- name: Push Docker Image to ACR with both tags
run: |
docker push ${{ secrets.ACR_REGISTRY }}/tristanvantriest/gtfs-rt:latest
docker push ${{ secrets.ACR_REGISTRY }}/tristanvantriest/gtfs-rt:${{ env.VERSION }}
40 changes: 24 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test service no push.
name: Test service

on:
push:
Expand All @@ -10,24 +10,32 @@ on:
- '**'
- '!main'

workflow_dispatch:

jobs:
build:
runs-on: ["self-hosted", "main"]
build_and_test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.SHARED_PAT }}
submodules: recursive
- name: Rebuild Compose Images
run: docker compose -f docker-compose.test.yml build --no-cache
- name: Test image with Docker Compose
run: docker compose -f docker-compose.test.yml up --force-recreate --abort-on-container-exit --exit-code-from app
compose-down:
runs-on: ["self-hosted", "main"]
if: ${{ always() }}
needs: [build]
steps:
- name: Docker compose down

- name: Build and start services
run: |
docker compose -f docker-compose.test.yml up -d database
sleep 10 # Adjust sleep time as needed to allow services to start
- name: Wait for database to be ready
run: |
until docker compose -f docker-compose.test.yml exec -T database pg_isready -U postgres; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
- name: Start app service
run: docker compose -f docker-compose.test.yml up --force-recreate --build --exit-code-from app app

- name: Clean up
if: always()
run: docker compose -f docker-compose.test.yml down
Binary file modified README.md
Binary file not shown.
6 changes: 3 additions & 3 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: '3'
services:
database:
image: postgis/postgis
image: postgis/postgis:17-master
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: TestPassword123@@
POSTGRES_DB: r-ov-test
POSTGRES_DB: infoplus-rt-test
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 5s
Expand All @@ -18,7 +18,7 @@ services:
dockerfile: Dockerfile
target: test
environment:
DB_NAME: r-ov-test
DB_NAME: infoplus-rt-test
DB_HOST: database
DB_USER: postgres
DB_PASSWORD: TestPassword123@@
Expand Down
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "r-ov_protobuf_service",
"name": "infoplaza_infoplus_gtfsrt_service",
"version": "1.1.0",
"description": "The Protobuf converter for the R-OV OTP instance.",
"description": "The GTFS-RT train feed generator for the InfoPlaza OTP instance.",
"main": "main.ts",
"scripts": {
"test": "echo \"Error: no tests specified\" && exit 0",
Expand All @@ -14,20 +14,20 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/R-OV-NL/Protobuf.git"
"url": "https://github.com/infoplaza-mobility/GTFS-RT"
},
"author": "Tristan van Triest",
"license": "None",
"bugs": {
"url": "https://github.com/R-OV-NL/Protobuf/issues"
"url": "https://github.com/infoplaza-mobility/GTFS-RT/issues"
},
"homepage": "https://github.com/R-OV-NL/Protobuf#readme",
"homepage": "https://github.com/infoplaza-mobility/GTFS-RT#readme",
"dependencies": {
"@protobuf-ts/plugin": "^2.9.1",
"@turf/turf": "^6.5.0",
"axios": "^1.5.1",
"axios": "^1.7.7",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"express": "^4.21.1",
"google-protobuf": "^3.21.2",
"gtfs-rb": "^1.2.8",
"gtfs-realtime-bindings": "^1.1.1",
Expand All @@ -36,7 +36,6 @@
"ncp": "^2.0.0",
"node-fetch": "^3.3.0",
"pg": "^8.8.0",
"request": "^2.88.2",
"ts-proto": "^1.160.0",
"ts-protoc-gen": "^0.15.1-pre.a71b34e"
},
Expand Down
13 changes: 6 additions & 7 deletions src/Models/StopUpdateCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export class StopUpdateCollection extends Collection<RitInfoStopUpdate> {

//Make sure all times are increasing
this.checkIncreasingTimes();

/*
@InfoPlaza - Specific to Infoplaza IFF GTFS
Set all stop sequences sequentually irrespective of the sequence in InfoPlus
*/
this.setSequenceNumbers();
}

private setFirstStop() {
Expand Down Expand Up @@ -114,8 +120,6 @@ export class StopUpdateCollection extends Collection<RitInfoStopUpdate> {
* @param fixDeparture Whether the departure time should be fixed
*/
private fixStopTime(previousStop: RitInfoStopUpdate, currentStop: RitInfoStopUpdate, fixArrival: boolean, fixDeparture: boolean) {
console.info(`[StopUpdateCollection] Fixing stop times for stop ${currentStop.stopId}: ${currentStop.name} [${currentStop.sequence}]`)

if(fixArrival)
this.fixArrivalTime(previousStop, currentStop);

Expand Down Expand Up @@ -162,15 +166,10 @@ export class StopUpdateCollection extends Collection<RitInfoStopUpdate> {
if(stopToFix.departureDelay > 0) {
//The departure time will be the delay + the arrival time.
stopToFix.departureTime = stopToFix.arrivalTime + stopToFix.departureDelay;

//Log what was fixed, the original stop time, the new arrival time, the new departure time and the delay.
console.info(`[StopUpdateCollection] Fixed stop ${stopToFix.stopId}: ${stopToFix.name} [${stopToFix.sequence}] Arrival time: ${new Date(stopToFix.arrivalTime * 1000)} Departure time: ${new Date(stopToFix.departureTime * 1000)} Original stop time: ${orignalStopTime} seconds. Arrival delay: ${stopToFix.arrivalDelay} seconds. Departure delay: ${stopToFix.departureDelay} seconds.`);
}
//If there is no delay, we can just set the departure time to the planned departure time.
else {
stopToFix.departureTime = stopToFix.plannedDepartureTime.getTime() / 1000;
//Log what was fixed, the original stop time, the new arrival time, the new departure time and the delay.
console.info(`[StopUpdateCollection] Fixed stop ${stopToFix.stopId}: ${stopToFix.name} [${stopToFix.sequence}] Arrival time: ${new Date(stopToFix.arrivalTime * 1000)} Departure time: ${new Date(stopToFix.departureTime * 1000)} Original stop time: ${orignalStopTime} seconds. Arrival delay: ${stopToFix.arrivalDelay} seconds. Departure delay: ${stopToFix.departureDelay} seconds.`);
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/Models/TrainUpdateCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class TrainUpdateCollection extends Collection<FeedEntity> {
//We do this so we can check if this update is there the next iteration as well, if not, we add a new stop time update
//that cancels the trip.
if(trainUpdate.hasCustomTripId && !this.TrainUpdatesWithCustomTripId.find(u => u.trip.tripId == trainUpdate.trip.tripId)) {
console.log(`[TrainUpdateCollection] Adding ${trainUpdate.trip.tripId} to TrainUpdatesWithCustomTripId array.`)
// console.log(`[TrainUpdateCollection] Adding ${trainUpdate.trip.tripId} to TrainUpdatesWithCustomTripId array.`)
this.TrainUpdatesWithCustomTripId.push(trainUpdate);
}

Expand Down
Loading

0 comments on commit 495e653

Please sign in to comment.