Skip to content

Commit

Permalink
test: 🚨 run tests in docker environment
Browse files Browse the repository at this point in the history
* test: 🚨 run tests in docker environment

* chore(version): πŸ”§ πŸ“¦οΈ prerelease version bump to 0.0.11-fix-run-tests-dockerized.0

* fix: πŸ› run docker in gh actions

* chore(version): πŸ”§ πŸ“¦οΈ prerelease version bump to 0.0.11-fix-run-tests-dockerized.1

* fix: πŸ› run docker in gh actions

* chore(version): πŸ”§ πŸ“¦οΈ prerelease version bump to 0.0.11-fix-run-tests-dockerized.2

---------

Co-authored-by: Evert De Spiegeleer <evert.despiegeleer@rightcrowd.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 19, 2024
1 parent dfdd1b7 commit db57a9b
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 20 deletions.
34 changes: 34 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/engine/reference/builder/#dockerignore-file

**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.next
**/.cache
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/build
**/dist
LICENSE
README.md
10 changes: 9 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:

test:
runs-on: ubuntu-latest
needs:
- build
permissions:
checks: write
pull-requests: write
Expand All @@ -71,13 +73,19 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 20.11.0

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build
path: ./packages

- name: Install Dependencies
run: npm ci

- name: Test
id: test
run: npm run test
run: docker compose run dev npm test

- name: Upload test artifacts
uses: actions/upload-artifact@v4
Expand Down
17 changes: 17 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ARG NODE_VERSION=20.10.0
FROM node:${NODE_VERSION}-alpine as base

WORKDIR /usr/src/app

FROM base as deps

RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=bind,source=packages,target=packages \
--mount=type=cache,target=/root/.npm \
npm ci

COPY ./package*.json ./
COPY ./tsconfig*.json ./

CMD ["sh"]
7 changes: 7 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
dev:
build:
context: ''
dockerfile: Dockerfile.dev
volumes:
- ./packages:/usr/src/app/packages
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "git",
"url": "https://github.com/evertdespiegeleer/zhttp.git"
},
"version": "0.0.10",
"version": "0.0.11-fix-run-tests-dockerized.2",
"type": "module",
"engines": {
"node": "^20.10.x",
Expand All @@ -20,7 +20,7 @@
"scripts": {
"build": "npm run build --workspaces --if-present",
"test": "npm run test --workspaces --if-present",
"prepare": "npx husky install && cp ./readme.md ./packages/core",
"prepare": "npx husky install && cp ./readme.md ./packages/core || true",
"lint": "eslint 'packages/*/src/**/*.ts' 'examples/*.ts'",
"lint:fix": "npm run lint -- --fix",
"sync:readme": "npx embedme ./readme.md"
Expand Down
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "git",
"url": "https://github.com/evertdespiegeleer/zhttp.git"
},
"version": "0.0.10",
"version": "0.0.11-fix-run-tests-dockerized.2",
"type": "module",
"types": "./dist/types/main.d.ts",
"exports": {
Expand All @@ -32,11 +32,11 @@
"build": "npm run build:esm && npm run build:cjs",
"build:esm": "tsc -p tsconfig.build.esm.json",
"build:cjs": "npx rollup ./dist/esm/main.js --file ./dist/cjs/main.cjs --format cjs",
"test": "node --test --test-reporter spec --test-reporter-destination stdout --test-reporter junit --test-reporter-destination=./test-report.xml --loader ts-node/esm ./src/{**/,}*.test.ts"
"test": "node --test --test-reporter spec --test-reporter-destination stdout --test-reporter junit --test-reporter-destination=./test-report.xml --loader ts-node/esm ./src/**/*.test.ts"
},
"dependencies": {
"@asteasolutions/zod-to-openapi": "^6.3.1",
"@zhttp/errors": "0.0.10",
"@zhttp/errors": "0.0.11-fix-run-tests-dockerized.2",
"body-parser": "^1.20.2",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
Expand All @@ -62,7 +62,7 @@
"typescript": "^4.4.4"
},
"peerDependencies": {
"@zhttp/errors": "0.0.10",
"@zhttp/errors": "0.0.11-fix-run-tests-dockerized.2",
"zod": "^3.22.4"
}
}
7 changes: 1 addition & 6 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,5 @@
},
"include": [
"./src/**/*.ts"
],
"ts-node": {
"experimentalSpecifierResolution": "node",
"transpileOnly": true,
"esm": true,
},
]
}
2 changes: 1 addition & 1 deletion packages/errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "git",
"url": "https://github.com/evertdespiegeleer/zhttp.git"
},
"version": "0.0.10",
"version": "0.0.11-fix-run-tests-dockerized.2",
"type": "module",
"types": "./dist/types/main.d.ts",
"exports": {
Expand Down
5 changes: 5 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@
"include": [
"packages/*/src/**/*.ts",
],
"ts-node": {
"experimentalSpecifierResolution": "node",
"transpileOnly": true,
"esm": true,
},
}

0 comments on commit db57a9b

Please sign in to comment.