Skip to content

Commit 76f4195

Browse files
Nirajn2311Sembauke
andauthored
fix: build and test mobile API (#1217)
* fix: build and test mobile API * chore: remove env file print command Co-authored-by: Sem Bauke <[email protected]> --------- Co-authored-by: Sem Bauke <[email protected]>
1 parent 554f2fc commit 76f4195

File tree

4 files changed

+21
-35
lines changed

4 files changed

+21
-35
lines changed

.github/workflows/test-api.yml renamed to .github/workflows/api-build-and-test.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Node.js CI
1+
name: Build and Test API
22

33
on:
44
push:
@@ -11,9 +11,9 @@ defaults:
1111
working-directory: mobile-api
1212

1313
jobs:
14-
lint-and-test:
15-
name: Lint and Test
16-
runs-on: ubuntu-22.04
14+
build-and-test:
15+
name: Build and Test API
16+
runs-on: ubuntu-latest
1717

1818
strategy:
1919
matrix:
@@ -35,5 +35,17 @@ jobs:
3535
- name: Lint source files
3636
run: npm run lint
3737

38-
- name: Run test
38+
- name: Build and start container
39+
run: docker compose -f docker-compose.dev.yml up -d
40+
41+
- name: Sleep for 1 minute
42+
run: sleep 60
43+
44+
- name: Ping container
45+
run: curl localhost:3000/ping
46+
47+
- name: Create .env file
48+
run: cp sample.env .env
49+
50+
- name: Run tests
3951
run: npm test

.github/workflows/test-image.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

mobile-api/sample.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
MONGODB_URL="mongodb://localhost:27017/mobile-api"
2-
DEV_URL="https://api.mobile.freecodecamp.dev"
1+
MONGODB_URL=mongodb://localhost:27017/mobile-api
2+
DEV_URL=http://localhost:3000

mobile-api/src/__tests__/podcast.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dotenv/config';
22
import fetch from 'node-fetch';
33
import { Podcast } from '../models/Podcast';
44
import { Episode } from '../models/Episode';
5+
56
interface pingEndpoint {
67
msg: string;
78
}
@@ -12,7 +13,7 @@ interface episodeEndpoint {
1213
}
1314

1415
describe('podcast api', () => {
15-
const url = process.env.DEV_URL ?? 'https://api.mobile.freecodecamp.dev';
16+
const url = process.env.DEV_URL;
1617

1718
let localPodcastId = '';
1819
let localEpisodeId = '';

0 commit comments

Comments
 (0)