From 4b5c1cdbda79dc542dbfca8e1e434692e4d65962 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 12:16:39 +0200 Subject: [PATCH 01/24] Created test script which has an option for Postgres testing. --- server/test/integration/flows/helpers.js | 7 +- server/test/test.sh | 84 ++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100755 server/test/test.sh diff --git a/server/test/integration/flows/helpers.js b/server/test/integration/flows/helpers.js index 354a16a..f6f3251 100644 --- a/server/test/integration/flows/helpers.js +++ b/server/test/integration/flows/helpers.js @@ -1,7 +1,12 @@ import { expect } from "chai"; export async function initTestDB() { - const knex = await require('knex')({ client: 'sqlite3', connection: ':memory:'}) + // Allow different database configs - but fall back to SQLite in memory if necessary. + const config = process.env.MUDBASE_DB_CONFIG ? + JSON.parse(process.env.MUDBASE_DB_CONFIG) : + { client: 'sqlite3', connection: ':memory:' }; + console.log("Running tests with DB config: ", config); + const knex = await require('knex')(config); await knex.migrate.latest(); return knex; } diff --git a/server/test/test.sh b/server/test/test.sh new file mode 100755 index 0000000..b4196eb --- /dev/null +++ b/server/test/test.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +# Wrapper around the Jasmine test scripts. +# Can test with different types of databases. + +SCRIPT=`realpath $0` +SCRIPTPATH=`dirname $SCRIPT` +SOURCEPATH="$SCRIPTPATH/.." + +SQLITE_CONFIG='{"client": "sqlite3", "connection": ":memory:"}' +POSTGRES_CONFIG='{"client":"pg","connection":{"host":"localhost","port":9432,"user":"mudbase","password":"mudbase","database":"mudbase"}}' + +DO_SQLITE= +DO_POSTGRES= + +usage() { + cat << EOF | echo +This tool runs MuDBase's Jasmine tests. Different database back-ends can be selected (multiple is allowed too). +Options: + -s,--sqlite Use SQLite in memory for testing. + -p,--postgres Use Postgres for testing. Spins up a temporary Postgres container on localhos, port 9432. + any other option is passed on to Jasmine. +EOF +} + +# Argument parsing +PARAMS="" +while (( "$#" )); do + case "$1" in + -s|--sqlite) + DO_SQLITE=1 + shift + ;; + -p|--postgres) + DO_POSTGRES=1 + shift + ;; + *) # preserve positional arguments + PARAMS="$PARAMS $1" + shift + ;; + esac +done +# Set positional arguments in their proper place +eval set -- "$PARAMS" + +pushd $SOURCEPATH +if [ ! -z "${DO_SQLITE}" ]; then + MUDBASE_DB_CONFIG="$SQLITE_CONFIG" ./node_modules/.bin/ts-node node_modules/jasmine/bin/jasmine --config=test/jasmine.json $@ + SQLITE_RESULT=$(echo $?) +fi +if [ ! -z "${DO_POSTGRES}" ]; then + # Fire up a test Postgres. + docker pull postgres:12 + CONTAINERID=$(docker create --rm \ + --env POSTGRES_USER=mudbase \ + --env POSTGRES_PASSWORD=mudbase \ + --env POSTGRES_DB=mudbase \ + -p 9432:5432 \ + postgres:12) + docker start ${CONTAINERID} + trap "docker stop ${CONTAINERID}" EXIT + + # Wait for postgres to be ready. + while [ -z "$(docker logs ${CONTAINERID} | grep 'ready to accept connections')" ]; do + sleep 1; + done + + MUDBASE_DB_CONFIG="$POSTGRES_CONFIG" ./node_modules/.bin/ts-node node_modules/jasmine/bin/jasmine --config=test/jasmine.json $@ 2>&1 + POSTGRES_RESULT=$(echo $?) + + docker stop ${CONTAINERID} + trap - EXIT +fi + +printf "Tests finished. Results:\n\n" +if [ ! -z "${DO_SQLITE}" ]; then + echo "SQLite: $([ ${SQLITE_RESULT} == '1' ] && echo Fail || echo Success)" +fi +if [ ! -z "${DO_POSTGRES}" ]; then + echo "Postgres: $([ ${POSTGRES_RESULT} == '1' ] && echo Fail || echo Success)" +fi + +popd \ No newline at end of file -- 2.36.1 From 318bd677f0b7aa32cf6b47d141a48e819d003828 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 14:33:52 +0200 Subject: [PATCH 02/24] Fixed all except query endpoint. Grouping problems... --- .../endpoints/AlbumDetailsEndpointHandler.ts | 4 +++- .../endpoints/ArtistDetailsEndpointHandler.ts | 3 ++- .../endpoints/CreateAlbumEndpointHandler.ts | 1 + .../endpoints/CreateArtistEndpointHandler.ts | 1 + server/endpoints/CreateSongEndpointHandler.ts | 1 + server/endpoints/CreateTagEndpointHandler.ts | 5 +++- server/endpoints/QueryEndpointHandler.ts | 15 +++++++----- .../endpoints/SongDetailsEndpointHandler.ts | 3 ++- server/lib/asJson.ts | 4 ++++ server/lib/jasmine_examples/Player.js | 24 ------------------- server/lib/jasmine_examples/Song.js | 9 ------- server/migrations/20200828124218_init_db.ts | 1 + server/test/integration/flows/helpers.js | 3 +++ server/test/test.sh | 11 +++++---- 14 files changed, 38 insertions(+), 47 deletions(-) create mode 100644 server/lib/asJson.ts delete mode 100644 server/lib/jasmine_examples/Player.js delete mode 100644 server/lib/jasmine_examples/Song.js diff --git a/server/endpoints/AlbumDetailsEndpointHandler.ts b/server/endpoints/AlbumDetailsEndpointHandler.ts index f18822d..e833ff9 100644 --- a/server/endpoints/AlbumDetailsEndpointHandler.ts +++ b/server/endpoints/AlbumDetailsEndpointHandler.ts @@ -1,6 +1,7 @@ import * as api from '../../client/src/api'; import { EndpointError, EndpointHandler, catchUnhandledErrors } from './types'; import Knex from 'knex'; +import asJson from '../lib/asJson'; export const AlbumDetailsEndpointHandler: EndpointHandler = async (req: any, res: any, knex: Knex) => { if (!api.checkAlbumDetailsRequest(req)) { @@ -42,12 +43,13 @@ export const AlbumDetailsEndpointHandler: EndpointHandler = async (req: any, res await Promise.all([albumPromise, tagIdsPromise, songIdsPromise, artistIdsPromise]); // Respond to the request. + console.log("ALBUM: ", album); const response: api.AlbumDetailsResponse = { name: album['name'], artistIds: artists, tagIds: tags, songIds: songs, - storeLinks: JSON.parse(album['storeLinks']), + storeLinks: asJson(album['storeLinks']), }; await res.send(response); diff --git a/server/endpoints/ArtistDetailsEndpointHandler.ts b/server/endpoints/ArtistDetailsEndpointHandler.ts index 753e12d..ede0836 100644 --- a/server/endpoints/ArtistDetailsEndpointHandler.ts +++ b/server/endpoints/ArtistDetailsEndpointHandler.ts @@ -1,6 +1,7 @@ import * as api from '../../client/src/api'; import { EndpointError, EndpointHandler, catchUnhandledErrors } from './types'; import Knex from 'knex'; +import asJson from '../lib/asJson'; export const ArtistDetailsEndpointHandler: EndpointHandler = async (req: any, res: any, knex: Knex) => { if (!api.checkArtistDetailsRequest(req)) { @@ -24,7 +25,7 @@ export const ArtistDetailsEndpointHandler: EndpointHandler = async (req: any, re const response: api.ArtistDetailsResponse = { name: results[0].name, tagIds: tagIds, - storeLinks: JSON.parse(results[0].storeLinks), + storeLinks: asJson(results[0].storeLinks), } await res.send(response); diff --git a/server/endpoints/CreateAlbumEndpointHandler.ts b/server/endpoints/CreateAlbumEndpointHandler.ts index b35593e..e9f9509 100644 --- a/server/endpoints/CreateAlbumEndpointHandler.ts +++ b/server/endpoints/CreateAlbumEndpointHandler.ts @@ -51,6 +51,7 @@ export const CreateAlbumEndpointHandler: EndpointHandler = async (req: any, res: name: reqObject.name, storeLinks: JSON.stringify(reqObject.storeLinks || []), }) + .returning('id') // Needed for Postgres )[0]; // Link the artists via the linking table. diff --git a/server/endpoints/CreateArtistEndpointHandler.ts b/server/endpoints/CreateArtistEndpointHandler.ts index 80a19b9..155e9d2 100644 --- a/server/endpoints/CreateArtistEndpointHandler.ts +++ b/server/endpoints/CreateArtistEndpointHandler.ts @@ -41,6 +41,7 @@ export const CreateArtistEndpointHandler: EndpointHandler = async (req: any, res name: reqObject.name, storeLinks: JSON.stringify(reqObject.storeLinks || []), }) + .returning('id') // Needed for Postgres )[0]; // Link the tags via the linking table. diff --git a/server/endpoints/CreateSongEndpointHandler.ts b/server/endpoints/CreateSongEndpointHandler.ts index 0c42585..89fdf58 100644 --- a/server/endpoints/CreateSongEndpointHandler.ts +++ b/server/endpoints/CreateSongEndpointHandler.ts @@ -60,6 +60,7 @@ export const CreateSongEndpointHandler: EndpointHandler = async (req: any, res: title: reqObject.title, storeLinks: JSON.stringify(reqObject.storeLinks || []), }) + .returning('id') // Needed for Postgres )[0]; // Link the artists via the linking table. diff --git a/server/endpoints/CreateTagEndpointHandler.ts b/server/endpoints/CreateTagEndpointHandler.ts index a1ff4d6..183ed1c 100644 --- a/server/endpoints/CreateTagEndpointHandler.ts +++ b/server/endpoints/CreateTagEndpointHandler.ts @@ -40,7 +40,10 @@ export const CreateTagEndpointHandler: EndpointHandler = async (req: any, res: a if (maybeParent) { tag['parentId'] = maybeParent; } - const tagId = (await trx('tags').insert(tag))[0]; + const tagId = (await trx('tags') + .insert(tag) + .returning('id') // Needed for Postgres + )[0]; // Respond to the request. const responseObject: api.CreateTagResponse = { diff --git a/server/endpoints/QueryEndpointHandler.ts b/server/endpoints/QueryEndpointHandler.ts index 4d26a00..d8bc861 100644 --- a/server/endpoints/QueryEndpointHandler.ts +++ b/server/endpoints/QueryEndpointHandler.ts @@ -1,6 +1,7 @@ import * as api from '../../client/src/api'; import { EndpointError, EndpointHandler, catchUnhandledErrors } from './types'; import Knex from 'knex'; +import asJson from '../lib/asJson'; enum ObjectType { Song = 0, @@ -176,13 +177,13 @@ function constructQuery(knex: Knex, queryFor: ObjectType, queryElem: api.QueryEl joinObjects.delete(queryFor); // We are already querying this object in the base query. // Figure out what data we want to select from the results. - var columns: string[] = []; + var columns: any[] = []; joinObjects.forEach((obj: ObjectType) => columns.push(...objectColumns[obj])); columns.push(...objectColumns[queryFor]); // First, we create a base query for the type of object we need to yield. var q = knex.select(columns) - .distinct(objectTables[queryFor] + '.' + 'id') + .groupBy(objectTables[queryFor] + '.' + 'id') .from(objectTables[queryFor]); // Now, we need to add join statements for other objects we want to filter on. @@ -213,11 +214,13 @@ async function getLinkedObjects(knex: Knex, base: ObjectType, linked: ObjectType const columns = objectColumns[linked]; await Promise.all(baseIds.map((baseId: number) => { - return knex.select(columns).distinct(otherTable + '.id').from(otherTable) + return knex.select(columns).groupBy(otherTable + '.id').from(otherTable) .join(linkingTable, { [linkingTable + '.' + linkingTableIdNames[linked]]: otherTable + '.id' }) .where({ [linkingTable + '.' + linkingTableIdNames[base]]: baseId }) .then((others: any) => { result[baseId] = others; }) })) + + console.log("Query results for", baseIds, ":", result); return result; } @@ -309,12 +312,12 @@ export const QueryEndpointHandler: EndpointHandler = async (req: any, res: any, return { songId: song['songs.id'], title: song['songs.title'], - storeLinks: JSON.parse(song['songs.storeLinks']), + storeLinks: asJson(song['songs.storeLinks']), artists: songsArtists[song['songs.id']].map((artist: any) => { return { artistId: artist['artists.id'], name: artist['artists.name'], - storeLinks: JSON.parse(artist['artists.storeLinks']), + storeLinks: asJson(artist['artists.storeLinks']), }; }), tags: songsTags[song['songs.id']].map((tag: any) => { @@ -330,7 +333,7 @@ export const QueryEndpointHandler: EndpointHandler = async (req: any, res: any, return { artistId: artist['artists.id'], name: artist['artists.name'], - storeLinks: JSON.parse(artist['artists.storeLinks']), + storeLinks: asJson(artist['artists.storeLinks']), } }), tags: tags.map((tag: any) => { diff --git a/server/endpoints/SongDetailsEndpointHandler.ts b/server/endpoints/SongDetailsEndpointHandler.ts index 7fc3149..591e31a 100644 --- a/server/endpoints/SongDetailsEndpointHandler.ts +++ b/server/endpoints/SongDetailsEndpointHandler.ts @@ -1,6 +1,7 @@ import * as api from '../../client/src/api'; import { EndpointError, EndpointHandler, catchUnhandledErrors } from './types'; import Knex from 'knex'; +import asJson from '../lib/asJson'; export const SongDetailsEndpointHandler: EndpointHandler = async (req: any, res: any, knex: Knex) => { if (!api.checkSongDetailsRequest(req)) { @@ -51,7 +52,7 @@ export const SongDetailsEndpointHandler: EndpointHandler = async (req: any, res: tagIds: tags, artistIds: artists, albumIds: albums, - storeLinks: JSON.parse(song.storeLinks), + storeLinks: asJson(song.storeLinks), } await res.send(response); diff --git a/server/lib/asJson.ts b/server/lib/asJson.ts new file mode 100644 index 0000000..82ff955 --- /dev/null +++ b/server/lib/asJson.ts @@ -0,0 +1,4 @@ +export default function asJson(s: Object | string) { + return (typeof s === 'string') ? + JSON.parse(s) : s; +} \ No newline at end of file diff --git a/server/lib/jasmine_examples/Player.js b/server/lib/jasmine_examples/Player.js deleted file mode 100644 index fe95f89..0000000 --- a/server/lib/jasmine_examples/Player.js +++ /dev/null @@ -1,24 +0,0 @@ -function Player() { -} -Player.prototype.play = function(song) { - this.currentlyPlayingSong = song; - this.isPlaying = true; -}; - -Player.prototype.pause = function() { - this.isPlaying = false; -}; - -Player.prototype.resume = function() { - if (this.isPlaying) { - throw new Error("song is already playing"); - } - - this.isPlaying = true; -}; - -Player.prototype.makeFavorite = function() { - this.currentlyPlayingSong.persistFavoriteStatus(true); -}; - -module.exports = Player; diff --git a/server/lib/jasmine_examples/Song.js b/server/lib/jasmine_examples/Song.js deleted file mode 100644 index 3415bb8..0000000 --- a/server/lib/jasmine_examples/Song.js +++ /dev/null @@ -1,9 +0,0 @@ -function Song() { -} - -Song.prototype.persistFavoriteStatus = function(value) { - // something complicated - throw new Error("not yet implemented"); -}; - -module.exports = Song; diff --git a/server/migrations/20200828124218_init_db.ts b/server/migrations/20200828124218_init_db.ts index 81a6392..b9883e2 100644 --- a/server/migrations/20200828124218_init_db.ts +++ b/server/migrations/20200828124218_init_db.ts @@ -114,5 +114,6 @@ export async function down(knex: Knex): Promise { await knex.schema.dropTable('songs_tags'); await knex.schema.dropTable('artists_tags'); await knex.schema.dropTable('albums_tags'); + await knex.schema.dropTable('artists_albums'); } diff --git a/server/test/integration/flows/helpers.js b/server/test/integration/flows/helpers.js index f6f3251..6d2da62 100644 --- a/server/test/integration/flows/helpers.js +++ b/server/test/integration/flows/helpers.js @@ -7,6 +7,9 @@ export async function initTestDB() { { client: 'sqlite3', connection: ':memory:' }; console.log("Running tests with DB config: ", config); const knex = await require('knex')(config); + + // Undoing and doing the migrations is a test in itself. + await knex.migrate.rollback(undefined, true); await knex.migrate.latest(); return knex; } diff --git a/server/test/test.sh b/server/test/test.sh index b4196eb..4273e5f 100755 --- a/server/test/test.sh +++ b/server/test/test.sh @@ -3,6 +3,8 @@ # Wrapper around the Jasmine test scripts. # Can test with different types of databases. +set -x + SCRIPT=`realpath $0` SCRIPTPATH=`dirname $SCRIPT` SOURCEPATH="$SCRIPTPATH/.." @@ -36,17 +38,18 @@ while (( "$#" )); do shift ;; *) # preserve positional arguments - PARAMS="$PARAMS $1" + echo "Preserving params: $1" + PARAMS="$PARAMS \"$1\"" shift ;; esac done -# Set positional arguments in their proper place +# set positional arguments in their proper place eval set -- "$PARAMS" pushd $SOURCEPATH if [ ! -z "${DO_SQLITE}" ]; then - MUDBASE_DB_CONFIG="$SQLITE_CONFIG" ./node_modules/.bin/ts-node node_modules/jasmine/bin/jasmine --config=test/jasmine.json $@ + MUDBASE_DB_CONFIG="$SQLITE_CONFIG" ./node_modules/.bin/ts-node node_modules/jasmine/bin/jasmine --config=test/jasmine.json "$@" SQLITE_RESULT=$(echo $?) fi if [ ! -z "${DO_POSTGRES}" ]; then @@ -66,7 +69,7 @@ if [ ! -z "${DO_POSTGRES}" ]; then sleep 1; done - MUDBASE_DB_CONFIG="$POSTGRES_CONFIG" ./node_modules/.bin/ts-node node_modules/jasmine/bin/jasmine --config=test/jasmine.json $@ 2>&1 + MUDBASE_DB_CONFIG="$POSTGRES_CONFIG" ./node_modules/.bin/ts-node node_modules/jasmine/bin/jasmine --config=test/jasmine.json "$@" POSTGRES_RESULT=$(echo $?) docker stop ${CONTAINERID} -- 2.36.1 From d28d94c7c89e0242d8246e9764364324f98f9e46 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 14:55:09 +0200 Subject: [PATCH 03/24] All works in Postgres! --- server/endpoints/QueryEndpointHandler.ts | 10 +++++++--- server/test/test.sh | 2 -- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/server/endpoints/QueryEndpointHandler.ts b/server/endpoints/QueryEndpointHandler.ts index d8bc861..4707b32 100644 --- a/server/endpoints/QueryEndpointHandler.ts +++ b/server/endpoints/QueryEndpointHandler.ts @@ -177,9 +177,13 @@ function constructQuery(knex: Knex, queryFor: ObjectType, queryElem: api.QueryEl joinObjects.delete(queryFor); // We are already querying this object in the base query. // Figure out what data we want to select from the results. - var columns: any[] = []; - joinObjects.forEach((obj: ObjectType) => columns.push(...objectColumns[obj])); - columns.push(...objectColumns[queryFor]); + var columns: any[] = objectColumns[queryFor]; + + // TODO: there was a line here to add columns for the joined objects. + // Could not get it to work with Postgres, which wants aggregate functions + // to specify exactly how duplicates should be aggregated. + // Not sure whether we need these columns in the first place. + // joinObjects.forEach((obj: ObjectType) => columns.push(...objectColumns[obj])); // First, we create a base query for the type of object we need to yield. var q = knex.select(columns) diff --git a/server/test/test.sh b/server/test/test.sh index 4273e5f..b5c72f8 100755 --- a/server/test/test.sh +++ b/server/test/test.sh @@ -3,8 +3,6 @@ # Wrapper around the Jasmine test scripts. # Can test with different types of databases. -set -x - SCRIPT=`realpath $0` SCRIPTPATH=`dirname $SCRIPT` SOURCEPATH="$SCRIPTPATH/.." -- 2.36.1 From 0d400bedd70e7d30f512f9e9759e247161295a10 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 15:33:24 +0200 Subject: [PATCH 04/24] Re-enabled client compile. Created Dockerfile for postgres_node. --- .drone.yml | 35 +++++++++++++++++------------------ ci/postgres_node/Dockerfile | 8 ++++++++ 2 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 ci/postgres_node/Dockerfile diff --git a/.drone.yml b/.drone.yml index 197911f..cdb3ee9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,21 +15,20 @@ steps: - cd server && npm test; cd .. -#kind: pipeline -#type: kubernetes -#name: front-end -# -#steps: -#- name: install dependencies -# image: node -# commands: -# - npm install -# - cd client && npm install; cd .. -# -#- name: front-end build -# image: node -# commands: -# - cd client && npm run-script build; cd .. -# -#--- -# \ No newline at end of file +kind: pipeline +type: kubernetes +name: front-end + +steps: +- name: install dependencies + image: node + commands: + - npm install + - cd client && npm install; cd .. + +- name: front-end compile + image: node + commands: + - cd client && ./node_modules/.bin/tsc; cd .. + +--- diff --git a/ci/postgres_node/Dockerfile b/ci/postgres_node/Dockerfile new file mode 100644 index 0000000..539b24c --- /dev/null +++ b/ci/postgres_node/Dockerfile @@ -0,0 +1,8 @@ +# Note: this Dockerfile is written to be executed with the whole source +# as its context. + +FROM postgres:12 + +# Install node.js +RUN apt update -y && apt install -y npm + -- 2.36.1 From d91ca7b5baba7360fe85ad1cf5a5e5be7c6d013b Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 15:41:44 +0200 Subject: [PATCH 05/24] Attempt to start build from the postgres Node container. --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index cdb3ee9..424c115 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4,7 +4,7 @@ name: back-end steps: - name: install dependencies - image: node + image: sandervocke/postgres_node:12 commands: - npm install - cd server && npm install; cd .. -- 2.36.1 From 9c79c751fe5404089aef15f1ed4cb9c9d86ca2dc Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 15:43:05 +0200 Subject: [PATCH 06/24] Drone syntax --- .drone.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index 424c115..7b6de8f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,7 +14,8 @@ steps: commands: - cd server && npm test; cd .. - +--- + kind: pipeline type: kubernetes name: front-end @@ -24,11 +25,11 @@ steps: image: node commands: - npm install - - cd client && npm install; cd .. + - cd client && npm install; cd .. - name: front-end compile - image: node - commands: - - cd client && ./node_modules/.bin/tsc; cd .. + image: node + commands: + - cd client && ./node_modules/.bin/tsc; cd .. --- -- 2.36.1 From 85a0b0671fbab15cd26d85ef35d165dd0b83e47f Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 15:44:10 +0200 Subject: [PATCH 07/24] Drone syntax. --- .drone.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7b6de8f..5dfb8dc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,7 +15,6 @@ steps: - cd server && npm test; cd .. --- - kind: pipeline type: kubernetes name: front-end @@ -31,5 +30,3 @@ steps: image: node commands: - cd client && ./node_modules/.bin/tsc; cd .. - ---- -- 2.36.1 From 41a0987d02506142106aa888db4d1f457c5edd7b Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 16:28:29 +0200 Subject: [PATCH 08/24] Attempt Postgres CI build. --- .drone.yml | 10 +++++-- server/test/test.sh | 72 +++++++++++++++++++++++++++++++++------------ 2 files changed, 61 insertions(+), 21 deletions(-) diff --git a/.drone.yml b/.drone.yml index 5dfb8dc..d19acf1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -9,10 +9,16 @@ steps: - npm install - cd server && npm install; cd .. -- name: back-end test +- name: back-end test (SQLite3) image: node commands: - - cd server && npm test; cd .. + - cd server && ./test/test.sh --sqlite ; cd .. + +- name: back-end test (PostgreSQL) + image: node + commands: + - POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_DB=mudbase \ + cd server && ./test/test.sh --postgres --start-postgres-testcontainer ; cd .. --- kind: pipeline diff --git a/server/test/test.sh b/server/test/test.sh index b5c72f8..e088401 100755 --- a/server/test/test.sh +++ b/server/test/test.sh @@ -12,13 +12,17 @@ POSTGRES_CONFIG='{"client":"pg","connection":{"host":"localhost","port":9432,"us DO_SQLITE= DO_POSTGRES= +START_POSTGRES= +START_POSTGRES_TESTCONTAINER= usage() { cat << EOF | echo This tool runs MuDBase's Jasmine tests. Different database back-ends can be selected (multiple is allowed too). Options: - -s,--sqlite Use SQLite in memory for testing. - -p,--postgres Use Postgres for testing. Spins up a temporary Postgres container on localhos, port 9432. + -s,--sqlite Use SQLite in memory for testing. + -p,--postgres Use Postgres for testing. Spins up a temporary Postgres container on localhos, port 9432. + -sp,--start-postgres Start its own Postgres Docker container for testing against. + -spt,--start-postgres-testcontainer Assume running in the sandervocke/postgres_node container. Spin up a PG process. any other option is passed on to Jasmine. EOF } @@ -35,6 +39,14 @@ while (( "$#" )); do DO_POSTGRES=1 shift ;; + -sp|--start-postgres) + START_POSTGRES=1 + shift + ;; + -spt|--start-postgres-testcontainer) + START_POSTGRES_TESTCONTAINER=1 + shift + ;; *) # preserve positional arguments echo "Preserving params: $1" PARAMS="$PARAMS \"$1\"" @@ -51,27 +63,45 @@ if [ ! -z "${DO_SQLITE}" ]; then SQLITE_RESULT=$(echo $?) fi if [ ! -z "${DO_POSTGRES}" ]; then - # Fire up a test Postgres. - docker pull postgres:12 - CONTAINERID=$(docker create --rm \ - --env POSTGRES_USER=mudbase \ - --env POSTGRES_PASSWORD=mudbase \ - --env POSTGRES_DB=mudbase \ - -p 9432:5432 \ - postgres:12) - docker start ${CONTAINERID} - trap "docker stop ${CONTAINERID}" EXIT + if [ ! -z "${START_POSTGRES}" ]; then + # Fire up a test Postgres. + docker pull postgres:12 + CONTAINERID=$(docker create --rm \ + --env POSTGRES_USER=mudbase \ + --env POSTGRES_PASSWORD=mudbase \ + --env POSTGRES_DB=mudbase \ + -p 9432:5432 \ + postgres:12) + docker start ${CONTAINERID} + trap "docker stop ${CONTAINERID}" EXIT - # Wait for postgres to be ready. - while [ -z "$(docker logs ${CONTAINERID} | grep 'ready to accept connections')" ]; do - sleep 1; - done + # Wait for postgres to be ready. + while true; do + pg_isready -d mudbase -h localhost -p 9432 -U mudbase + [ "$(echo $?)" == "0" ] && break + sleep 1 + done + elif [ ! -z "${START_POSTGRES_TESTCONTAINER}" ]; then + # Fire up a test Postgres process. + docker_entrypoint.sh postgres & + PID=$(echo $!) + trap "kill $PID" EXIT + + # Wait for postgres to be ready. + while true; do + pg_isready -d mudbase -h localhost -p 5432 -U mudbase + [ "$(echo $?)" == "0" ] && break + sleep 1 + done + fi MUDBASE_DB_CONFIG="$POSTGRES_CONFIG" ./node_modules/.bin/ts-node node_modules/jasmine/bin/jasmine --config=test/jasmine.json "$@" POSTGRES_RESULT=$(echo $?) - docker stop ${CONTAINERID} - trap - EXIT + if [ ! -z "${START_POSTGRES}" ]; then + docker stop ${CONTAINERID} + trap - EXIT + fi fi printf "Tests finished. Results:\n\n" @@ -82,4 +112,8 @@ if [ ! -z "${DO_POSTGRES}" ]; then echo "Postgres: $([ ${POSTGRES_RESULT} == '1' ] && echo Fail || echo Success)" fi -popd \ No newline at end of file +popd + +[ "${SQLITE_RESULT}" == '1' -o "${POSTGRES_RESULT}" == '1' ] && exit 1 +exit 0 + -- 2.36.1 From 9d437163b884fa6a5198ce7bf5142fa0794377c4 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 16:33:14 +0200 Subject: [PATCH 09/24] Another try. --- .drone.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index d19acf1..00491d7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,37 +2,43 @@ kind: pipeline type: kubernetes name: back-end +workspace: + path: /drone/src + steps: - name: install dependencies image: sandervocke/postgres_node:12 commands: - npm install - - cd server && npm install; cd .. + - cd /drone/src/server && npm install - name: back-end test (SQLite3) image: node commands: - - cd server && ./test/test.sh --sqlite ; cd .. + - cd /drone/src/server && ./test/test.sh --sqlite - name: back-end test (PostgreSQL) image: node commands: - POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_DB=mudbase \ - cd server && ./test/test.sh --postgres --start-postgres-testcontainer ; cd .. + cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer --- kind: pipeline type: kubernetes name: front-end +workspace: + path: /drone/src + steps: - name: install dependencies image: node commands: - - npm install - - cd client && npm install; cd .. + - cd /drone/src && npm install + - cd /drone/src/client && npm install - name: front-end compile image: node commands: - - cd client && ./node_modules/.bin/tsc; cd .. + - cd /drone/src/client && ./node_modules/.bin/tsc; cd .. -- 2.36.1 From 0f7c391a416f90400fc02dd6a0fd555946620466 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 16:43:51 +0200 Subject: [PATCH 10/24] Trial n error --- .drone.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 00491d7..105e23b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,8 +20,7 @@ steps: - name: back-end test (PostgreSQL) image: node commands: - - POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_DB=mudbase \ - cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer + - /bin/bash -c "POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_DB=mudbase cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer" --- kind: pipeline -- 2.36.1 From cdb38b000df36caf83589857854f87fee76c3db8 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 16:44:39 +0200 Subject: [PATCH 11/24] Quick iteration --- .drone.yml | 56 +++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/.drone.yml b/.drone.yml index 105e23b..c4bb821 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,38 +6,38 @@ workspace: path: /drone/src steps: -- name: install dependencies - image: sandervocke/postgres_node:12 - commands: - - npm install - - cd /drone/src/server && npm install +#- name: install dependencies +# image: sandervocke/postgres_node:12 +# commands: +# - npm install +# - cd /drone/src/server && npm install -- name: back-end test (SQLite3) - image: node - commands: - - cd /drone/src/server && ./test/test.sh --sqlite +#- name: back-end test (SQLite3) +# image: node +# commands: +# - cd /drone/src/server && ./test/test.sh --sqlite - name: back-end test (PostgreSQL) image: node commands: - /bin/bash -c "POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_DB=mudbase cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer" ---- -kind: pipeline -type: kubernetes -name: front-end - -workspace: - path: /drone/src - -steps: -- name: install dependencies - image: node - commands: - - cd /drone/src && npm install - - cd /drone/src/client && npm install - -- name: front-end compile - image: node - commands: - - cd /drone/src/client && ./node_modules/.bin/tsc; cd .. +# --- +# kind: pipeline +# type: kubernetes +# name: front-end + +# workspace: +# path: /drone/src + +# steps: +# - name: install dependencies +# image: node +# commands: +# - cd /drone/src && npm install +# - cd /drone/src/client && npm install + +# - name: front-end compile +# image: node +# commands: +# - cd /drone/src/client && ./node_modules/.bin/tsc; cd .. -- 2.36.1 From 3cb106316e0d284c3635ef531be4ee3855c7c36c Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 16:46:45 +0200 Subject: [PATCH 12/24] Try again. --- .drone.yml | 3 ++- server/test/test.sh | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index c4bb821..83e3108 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,7 +20,8 @@ steps: - name: back-end test (PostgreSQL) image: node commands: - - /bin/bash -c "POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_DB=mudbase cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer" + - /bin/bash -c "POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_DB=mudbase \ + cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer" # --- # kind: pipeline diff --git a/server/test/test.sh b/server/test/test.sh index e088401..7c2cca6 100755 --- a/server/test/test.sh +++ b/server/test/test.sh @@ -83,13 +83,13 @@ if [ ! -z "${DO_POSTGRES}" ]; then done elif [ ! -z "${START_POSTGRES_TESTCONTAINER}" ]; then # Fire up a test Postgres process. - docker_entrypoint.sh postgres & + /docker_entrypoint.sh postgres & PID=$(echo $!) trap "kill $PID" EXIT # Wait for postgres to be ready. while true; do - pg_isready -d mudbase -h localhost -p 5432 -U mudbase + /usr/bin/pg_isready -d mudbase -h localhost -p 5432 -U mudbase [ "$(echo $?)" == "0" ] && break sleep 1 done -- 2.36.1 From 891efab4c99066e81f31c128bfe4122cf7732fb5 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 16:47:42 +0200 Subject: [PATCH 13/24] Again. --- .drone.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 83e3108..c4bb821 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,8 +20,7 @@ steps: - name: back-end test (PostgreSQL) image: node commands: - - /bin/bash -c "POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_DB=mudbase \ - cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer" + - /bin/bash -c "POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_DB=mudbase cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer" # --- # kind: pipeline -- 2.36.1 From 534b61f13b2991faefe3b2b76d68858822a83ddb Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 16:48:45 +0200 Subject: [PATCH 14/24] Again. --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index c4bb821..e36dfa1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,12 +13,12 @@ steps: # - cd /drone/src/server && npm install #- name: back-end test (SQLite3) -# image: node +# image: sandervocke/postgres_node:12 # commands: # - cd /drone/src/server && ./test/test.sh --sqlite - name: back-end test (PostgreSQL) - image: node + image: sandervocke/postgres_node:12 commands: - /bin/bash -c "POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_DB=mudbase cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer" -- 2.36.1 From cf739520945679124cbc7ba6949a25a968746b2a Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 16:50:44 +0200 Subject: [PATCH 15/24] Again. --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index e36dfa1..440ea1b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,7 +20,7 @@ steps: - name: back-end test (PostgreSQL) image: sandervocke/postgres_node:12 commands: - - /bin/bash -c "POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_DB=mudbase cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer" + - POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_DB=mudbase cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer # --- # kind: pipeline -- 2.36.1 From e4bfe5a9204a7d3b28f14977159d623e879f1993 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 16:56:25 +0200 Subject: [PATCH 16/24] Again --- server/test/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/test/test.sh b/server/test/test.sh index 7c2cca6..9d3e4ed 100755 --- a/server/test/test.sh +++ b/server/test/test.sh @@ -83,7 +83,7 @@ if [ ! -z "${DO_POSTGRES}" ]; then done elif [ ! -z "${START_POSTGRES_TESTCONTAINER}" ]; then # Fire up a test Postgres process. - /docker_entrypoint.sh postgres & + /docker-entrypoint.sh postgres & PID=$(echo $!) trap "kill $PID" EXIT -- 2.36.1 From d5751b98b6e6d44ecbefd506ff7cf6375087eec1 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 16:58:33 +0200 Subject: [PATCH 17/24] Again. --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 440ea1b..f509374 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,7 +20,7 @@ steps: - name: back-end test (PostgreSQL) image: sandervocke/postgres_node:12 commands: - - POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_DB=mudbase cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer + - POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_PASSWORD=mudbase cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer # --- # kind: pipeline -- 2.36.1 From 3a20912da9693062df0905dd0df778c8c3256947 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 17:00:47 +0200 Subject: [PATCH 18/24] Again. --- .drone.yml | 2 +- server/test/test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index f509374..3df5710 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,7 +20,7 @@ steps: - name: back-end test (PostgreSQL) image: sandervocke/postgres_node:12 commands: - - POSTGRES_USER=mudbase POSTGRES_DATABASE=mudbase POSTGRES_PASSWORD=mudbase cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer + - cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer # --- # kind: pipeline diff --git a/server/test/test.sh b/server/test/test.sh index 9d3e4ed..687b344 100755 --- a/server/test/test.sh +++ b/server/test/test.sh @@ -83,7 +83,7 @@ if [ ! -z "${DO_POSTGRES}" ]; then done elif [ ! -z "${START_POSTGRES_TESTCONTAINER}" ]; then # Fire up a test Postgres process. - /docker-entrypoint.sh postgres & + POSTGRES_USER=mudbase POSTGRES_PASSWORD=mudbase POSTGRES_DATABASE=mudbase /docker-entrypoint.sh postgres & PID=$(echo $!) trap "kill $PID" EXIT -- 2.36.1 From 00627443d5e3a0733b44b37731b798fd5461cbf3 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 17:06:10 +0200 Subject: [PATCH 19/24] Again. --- server/test/test.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/test/test.sh b/server/test/test.sh index 687b344..3093795 100755 --- a/server/test/test.sh +++ b/server/test/test.sh @@ -74,7 +74,6 @@ if [ ! -z "${DO_POSTGRES}" ]; then postgres:12) docker start ${CONTAINERID} trap "docker stop ${CONTAINERID}" EXIT - # Wait for postgres to be ready. while true; do pg_isready -d mudbase -h localhost -p 9432 -U mudbase @@ -86,7 +85,6 @@ if [ ! -z "${DO_POSTGRES}" ]; then POSTGRES_USER=mudbase POSTGRES_PASSWORD=mudbase POSTGRES_DATABASE=mudbase /docker-entrypoint.sh postgres & PID=$(echo $!) trap "kill $PID" EXIT - # Wait for postgres to be ready. while true; do /usr/bin/pg_isready -d mudbase -h localhost -p 5432 -U mudbase -- 2.36.1 From e5b226a698a460a6abfd02a85152fbb8b217b41c Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 17:07:44 +0200 Subject: [PATCH 20/24] Again. --- .drone.yml | 2 +- server/test/test.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 3df5710..7e73e31 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,7 +20,7 @@ steps: - name: back-end test (PostgreSQL) image: sandervocke/postgres_node:12 commands: - - cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer + - cd /drone/src/server && ls -la . && ls -la node_modules && ./test/test.sh --postgres --start-postgres-testcontainer # --- # kind: pipeline diff --git a/server/test/test.sh b/server/test/test.sh index 3093795..5e2737d 100755 --- a/server/test/test.sh +++ b/server/test/test.sh @@ -3,6 +3,8 @@ # Wrapper around the Jasmine test scripts. # Can test with different types of databases. +set -e + SCRIPT=`realpath $0` SCRIPTPATH=`dirname $SCRIPT` SOURCEPATH="$SCRIPTPATH/.." -- 2.36.1 From 4ffc2aa0ec229f566ef8ad07bda6098fba6eaba3 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 17:09:43 +0200 Subject: [PATCH 21/24] Again. --- .drone.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7e73e31..62adbcf 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,11 +6,11 @@ workspace: path: /drone/src steps: -#- name: install dependencies -# image: sandervocke/postgres_node:12 -# commands: -# - npm install -# - cd /drone/src/server && npm install +- name: install dependencies + image: sandervocke/postgres_node:12 + commands: + - npm install + - cd /drone/src/server && npm install #- name: back-end test (SQLite3) # image: sandervocke/postgres_node:12 @@ -20,7 +20,7 @@ steps: - name: back-end test (PostgreSQL) image: sandervocke/postgres_node:12 commands: - - cd /drone/src/server && ls -la . && ls -la node_modules && ./test/test.sh --postgres --start-postgres-testcontainer + - cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer # --- # kind: pipeline -- 2.36.1 From 6f4458e6734377853c9684627a5baea903ff8f31 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 17:11:11 +0200 Subject: [PATCH 22/24] Again. --- server/test/test.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/test/test.sh b/server/test/test.sh index 5e2737d..3093795 100755 --- a/server/test/test.sh +++ b/server/test/test.sh @@ -3,8 +3,6 @@ # Wrapper around the Jasmine test scripts. # Can test with different types of databases. -set -e - SCRIPT=`realpath $0` SCRIPTPATH=`dirname $SCRIPT` SOURCEPATH="$SCRIPTPATH/.." -- 2.36.1 From 6bdaa5c6fd2b5dd79310fec5c7bb1433acd7387e Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 17:12:49 +0200 Subject: [PATCH 23/24] Again. --- server/test/test.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/test/test.sh b/server/test/test.sh index 3093795..dc7e7d9 100755 --- a/server/test/test.sh +++ b/server/test/test.sh @@ -8,7 +8,7 @@ SCRIPTPATH=`dirname $SCRIPT` SOURCEPATH="$SCRIPTPATH/.." SQLITE_CONFIG='{"client": "sqlite3", "connection": ":memory:"}' -POSTGRES_CONFIG='{"client":"pg","connection":{"host":"localhost","port":9432,"user":"mudbase","password":"mudbase","database":"mudbase"}}' +POSTGRES_CONFIG='{"client":"pg","connection":{"host":"localhost","port":5432,"user":"mudbase","password":"mudbase","database":"mudbase"}}' DO_SQLITE= DO_POSTGRES= @@ -70,13 +70,13 @@ if [ ! -z "${DO_POSTGRES}" ]; then --env POSTGRES_USER=mudbase \ --env POSTGRES_PASSWORD=mudbase \ --env POSTGRES_DB=mudbase \ - -p 9432:5432 \ + -p 5432:5432 \ postgres:12) docker start ${CONTAINERID} trap "docker stop ${CONTAINERID}" EXIT # Wait for postgres to be ready. while true; do - pg_isready -d mudbase -h localhost -p 9432 -U mudbase + pg_isready -d mudbase -h localhost -p 5432 -U mudbase [ "$(echo $?)" == "0" ] && break sleep 1 done -- 2.36.1 From c6eb489a49cb8a7f3a50de50c35f2abb83573204 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 17:14:22 +0200 Subject: [PATCH 24/24] Everything seems to work. Re-enabling other CI steps. --- .drone.yml | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/.drone.yml b/.drone.yml index 62adbcf..140eae7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,32 +12,32 @@ steps: - npm install - cd /drone/src/server && npm install -#- name: back-end test (SQLite3) -# image: sandervocke/postgres_node:12 -# commands: -# - cd /drone/src/server && ./test/test.sh --sqlite +- name: back-end test (SQLite3) + image: sandervocke/postgres_node:12 + commands: + - cd /drone/src/server && ./test/test.sh --sqlite - name: back-end test (PostgreSQL) image: sandervocke/postgres_node:12 commands: - cd /drone/src/server && ./test/test.sh --postgres --start-postgres-testcontainer -# --- -# kind: pipeline -# type: kubernetes -# name: front-end - -# workspace: -# path: /drone/src - -# steps: -# - name: install dependencies -# image: node -# commands: -# - cd /drone/src && npm install -# - cd /drone/src/client && npm install - -# - name: front-end compile -# image: node -# commands: -# - cd /drone/src/client && ./node_modules/.bin/tsc; cd .. +--- +kind: pipeline +type: kubernetes +name: front-end + +workspace: + path: /drone/src + +steps: +- name: install dependencies + image: node + commands: + - cd /drone/src && npm install + - cd /drone/src/client && npm install + +- name: front-end compile + image: node + commands: + - cd /drone/src/client && ./node_modules/.bin/tsc; cd .. -- 2.36.1