Skip to content

Commit

Permalink
Merge pull request #14 from HSLdevcom/filter-problematic-headsigns
Browse files Browse the repository at this point in the history
Filter problematic headsigns
  • Loading branch information
vesameskanen authored Dec 1, 2020
2 parents f34de57 + e042101 commit 7361e9b
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 53 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/dev-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Process master push or pr
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
docker-push:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build docker image from master and push it
run: ./.github/workflows/scripts/build_and_push_dev.sh
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_AUTH: ${{ secrets.DOCKER_AUTH }}
DOCKER_BASE_TAG: latest
25 changes: 25 additions & 0 deletions .github/workflows/prod-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build prod from release
on:
release:
types:
- published
jobs:
prod-push:
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Check Tag
id: check-tag
run: |
if [[ ${GITHUB_REF##*/} =~ ^202[0-9][0-1][0-9][0-3][0-9]$ ]]; then
echo ::set-output name=match::true
fi
- name: Push latest image as prod
if: steps.check-tag.outputs.match == 'true'
run: ./.github/workflows/scripts/push_prod.sh
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_AUTH: ${{ secrets.DOCKER_AUTH }}
DOCKER_BASE_TAG: prod
DOCKER_DEV_TAG: latest
23 changes: 23 additions & 0 deletions .github/workflows/scripts/build_and_push_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -e

DOCKER_IMAGE="hsldevcom/gtfsrthttp2mqtt"
DOCKER_TAG=${DOCKER_BASE_TAG:-latest}

COMMIT_HASH=$(git rev-parse --short "$GITHUB_SHA")

DOCKER_TAG_LONG=$DOCKER_TAG-$(date +"%Y-%m-%dT%H.%M.%S")-$COMMIT_HASH
DOCKER_IMAGE_TAG=$DOCKER_IMAGE:$DOCKER_TAG
DOCKER_IMAGE_TAG_LONG=$DOCKER_IMAGE:$DOCKER_TAG_LONG

# Build image
echo "Building gtfsrthttp2mqtt"
docker build --tag=$DOCKER_IMAGE_TAG_LONG .

docker login -u $DOCKER_USER -p $DOCKER_AUTH
echo "Pushing $DOCKER_TAG image"
docker push $DOCKER_IMAGE_TAG_LONG
docker tag $DOCKER_IMAGE_TAG_LONG $DOCKER_IMAGE_TAG
docker push $DOCKER_IMAGE_TAG

echo Build completed
24 changes: 24 additions & 0 deletions .github/workflows/scripts/push_prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -e

DOCKER_IMAGE="hsldevcom/gtfsrthttp2mqtt"
DOCKER_TAG=${DOCKER_BASE_TAG:-prod}
DOCKER_DEV_TAG=${DOCKER_DEV_TAG:-latest}

COMMIT_HASH=$(git rev-parse --short "$GITHUB_SHA")

DOCKER_TAG_LONG=$DOCKER_TAG-$(date +"%Y-%m-%dT%H.%M.%S")-$COMMIT_HASH
DOCKER_IMAGE_TAG=$DOCKER_IMAGE:$DOCKER_TAG
DOCKER_IMAGE_TAG_LONG=$DOCKER_IMAGE:$DOCKER_TAG_LONG
DOCKER_IMAGE_DEV=$DOCKER_IMAGE:$DOCKER_DEV_TAG

docker login -u $DOCKER_USER -p $DOCKER_AUTH

echo "processing prod release"
docker pull $DOCKER_IMAGE_DEV
docker tag $DOCKER_IMAGE_DEV $DOCKER_IMAGE_TAG
docker tag $DOCKER_IMAGE_DEV $DOCKER_IMAGE_TAG_LONG
docker push $DOCKER_IMAGE_TAG
docker push $DOCKER_IMAGE_TAG_LONG

echo Build completed
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

37 changes: 0 additions & 37 deletions build-docker-image.sh

This file was deleted.

3 changes: 3 additions & 0 deletions gtfsrthttp2mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def doGTFSRTPolling(self):
route_id = utils.parse_route_id(self.feedName, entity.vehicle.trip.route_id, trip_id, self.OTPData)
direction_id = utils.parse_direction_id(self.feedName, entity.vehicle.trip.direction_id, trip_id, self.OTPData)
trip_headsign = entity.vehicle.vehicle.label
# headsigns with / cause problems in topics
if '/' in trip_headsign:
trip_headsign = ''
latitude = "{:.6f}".format(entity.vehicle.position.latitude) # Force coordinates to have 6 numbers
latitude_head = latitude[:2]
longitude = "{:.6f}".format(entity.vehicle.position.longitude)
Expand Down
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
certifi==2018.11.29
chardet==3.0.4
get==2018.11.19
idna==2.8
paho-mqtt==1.4.0
post==2018.11.20
protobuf==3.6.1
public==2018.11.20
query-string==2018.11.20
request==2018.11.20
requests==2.22.0
six==1.12.0
urllib3==1.25.6

0 comments on commit 7361e9b

Please sign in to comment.