Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: run smoke tests with some GTFS datasets #35

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: smoke test with GTFS dataset

on:
workflow_call:
inputs:
feed-name:
required: true
type: string
feed-download-cmd:
required: true
type: string
feed-extract-cmd:
required: true
type: string
feed-import-glob:
required: true
type: string

jobs:
smoke-test:
name: run ${{ inputs.feed-name }} smoke test
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v2
- name: setup Node
uses: actions/setup-node@v1
with:
node-version: '16.x'

- name: install & start PostgreSQL with PostGIS
# todo: currently, it uses mdillon, which doesn't have PostgreSQL 14
# uses: huaxk/postgis-action@v1
# with:
# postgresql version: '${{ matrix.postgis-docker-tag }}'
# postgresql password: password
# postgresql user: postgres
# postgresql db: postgres
run: |
docker run -d \
-e POSTGRES_USER=$PGUSER -e POSTGRES_PASSWORD=$PGPASSWORD -e POSTGRES_DB=$PGDATABASE \
-p 5432:5432 postgis/postgis:14-3.3-alpine
env:
PGUSER: postgres
PGPASSWORD: password
PGDATABASE: postgres

- run: npm install

- name: install prerequisites
run: |
sudo apt install -y moreutils
- name: import ${{ inputs.feed-name }} GTFS
env:
PGHOST: localhost
PGPORT: '5432'
PGUSER: postgres
PGPASSWORD: password
run: |
set -e
set -o pipefail
set -x

env PGDATABASE=postgres psql -c 'create database gtfs'
export PGDATABASE=gtfs
# test DB access
psql -c 'select 1' >/dev/null

# download & extract GTFS
${{ inputs.feed-download-cmd }}
${{ inputs.feed-extract-cmd }}
# import GTFS
./cli.js -d -- ${{ inputs.feed-import-glob }} | sponge | psql -b
# test if data has been imported
psql --csv -c 'SELECT * FROM service_days LIMIT 1' | wc -l

# delete database
env PGDATABASE=postgres psql -c 'drop database gtfs'
25 changes: 25 additions & 0 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: smoke tests with GTFS datasets

on:
push:
branches:
- main
- ci-smoke-tests

jobs:
smoke-test-vbb:
name: run VBB smoke test
uses: './.github/workflows/smoke-test.yml'
with:
feed-name: VBB
feed-download-cmd: 'wget -q --compression auto -r --no-parent --no-directories -R .csv.gz -P gtfs -N "https://vbb-gtfs.jannisr.de/latest/"'
feed-extract-cmd: ''
feed-import-glob: 'gtfs/*.csv'
smoke-test-entur:
name: run Entur smoke test
uses: './.github/workflows/smoke-test.yml'
with:
feed-name: Entur
feed-download-cmd: 'wget "https://storage.googleapis.com/marduk-production/outbound/gtfs/rb_norway-aggregated-gtfs.zip" -O gtfs.zip'
feed-extract-cmd: 'unzip -d gtfs gtfs.zip'
feed-import-glob: 'gtfs/*.txt'
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- '*'
branches-ignore:
- ci-smoke-tests
pull_request:
branches:
- '*'
Expand Down