Skip to content

Commit

Permalink
ci: Add check for matching realtime feed names
Browse files Browse the repository at this point in the history
  • Loading branch information
jbruechert committed Mar 3, 2024
1 parent 5cd829c commit cc5b0b9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-import.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ jobs:
run: |
find . -type d -exec chmod 777 {} \;
docker run -v $PWD:/transitous -w /transitous transitous ci/fetch-feeds.py merge-request
docker run -v $PWD:/transitous -w /transitous transitous src/generate-motis-config.py full
4 changes: 2 additions & 2 deletions feeds/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@
{
"name": "Metrolinx-orangeville",
"type": "transitland-atlas",
"transitland-atlas-id": "f-orangeville~on~ca~rt"
"transitland-atlas-id": "f-orangeville~transit~ca"
},
{
"name": "Metrolinx-orangeville",
"type": "transitland-atlas",
"transitland-atlas-id": "f-orangeville~transit~ca"
"transitland-atlas-id": "f-orangeville~on~ca~rt"
},
{
"name": "Metrolinx-orillia",
Expand Down
7 changes: 2 additions & 5 deletions src/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from metadata import *
from pathlib import Path
from datetime import datetime, timezone
import email.utils
from utils import eprint

import email.utils
import requests
import transitland
import json
Expand All @@ -17,10 +18,6 @@
import shutil


def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)


def validate_source_name(name: str):
if " " in name:
eprint(f"Error: Feed names must not contain spaces, found {name}.")
Expand Down
12 changes: 12 additions & 0 deletions src/generate-motis-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from pathlib import Path
from jinja2 import Template
from utils import eprint


if __name__ == "__main__":
Expand Down Expand Up @@ -56,6 +57,17 @@
"path": schedule_file
})
case "gtfs-rt" if isinstance(source, metadata.UrlSource):
referenced_static_feed = list(filter(
lambda f: f["id"] == schedule_name, gtfs_feeds))

if not referenced_static_feed:
eprint("Error: The name of a realtime (gtfs-rt) "
+ "feed needs to match the name of its "
+ "static base feed defined before the "
+ "realtime feed. Found nothing "
+ "belonging to", source.name)
sys.exit(1)

gtfsrt_feeds.append({
"id": schedule_name,
"url": source.url,
Expand Down

0 comments on commit cc5b0b9

Please sign in to comment.