Skip to content

Commit 44b9caf

Browse files
authored
Merge pull request #17 from cupofpython/add-testing
add testcontainers cloud test and action
2 parents abb7213 + 5c45617 commit 44b9caf

File tree

12 files changed

+7139
-3331
lines changed

12 files changed

+7139
-3331
lines changed

.github/workflows/pull-request-workflow.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ jobs:
1010
IMAGE_TAG: pr-${{ github.event.number }}
1111
secrets:
1212
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
13+
tests:
14+
uses: ./.github/workflows/tests.yml
15+
secrets:
16+
TC_CLOUD_TOKEN: ${{ secrets.TC_CLOUD_TOKEN }}
1317
scout:
1418
permissions:
1519
pull-requests: write

.github/workflows/tests.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Test with TestContainers
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
TC_CLOUD_TOKEN:
7+
required: true
8+
9+
jobs:
10+
server-test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out repo
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Testcontainers Cloud Client
17+
uses: atomicjar/testcontainers-cloud-setup-action@v1
18+
with:
19+
token: ${{ secrets.TC_CLOUD_TOKEN }}
20+
21+
- name: Run tests
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '23.10.0'
25+
- run: npm install
26+
- run: npm test
27+
28+
# (Optionally) When you don't need Testcontainers anymore, you could terminate sessions eagerly
29+
- name: Terminate Testcontainers Cloud Client active sessions
30+
uses: atomicjar/testcontainers-cloud-setup-action@v1
31+
with:
32+
action: terminate

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ RUN --mount=type=bind,source=package.json,target=package.json \
2222
npm ci --omit=dev
2323

2424
# Run the application as a non-root user.
25-
#USER node
25+
USER node
2626

2727
# Copy the rest of the source files into the image.
2828
COPY . .

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ It is a NodeJS app that uses the llama3.2 model to service prompt requests. It u
1616
- Exec into the container and run `ollama pull llama3.2`
1717
- `dotenv -e .env.dev -- npm run start:dev`
1818

19+
#### Local Tests
20+
- Run `npm test`
21+
1922
### Locally with Docker Compose
2023
I used compose to develop this locally.
2124

babel.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {presets: ['@babel/preset-env']}

jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
transform: {
4+
'^.+\\.(ts|tsx)?$': 'ts-jest',
5+
'^.+\\.(js|jsx)$': 'babel-jest',
6+
}
7+
};

0 commit comments

Comments
 (0)