diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..3cc265d --- /dev/null +++ b/.drone.yml @@ -0,0 +1,23 @@ +kind: pipeline +name: default + +steps: +- name: deploy + image: docker:cli + volumes: + - name: docker-socket + path: /var/run/docker.sock + commands: + - docker compose up --build -d + +trigger: + branch: + - main + event: + - push + +volumes: +- name: docker-socket + host: + path: /var/run/docker.sock + \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 2e516cd..0229ec3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,11 +2,13 @@ services: ggwp: build: context: . - container_name: ggwp-container + container_name: ggwp restart: unless-stopped ports: - - "4321:4321" + # https://gist.github.com/aziis98/88af12b32d9cf3eeae3929b93146fd27 + # hash2addr "ggwp.phc.dm.unipi.it" + - "127.195.127.102:1227:4321" volumes: - - /usr/share/ggwp:/app/database.local + - /var/lib/ggwp:/app/data.local environment: - - DATABASE_FILE=database.local/ggwp.db + - DATABASE_FILE=data.local/ggwp.db diff --git a/src/db/index.ts b/src/db/index.ts index b8bc171..c7c5a79 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -4,7 +4,7 @@ import type { Room, RoomData } from './model' import type { Question } from '@/ggwp' import { emitRoomUpdate } from './events' -const db = new Database(process.env.DATABASE_FILE ?? './database.local/ggwp.db') +const db = new Database(process.env.DATABASE_FILE ?? './data.local/ggwp.db') db.pragma('journal_mode = WAL') db.pragma('foreign_keys = ON') diff --git a/src/ggwp/index.test.ts b/src/ggwp/index.test.ts index 02e5614..773f807 100644 --- a/src/ggwp/index.test.ts +++ b/src/ggwp/index.test.ts @@ -14,13 +14,13 @@ describe('ggwp simple game', () => { } satisfies Game const actions = [ - { type: 'answer', team: 'B', question: 'Q1-1', outcome: 'partial' }, - { type: 'answer', team: 'B', question: 'Q2-2', outcome: 'partial' }, - { type: 'answer', team: 'A', question: 'Q1-1', outcome: 'correct' }, - { type: 'answer', team: 'A', question: 'Q1-2', outcome: 'correct' }, - { type: 'jolly', team: 'A', group: 'P1' }, - { type: 'answer', team: 'C', question: 'Q1-1', outcome: 'correct' }, - { type: 'answer', team: 'D', question: 'Q1-1', outcome: 'correct' }, + { timestamp: '?', type: 'answer', team: 'B', question: 'Q1-1', outcome: 'partial' }, + { timestamp: '?', type: 'answer', team: 'B', question: 'Q2-2', outcome: 'partial' }, + { timestamp: '?', type: 'answer', team: 'A', question: 'Q1-1', outcome: 'correct' }, + { timestamp: '?', type: 'answer', team: 'A', question: 'Q1-2', outcome: 'correct' }, + { timestamp: '?', type: 'jolly', team: 'A', group: 'P1' }, + { timestamp: '?', type: 'answer', team: 'C', question: 'Q1-1', outcome: 'correct' }, + { timestamp: '?', type: 'answer', team: 'D', question: 'Q1-1', outcome: 'correct' }, ] satisfies Action[] const scoreboard = computeScoreboardState(game, actions)