diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml new file mode 100644 index 0000000..88a58b6 --- /dev/null +++ b/.github/workflows/smoke-test.yml @@ -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' diff --git a/.github/workflows/smoke-tests.yml b/.github/workflows/smoke-tests.yml new file mode 100644 index 0000000..436cd2f --- /dev/null +++ b/.github/workflows/smoke-tests.yml @@ -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' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2b0f965..c95e56a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,8 @@ on: push: branches: - '*' + branches-ignore: + - ci-smoke-tests pull_request: branches: - '*'