From 4e88ef2bf383091ff5f0da69c5e2dfb5d52a0f40 Mon Sep 17 00:00:00 2001 From: Raphael Kabo Date: Fri, 12 May 2023 22:34:44 +0100 Subject: Add CI workflow --- .github/workflows/ci.yaml | 36 ++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..882c2c9 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,36 @@ +name: Build test +on: + pull_request: + workflow_dispatch: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: pnpm/action-setup@v2 + with: + version: 8 + - uses: actions/setup-node@v3 + with: + node-version-file: ".nvmrc" + cache: "pnpm" + cache-dependency-path: "pnpm-lock.yaml" + - name: Install dependencies + run: pnpm install + - name: Set up config files + run: | + cp src/config/api-example.js src/config/api.js + cp src/config/database-example.js src/config/database.js + cp src/config/domain-example.js src/config/domain.js + - name: Build + run: pnpm build + continue-on-error: true + - name: Start and test + run: | + pnpm start & + sleep 5 + curl -sSf http://localhost:3000 diff --git a/package.json b/package.json index d765c0e..a00a53a 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "build": "tsc", "start": "node dist/start.js", - "dev": "nodemon -e ts,js --watch src --exec \"pnpm run build ; pnpm run start\"" + "dev": "nodemon -e ts,js --watch src --exec \"pnpm run build ; pnpm run start\"", + "test": "./test.sh" }, "engines": { "node": ">=16.16.0" -- cgit v1.2.3 From 090a44df57cec84e460462f0ae2db7fb4f87a7e9 Mon Sep 17 00:00:00 2001 From: Raphael Kabo Date: Fri, 12 May 2023 22:56:21 +0100 Subject: Rename and move old Docker test script --- scripts/docker-test.sh | 20 ++++++++++++++++++++ test.sh | 15 --------------- 2 files changed, 20 insertions(+), 15 deletions(-) create mode 100755 scripts/docker-test.sh delete mode 100755 test.sh diff --git a/scripts/docker-test.sh b/scripts/docker-test.sh new file mode 100755 index 0000000..1cba254 --- /dev/null +++ b/scripts/docker-test.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# A Docker-based test script. It builds the Docker image, starts the container, +# and then waits for the server to be ready. Once the server is ready, it +# makes a request to the server and then kills the container. A 200 response +# code is expected. + +set -eux -o pipefail + +cleanup() { + docker-compose kill +} +trap cleanup 0 + +docker-compose up --build & + +while [[ "$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/)" -ne "200" ]]; do sleep 5; done +curl -v http://localhost:3000/new/event/public + +cleanup \ No newline at end of file diff --git a/test.sh b/test.sh deleted file mode 100755 index 6626437..0000000 --- a/test.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -set -eux -o pipefail - -cleanup() { - docker-compose kill -} -trap cleanup 0 - -docker-compose up --build & - -while [[ "$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/)" -ne "200" ]]; do sleep 5; done -curl -v http://localhost:3000/new/event/public - -cleanup \ No newline at end of file -- cgit v1.2.3