Skip to content

Commit

Permalink
Merge pull request #14 from hayleyashby7/fix-test-run-on-build
Browse files Browse the repository at this point in the history
remove problematic addition to workflow
  • Loading branch information
hayleyashby7 authored Apr 19, 2024
2 parents efd311d + 88d9530 commit 33d2a7d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/CI and Deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ jobs:
with:
node-version: '20.x'
- run: npm ci
- run: npm install -g json-server
- run: json-server --watch db.json --routes routes.json --port 3000 &
- run: npm run build --if-present
- run: npm test
env:
DB_URL: ${{ secrets.DB_URL }}
NODE_ENV: 'production'
CLIENT_TOKEN: ${{ secrets.CLIENT_TOKEN }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
KANKA_TOKEN: ${{ secrets.KANKA_TOKEN }}
DB_TOKEN: ${{ secrets.DB_TOKEN }}
DB_URL: http://localhost:3000

deploy:
name: Fly Deploy
needs: build
Expand All @@ -34,3 +42,4 @@ jobs:
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
DB_URL: ${{ secrets.DB_URL}}
4 changes: 3 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import dotenv from 'dotenv';

dotenv.config();
if (process.env.NODE_ENV !== 'production') {
dotenv.config();
}

const { NODE_ENV, CLIENT_TOKEN, CLIENT_ID, KANKA_TOKEN, DB_TOKEN, DB_URL } = process.env;

Expand Down
8 changes: 8 additions & 0 deletions src/mocks/db/db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"stats": [
{
"name": "EchoesLeft",
"value": 123
}
]
}
3 changes: 3 additions & 0 deletions src/mocks/db/routes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"/stats?name=eq.EchoesLeft": "/stats/0"
}
2 changes: 1 addition & 1 deletion src/services/dbClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios, { AxiosRequestConfig, RawAxiosRequestHeaders } from 'axios';
import { config } from '../config';

export const dbClient = axios.create({
baseURL: config.DB_URL,
baseURL: process.env.NODE_ENV === 'test' ? 'http://localhost:3000' : config.DB_URL,
});

export const dbConfig: AxiosRequestConfig = {
Expand Down

0 comments on commit 33d2a7d

Please sign in to comment.