Skip to content

Commit

Permalink
Fix Docker tests and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
matteocontrini committed Apr 14, 2024
1 parent 1eee90c commit f36f29b
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 19 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Debug
run: |
ls -lah
ls -lah test
- name: Run tests
run: docker-compose -f docker-compose.tests.yml up --build
run: docker compose -f docker-compose.tests.yml up --build --abort-on-container-exit --exit-code-from tests

docker:
name: Docker build
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ $RECYCLE.BIN/

.idea

config.json
/config.json

maps/tmp/cards/
maps/tmp/maps/
Expand Down
1 change: 0 additions & 1 deletion Dockerfile.Dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM public.ecr.aws/m8i2k7g9/docker-for-terremotibot:16.13.1
LABEL mantainer Matteo Contrini <matteo@contrini.it>

# Move to /src
WORKDIR /src
Expand Down
1 change: 0 additions & 1 deletion Dockerfile.Prod
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM public.ecr.aws/m8i2k7g9/docker-for-terremotibot:16.13.1
LABEL mantainer Francesco Tonini <francesco@tonini.dev>
ENV NODE_ENV=production

# Move to /src
Expand Down
1 change: 0 additions & 1 deletion Dockerfile.Tests
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM public.ecr.aws/m8i2k7g9/docker-for-terremotibot:16.13.1
LABEL mantainer Matteo Contrini <matteo@contrini.it>

# Move to /src folder
WORKDIR /src
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ A `config.json` file should be placed in the `config` directory. The template fo

## How to run it

```js
```sh
npm ci
npm run dev
```
Expand All @@ -58,8 +58,8 @@ docker compose -f docker-compose.dev.yml up --build bot

## Run tests with Docker

You can run tests locally with Docker. This brings up a MongoDB instance used for runnig tests. After they are completed, stop Compose pressing CTRL+C (once).
You can run tests locally with Docker. This brings up a MongoDB instance used for running tests. After they are completed, stop Compose pressing CTRL+C (once).

```sh
docker-compose -f docker-compose.tests.yml up --build
docker compose -f docker-compose.tests.yml up --build
```
6 changes: 1 addition & 5 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
version: '3'

services:
bot:
container_name: bot
build:
context: .
dockerfile: Dockerfile.Dev
Expand All @@ -12,8 +9,7 @@ services:
- ./lib/config/config.json:/src/lib/config/config.json
- ./tmp:/tmp
mongo:
container_name: mongo
image: mongo:4.0.6
image: mongo:4.2.2
ports:
- "28000:27017"
logging:
Expand Down
8 changes: 2 additions & 6 deletions docker-compose.tests.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
version: '3'

services:
bot:
container_name: tests
tests:
build:
context: .
dockerfile: Dockerfile.Tests
Expand All @@ -11,8 +8,7 @@ services:
volumes:
- ./test/config.json:/src/lib/config/config.json
mongo:
container_name: mongo
image: mongo:4.2
image: mongo:4.2.2
expose:
- "27017"
logging:
Expand Down
39 changes: 39 additions & 0 deletions test/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"telegram": {
"token": "",
"serverPort": 4050
},
"botan": {
"token": ""
},
"db": {
"connectionString": "mongo/terretest"
},
"ingv": {
"pollingInterval": 60000,
"broadcastThreshold": 5
},
"social": {
"enabled": false,
"threshold": 3,
"facebook": {
"accessToken": "",
"pageId": ""
},
"twitter": {
"consumerKey": "",
"consumerSecret": "",
"accessToken": "",
"accessTokenSecret": ""
}
},
"geonames": {
"username": "demo"
},
"mapbox": {
"token": "demo"
},
"stathat": {
"key": ""
}
}

0 comments on commit f36f29b

Please sign in to comment.