Reviewed-on: #26 Co-authored-by: Alie <bizcochito@anartist.org> Co-committed-by: Alie <bizcochito@anartist.org>
This commit is contained in:
parent
ad37f9d72b
commit
a05c801236
|
@ -1,10 +1,5 @@
|
|||
name: Unit Tests with docker compose
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
unit-test:
|
|
@ -0,0 +1,49 @@
|
|||
name: Build image
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- build
|
||||
jobs:
|
||||
build:
|
||||
container:
|
||||
image: docker:dind
|
||||
volumes:
|
||||
- /data/.cache/act:/data/.cache/act
|
||||
- /var/lib/docker/image:/var/lib/docker/image
|
||||
- /var/lib/docker/overlay2:/var/lib/docker/overlay2
|
||||
steps:
|
||||
- name: Starting docker daemon
|
||||
run: docker-init -- dockerd --host=unix:///var/run/docker.sock &
|
||||
- name: Installing necessary packages
|
||||
run: apk add nodejs git curl bash
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: https://github.com/docker/metadata-action@v4
|
||||
with:
|
||||
# list of Docker images to use as base name for tags
|
||||
images: |
|
||||
git.fai.st/fedi-image-bot/bot-api
|
||||
# generate Docker tags based on the following events/attributes
|
||||
tags: |
|
||||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
||||
type=ref,event=branch
|
||||
type=sha
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Login to fai.st docker registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: git.fai.st
|
||||
username: ${{ secrets.DOCKER_USER }}
|
||||
password: ${{ secrets.DOCKER_PASS }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
|
@ -4,4 +4,4 @@ bun.lockb
|
|||
.env
|
||||
.editorconfig
|
||||
.idea
|
||||
coverage*
|
||||
coverage*
|
||||
|
|
17
Dockerfile
17
Dockerfile
|
@ -5,23 +5,28 @@
|
|||
FROM oven/bun:1 as base
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Generate new bun lock
|
||||
FROM base as lock
|
||||
RUN mkdir -p /temp/lock
|
||||
COPY package.json /temp/lock
|
||||
RUN cd /temp/lock && bun install
|
||||
|
||||
# install dependencies into temp folder
|
||||
# this will cache them and speed up future builds
|
||||
FROM base AS install
|
||||
|
||||
# install with --production (exclude devDependencies)
|
||||
RUN mkdir -p /temp/prod
|
||||
COPY package.json yarn.lock /temp/prod/
|
||||
RUN cd /temp/prod && bun install --production
|
||||
COPY --from=lock /temp/lock/package.json /temp/lock/bun.lockb /temp/prod/
|
||||
RUN cd /temp/prod && bun install --production --frozen-lockfile
|
||||
|
||||
# Copy production dependencies and source code into final image
|
||||
FROM base AS release
|
||||
COPY --from=install /temp/prod/node_modules node_modules
|
||||
COPY --from=install /usr/src/app/src ./src
|
||||
COPY --from=install /usr/src/app/package.json .
|
||||
COPY --from=install /temp/prod/package.json .
|
||||
COPY ./src ./src
|
||||
|
||||
# run the app
|
||||
USER bun
|
||||
ENV NODE_ENV=production
|
||||
ENV NODE_ENV production
|
||||
EXPOSE 8080/tcp
|
||||
CMD ["bun", "run", "start"]
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"enforce-unique": "^1.2.0",
|
||||
"jest": "^29.7.0",
|
||||
"supertest": "^6.3.3",
|
||||
"@types/compression": "^1.7.5",
|
||||
"ts-jest": "^29.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
@ -25,7 +26,6 @@
|
|||
"test": "docker compose down -v && docker compose run bot-api bun test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/compression": "^1.7.5",
|
||||
"compression": "^1.7.4",
|
||||
"express": "^4.18.2",
|
||||
"express-list-endpoints": "^6.0.0",
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import populateDatabase from "../tests/populateDatabase";
|
||||
import { startApp } from "./app";
|
||||
|
||||
await startApp();
|
||||
|
@ -7,6 +6,7 @@ await startApp();
|
|||
try {
|
||||
// Not insert test data into production
|
||||
if (process.env.NODE_ENV != "production") {
|
||||
const populateDatabase = require("../tests/populateDatabase");
|
||||
await populateDatabase();
|
||||
}
|
||||
} catch {}
|
||||
|
|
59
yarn.lock
59
yarn.lock
|
@ -1,6 +1,6 @@
|
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
# bun ./bun.lockb --hash: 9B0DB2A6DDF32440-fedbc92538df07cc-E7A3C1DB0A83DF66-732fbcf575fe4b52
|
||||
# bun ./bun.lockb --hash: 0566846CEF9BC37B-67668f8ef100cf47-BD54633F277319ED-f974ac5408e619f6
|
||||
|
||||
|
||||
"@ampproject/remapping@^2.2.0":
|
||||
|
@ -24,7 +24,7 @@
|
|||
resolved "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.23.5.tgz"
|
||||
integrity sha512-uU27kfDRlhfKl+w1U6vp16IuvSLtjAxdArVXPa9BvLkrr7CYIsxH5adpHObeAGY/41+syctUWOZ140a2Rvkgjw==
|
||||
|
||||
"@babel/core@>=7.0.0-beta.0 <8", "@babel/core@^7.0.0", "@babel/core@^7.0.0-0", "@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.8.0":
|
||||
"@babel/core@^7.0.0", "@babel/core@^7.0.0-0", "@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.8.0":
|
||||
version "7.23.7"
|
||||
resolved "https://registry.npmjs.org/@babel/core/-/core-7.23.7.tgz"
|
||||
integrity sha512-+UpDgowcmqe36d4NwqvKsyPMlOLNGMsfMmQ5WGCu+siCe3t3dfe9njrzGfdN4qq+bcNUt0+Vw6haRxBOycs4dw==
|
||||
|
@ -139,9 +139,9 @@
|
|||
integrity sha512-85ttAOMLsr53VgXkTbkx8oA6YTfT4q7/HzXSLEYmjcSTJPMPQtvq1BD79Byep5xMUYbGRzEpDsjUf3dyp54IKw==
|
||||
|
||||
"@babel/helpers@^7.23.7":
|
||||
version "7.23.7"
|
||||
resolved "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.7.tgz"
|
||||
integrity sha512-6AMnjCoC8wjqBzDHkuqpa7jAKwvMo4dC+lr/TFBz+ucfulO1XMpDnwWPGBNwClOKZ8h6xn5N81W/R5OrcKtCbQ==
|
||||
version "7.23.8"
|
||||
resolved "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.8.tgz"
|
||||
integrity sha512-KDqYz4PiOWvDFrdHLPhKtCThtIcKVy6avWD2oG4GEvyQ+XDZwHD4YQd+H2vNMnq2rkdxsDkU82T+Vk8U/WXHRQ==
|
||||
dependencies:
|
||||
"@babel/template" "^7.22.15"
|
||||
"@babel/traverse" "^7.23.7"
|
||||
|
@ -550,17 +550,17 @@
|
|||
integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==
|
||||
|
||||
"@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.18", "@jridgewell/trace-mapping@^0.3.9":
|
||||
version "0.3.20"
|
||||
resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz"
|
||||
integrity sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==
|
||||
version "0.3.21"
|
||||
resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.21.tgz"
|
||||
integrity sha512-SRfKmRe1KvYnxjEMtxEr+J4HIeMX5YBg/qhRHpxEIGjhX1rshcHlnFUE9K0GazhVKWM7B+nARSkV8LuvJdJ5/g==
|
||||
dependencies:
|
||||
"@jridgewell/resolve-uri" "^3.1.0"
|
||||
"@jridgewell/sourcemap-codec" "^1.4.14"
|
||||
|
||||
"@mongodb-js/saslprep@^1.1.0":
|
||||
version "1.1.1"
|
||||
resolved "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.1.tgz"
|
||||
integrity sha512-t7c5K033joZZMspnHg/gWPE4kandgc2OxE74aYOtGKfgB9VPuVJPix0H6fhmm2erj5PBJ21mqcx34lpIGtUCsQ==
|
||||
version "1.1.3"
|
||||
resolved "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.3.tgz"
|
||||
integrity sha512-SyCxhJfmK6MoLNV5SbDpNdUy9SDv5H7y9/9rl3KpnwgTHWuNNMc87zWqbcIZXNWY+aUjxLGLEcvHoLagG4tWCg==
|
||||
dependencies:
|
||||
sparse-bitfield "^3.0.3"
|
||||
|
||||
|
@ -732,9 +732,9 @@
|
|||
integrity sha512-iJt33IQnVRkqeqC7PzBHPTC6fDlRNRW8vjrgqtScAhrmMwe8c4Eo7+fUGTa+XdWrpEgpyKWMYmi2dIwMAYRzPw==
|
||||
|
||||
"@types/node@*":
|
||||
version "20.10.6"
|
||||
resolved "https://registry.npmjs.org/@types/node/-/node-20.10.6.tgz"
|
||||
integrity sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==
|
||||
version "20.11.0"
|
||||
resolved "https://registry.npmjs.org/@types/node/-/node-20.11.0.tgz"
|
||||
integrity sha512-o9bjXmDNcF7GbM4CNQpmi+TutCgap/K3w1JyKgxAjqx41zp9qlIAVFi0IhCNsJcXolEqLWhbFbEeL0PvYm4pcQ==
|
||||
dependencies:
|
||||
undici-types "~5.26.4"
|
||||
|
||||
|
@ -1036,9 +1036,9 @@ buffer-from@^1.0.0:
|
|||
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==
|
||||
|
||||
bun-types@latest:
|
||||
version "1.0.21"
|
||||
resolved "https://registry.npmjs.org/bun-types/-/bun-types-1.0.21.tgz"
|
||||
integrity sha512-Ugagjf+XZUXDvxDRa3EnhLeMzm2g8ZYFleBF55Ac3GZSzPqdMLAdK9kvZB6M1H4nAFvrEHdV2PHqkzIoNs+3wQ==
|
||||
version "1.0.22"
|
||||
resolved "https://registry.npmjs.org/bun-types/-/bun-types-1.0.22.tgz"
|
||||
integrity sha512-JxmXAx6cXb37+rMsn30WRXlz9lbPFR9rQE78hNSoy5wJ8m/nUktkmHpo7xZb/YKDds23ifxWLjDtyni9MeXLgw==
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
"@types/ws" "*"
|
||||
|
@ -1079,9 +1079,9 @@ camelcase@^6.2.0:
|
|||
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
|
||||
|
||||
caniuse-lite@^1.0.30001565:
|
||||
version "1.0.30001574"
|
||||
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001574.tgz"
|
||||
integrity sha512-BtYEK4r/iHt/txm81KBudCUcTy7t+s9emrIaHqjYurQ10x71zJ5VQ9x1dYPcz/b+pKSp4y/v1xSI67A+LzpNyg==
|
||||
version "1.0.30001576"
|
||||
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001576.tgz"
|
||||
integrity sha512-ff5BdakGe2P3SQsMsiqmt1Lc8221NR1VzHj5jXN5vBny9A6fpze94HiVV/n7XRosOlsShJcvMv5mdnpjOGCEgg==
|
||||
|
||||
chalk@^2.4.2:
|
||||
version "2.4.2"
|
||||
|
@ -1352,9 +1352,9 @@ ee-first@1.1.1:
|
|||
integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==
|
||||
|
||||
electron-to-chromium@^1.4.601:
|
||||
version "1.4.623"
|
||||
resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.623.tgz"
|
||||
integrity sha512-lKoz10iCYlP1WtRYdh5MvocQPWVRoI7ysp6qf18bmeBgR8abE6+I2CsfyNKztRDZvhdWc+krKT6wS7Neg8sw3A==
|
||||
version "1.4.630"
|
||||
resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.630.tgz"
|
||||
integrity sha512-osHqhtjojpCsACVnuD11xO5g9xaCyw7Qqn/C2KParkMv42i8jrJJgx3g7mkHfpxwhy9MnOJr8+pKOdZ7qzgizg==
|
||||
|
||||
emittery@^0.13.1:
|
||||
version "0.13.1"
|
||||
|
@ -2463,9 +2463,9 @@ mongodb-connection-string-url@^2.6.0:
|
|||
whatwg-url "^11.0.0"
|
||||
|
||||
mongoose@^8.0.3:
|
||||
version "8.0.3"
|
||||
resolved "https://registry.npmjs.org/mongoose/-/mongoose-8.0.3.tgz"
|
||||
integrity sha512-LJRT0yP4TW14HT4r2RkxqyvoTylMSzWpl5QOeVHTnRggCLQSpkoBdgbUtORFq/mSL2o9cLCPJz+6uzFj25qbHw==
|
||||
version "8.0.4"
|
||||
resolved "https://registry.npmjs.org/mongoose/-/mongoose-8.0.4.tgz"
|
||||
integrity sha512-wN9qvdevX3+922VnLT7CpaZRT3jmVCBOK2QMHMGeScQxDRnFMPpkuI9StEPpZo/3x8t+kbzH7F8RMPsyNwyM4w==
|
||||
dependencies:
|
||||
bson "^6.2.0"
|
||||
kareem "2.5.1"
|
||||
|
@ -3109,11 +3109,16 @@ type-is@~1.6.18:
|
|||
resolved "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz"
|
||||
integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==
|
||||
|
||||
undici-types@^5.26.4, undici-types@~5.26.4:
|
||||
undici-types@~5.26.4:
|
||||
version "5.26.5"
|
||||
resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz"
|
||||
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==
|
||||
|
||||
undici-types@^5.26.4:
|
||||
version "5.28.2"
|
||||
resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.28.2.tgz"
|
||||
integrity sha512-W71OLwDqzIO0d3k07qg1xc7d4cX8SsSwuCO4bQ4V7ITwduXXie/lcImofabP5VV+NvuvSe8ovKvHVJcizVc1JA==
|
||||
|
||||
unpipe@1.0.0, unpipe@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz"
|
||||
|
|
Loading…
Reference in New Issue