Skip to content

Commit

Permalink
shorter wait for db time for github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
my-opencode committed Aug 16, 2024
1 parent 0aab0fd commit 2dcbbfa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion back/database/connector.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { describe, it, after, before } from "node:test";
import * as assert from "node:assert";
import mysql, { FieldPacket, RowDataPacket } from "mysql2/promise";

const waitForDbServerTime = process.env.GITHUB_ACTION === `1` ? 10 : 60;

// from mysql2/lib/constants/types.js
const typeDict: { [key: number]: string } = {
0x00: 'DECIMAL', // aka DECIMAL
Expand Down Expand Up @@ -63,7 +65,7 @@ describe(`Database connector`, async function () {
before(async function () {
// Waiting for the database server
// TODO add env flag to trigger this behavior
await waitForDbServer();
await waitForDbServer(waitForDbServerTime);
pool = connector();
});
after(function () {
Expand Down
3 changes: 2 additions & 1 deletion back/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import AppSymbols from "./AppSymbols";
import setCors from "./middleware/cors";
const logger = Logger(`server`);
const PORT = process.env.APP_PORT ? parseInt(process.env.APP_PORT) : 3000;
const waitForDbServerTime = process.env.GITHUB_ACTION === `1` ? 10 : 60;
export interface StartServerOptions {
skipDatabase?: boolean;
skipRoutes?: boolean;
Expand All @@ -31,7 +32,7 @@ export default async function startServer(options?: StartServerOptions) {

if (!options?.skipDatabase) {
logger.log(`debug`, `Connecting DB.`);
await waitForDbServer();
await waitForDbServer(waitForDbServerTime);
const connectionPool = connector();
logger.log(`debug`, `Connected DB.`);
disconnectDatabase = function () {
Expand Down

0 comments on commit 2dcbbfa

Please sign in to comment.