41 Commits

Author SHA1 Message Date
36d1306180 remove test build 2023-06-24 02:13:05 +02:00
69bde313b5 test with latest
All checks were successful
Build a docker image for node-jellyfin-role-bot / build-docker-image (push) Successful in 6s
2023-06-24 02:10:26 +02:00
7af3d87048 use new var in build
All checks were successful
Build a docker image for node-jellyfin-role-bot / build-docker-image (push) Successful in 6s
2023-06-24 02:09:03 +02:00
73741230b1 adjust env method
All checks were successful
Build a docker image for node-jellyfin-role-bot / build-docker-image (push) Successful in 7s
2023-06-24 02:08:26 +02:00
4f6d4f646a adjust echo script
All checks were successful
Build a docker image for node-jellyfin-role-bot / build-docker-image (push) Successful in 6s
2023-06-24 02:07:19 +02:00
6169649261 add new step
All checks were successful
Build a docker image for node-jellyfin-role-bot / build-docker-image (push) Successful in 6s
2023-06-24 02:06:10 +02:00
0560c4620c adjust awk script
All checks were successful
Build a docker image for node-jellyfin-role-bot / build-docker-image (push) Successful in 6s
2023-06-24 02:05:01 +02:00
be3ee5e493 echo version
All checks were successful
Build a docker image for node-jellyfin-role-bot / build-docker-image (push) Successful in 6s
2023-06-24 02:02:42 +02:00
251e6ae3d6 add test build script
Some checks failed
Build a docker image for node-jellyfin-role-bot / build-docker-image (push) Failing after 9s
2023-06-24 02:00:56 +02:00
2edd0312dc Merge branch 'master' into feat/cicd 2023-06-24 02:00:28 +02:00
f2b5ee502f remove unnecessary scripts
All checks were successful
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Successful in 10s
2023-06-14 22:35:59 +02:00
749e1c89ab clean up ci yaml 2023-06-14 22:35:51 +02:00
0d5799796a go back to normal docker commands
All checks were successful
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Successful in 15s
2023-06-14 22:33:15 +02:00
b7986d276b fix env access
All checks were successful
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Successful in 24s
2023-06-14 22:31:34 +02:00
8540381834 use bash explicitly
All checks were successful
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Successful in 8s
2023-06-14 22:29:55 +02:00
7e67d1fed9 adjust scripts
All checks were successful
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Successful in 8s
2023-06-14 22:28:29 +02:00
0cb19ba8f1 use bash scripts for docker stage
All checks were successful
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Successful in 11s
2023-06-14 22:27:18 +02:00
5dcf766593 dockerbuild and dockerpush scripts 2023-06-14 22:27:05 +02:00
808bdd033e string it
All checks were successful
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Successful in 9s
2023-06-14 22:20:06 +02:00
33f031d333 simplify push
All checks were successful
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Successful in 9s
2023-06-14 22:14:46 +02:00
40d9523e21 doing it manually 2023-06-14 22:14:19 +02:00
26e74a62c1 add branch 2023-06-14 21:54:22 +02:00
c0f91aad79 add secrets to 'on' 2023-06-14 21:42:16 +02:00
79ffde5f34 check env step
Some checks failed
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Failing after 23s
2023-06-14 21:30:23 +02:00
911b9e4884 adjust pipeline to be personalized
Some checks failed
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Failing after 17s
2023-06-14 21:27:16 +02:00
31a9e0eb28 adjust url
Some checks failed
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Failing after 22s
2023-06-14 19:44:50 +02:00
bcf788293e hardcoded docker tags
Some checks failed
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Failing after 28s
2023-06-14 19:27:28 +02:00
934b6dfead remove custom script
Some checks failed
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Failing after 15s
2023-06-14 19:21:22 +02:00
cd0c8c0017 latest tag by default
Some checks failed
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Failing after 15s
2023-06-14 19:18:46 +02:00
83f803d0e7 remove metadata action
Some checks failed
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Failing after 20s
2023-06-14 19:16:23 +02:00
2cb652aee6 add metadata and registry push
Some checks failed
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Failing after 9s
2023-06-14 19:11:05 +02:00
034d14eb15 use a container with docker
All checks were successful
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Successful in 2m3s
2023-06-14 18:59:07 +02:00
c8bfc47ddf add docker login
Some checks failed
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Failing after 14s
2023-06-13 23:47:22 +02:00
b67982ed38 ls
Some checks failed
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Failing after 9s
2023-06-13 23:29:29 +02:00
e3144fc402 add checkout option 2023-06-13 23:29:03 +02:00
1970f4b0cb adjust docker build stage
Some checks failed
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Failing after 34s
2023-06-13 23:24:56 +02:00
8ac4f568a0 add on push
Some checks failed
Build a docker image for node-jellyfin-role-ot / build-docker-image (push) Failing after 41s
2023-06-13 21:51:26 +02:00
09f4efc96c change os 2023-06-13 21:50:21 +02:00
6e0c3b8ef6 add gitea cicd 2023-06-13 21:49:04 +02:00
8ee36f7510 add woodpecker integration 2023-06-13 20:31:33 +02:00
1593e126eb add docker build files 2023-06-13 20:31:19 +02:00
32 changed files with 1423 additions and 1537 deletions

View File

@ -1,7 +0,0 @@
root = true
[*]
indent_style = tab
tab_width = 4
[*.ts]
indent_style = tab
tab_width = 4

View File

@ -14,4 +14,4 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Build Container - name: Build Container
run: docker build --target compile . run: docker build .

View File

@ -11,6 +11,7 @@ env:
jobs: jobs:
build-docker-image: build-docker-image:
runs-on: ubuntu-latest runs-on: ubuntu-latest
#if: gitea.ref == 'refs/heads/master'
container: catthehacker/ubuntu:act-latest container: catthehacker/ubuntu:act-latest
permissions: permissions:
contents: read contents: read
@ -21,8 +22,6 @@ jobs:
- name: Log in to the Container registry - name: Log in to the Container registry
run: docker login -u ${{ env.USER }} -p ${{ secrets.TOKEN }} ${{ env.REGISTRY }} run: docker login -u ${{ env.USER }} -p ${{ secrets.TOKEN }} ${{ env.REGISTRY }}
- name: Build Container - name: Build Container
run: docker build --target compile -t "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" -t "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}" . run: docker build -t "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" .
env:
version: $(cat package.json | awk 'match($0, /version/) {print $2}' | sed 's/[\",]//g') # extracts the version number from the package.json with bash magic
- name: Push Container - name: Push Container
run: docker push --all-tags "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" run: docker push --all-tags "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"

View File

@ -1,18 +0,0 @@
name: Run unit tests
on: [pull_request]
env:
REGISTRY: gitea.brudi.xyz
IMAGE_NAME: ${{ gitea.repository }}
USER: ${{ gitea.actor }}
jobs:
test:
runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run Tests
run: docker build --target test .

View File

@ -1,21 +1,11 @@
FROM node:alpine as files FROM node:alpine as Build
ENV TZ="Europe/Berlin" ENV NODE_ENV=production
WORKDIR /app WORKDIR /app
COPY [ "package-lock.json", "package.json", "index.ts", "tsconfig.json", "./" ] COPY [ "package-lock.json", "package.json", "index.ts", "tsconfig.json", "./" ]
COPY server ./server COPY server ./server
FROM files as proddependencies
ENV NODE_ENV=production
RUN npm ci --omit=dev RUN npm ci --omit=dev
FROM proddependencies as compile
RUN npm run build RUN npm run build
CMD ["npm","run","start"] CMD ["npm","run","start"]
FROM files as dependencies
RUN npm ci
FROM dependencies as test
COPY jest.config.js .
COPY tests ./tests
RUN npm run test

View File

@ -1,18 +0,0 @@
module.exports = {
'roots': [
'<rootDir>/tests',
'<rootDir>/server'
],
'transform': {
'^.+\\.tsx?$': 'ts-jest'
},
'testRegex': '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
'moduleFileExtensions': [
'ts',
'tsx',
'js',
'jsx',
'json',
'node'
],
};

27
package-lock.json generated
View File

@ -30,13 +30,12 @@
"winston": "^3.8.2" "winston": "^3.8.2"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.2", "@types/jest": "^29.5.0",
"@typescript-eslint/eslint-plugin": "^5.58.0", "@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0", "@typescript-eslint/parser": "^5.58.0",
"eslint": "^8.38.0", "eslint": "^8.38.0",
"jest": "^29.5.0", "jest": "^29.5.0",
"jest-cli": "^29.5.0", "jest-cli": "^29.5.0",
"mockdate": "^3.0.5",
"nodemon": "^2.0.22", "nodemon": "^2.0.22",
"rimraf": "^5.0.0", "rimraf": "^5.0.0",
"ts-jest": "^29.1.0" "ts-jest": "^29.1.0"
@ -1569,9 +1568,9 @@
} }
}, },
"node_modules/@types/jest": { "node_modules/@types/jest": {
"version": "29.5.2", "version": "29.5.0",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.2.tgz", "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.0.tgz",
"integrity": "sha512-mSoZVJF5YzGVCk+FsDxzDuH7s+SCkzrgKZzf0Z0T2WudhBUPoF6ktoTPC4R0ZoCPCV5xUvuU6ias5NvxcBcMMg==", "integrity": "sha512-3Emr5VOl/aoBwnWcH/EFQvlSAmjV+XtV9GGu5mwdYew5vhQh0IUZx/60x0TzHDu09Bi7HMx10t/namdJw5QIcg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"expect": "^29.0.0", "expect": "^29.0.0",
@ -4990,12 +4989,6 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/mockdate": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/mockdate/-/mockdate-3.0.5.tgz",
"integrity": "sha512-iniQP4rj1FhBdBYS/+eQv7j1tadJ9lJtdzgOpvsOHng/GbcDh2Fhdeq+ZRldrPYdXvCyfFUmFeEwEGXZB5I/AQ==",
"dev": true
},
"node_modules/ms": { "node_modules/ms": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@ -8146,9 +8139,9 @@
} }
}, },
"@types/jest": { "@types/jest": {
"version": "29.5.2", "version": "29.5.0",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.2.tgz", "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.0.tgz",
"integrity": "sha512-mSoZVJF5YzGVCk+FsDxzDuH7s+SCkzrgKZzf0Z0T2WudhBUPoF6ktoTPC4R0ZoCPCV5xUvuU6ias5NvxcBcMMg==", "integrity": "sha512-3Emr5VOl/aoBwnWcH/EFQvlSAmjV+XtV9GGu5mwdYew5vhQh0IUZx/60x0TzHDu09Bi7HMx10t/namdJw5QIcg==",
"dev": true, "dev": true,
"requires": { "requires": {
"expect": "^29.0.0", "expect": "^29.0.0",
@ -10727,12 +10720,6 @@
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="
}, },
"mockdate": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/mockdate/-/mockdate-3.0.5.tgz",
"integrity": "sha512-iniQP4rj1FhBdBYS/+eQv7j1tadJ9lJtdzgOpvsOHng/GbcDh2Fhdeq+ZRldrPYdXvCyfFUmFeEwEGXZB5I/AQ==",
"dev": true
},
"ms": { "ms": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",

View File

@ -33,18 +33,15 @@
"debuggable": "node build/index.js --inspect-brk", "debuggable": "node build/index.js --inspect-brk",
"monitor": "nodemon build/index.js", "monitor": "nodemon build/index.js",
"lint": "eslint . --ext .ts", "lint": "eslint . --ext .ts",
"lint-fix": "eslint . --ext .ts --fix", "lint-fix": "eslint . --ext .ts --fix"
"test": "jest",
"test-watch": "jest --watch"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.2", "@types/jest": "^29.5.0",
"@typescript-eslint/eslint-plugin": "^5.58.0", "@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0", "@typescript-eslint/parser": "^5.58.0",
"eslint": "^8.38.0", "eslint": "^8.38.0",
"jest": "^29.5.0", "jest": "^29.5.0",
"jest-cli": "^29.5.0", "jest-cli": "^29.5.0",
"mockdate": "^3.0.5",
"nodemon": "^2.0.22", "nodemon": "^2.0.22",
"rimraf": "^5.0.0", "rimraf": "^5.0.0",
"ts-jest": "^29.1.0" "ts-jest": "^29.1.0"

View File

@ -1,16 +0,0 @@
import { GuildScheduledEvent } from "discord.js"
import { createDateStringFromEvent } from "../../server/helper/dateHelper"
import MockDate from 'mockdate'
beforeAll(() => {
MockDate.set('01-01-2023')
})
function getTestDate(date: string): GuildScheduledEvent {
return <GuildScheduledEvent>{ scheduledStartAt: new Date(date) }
}
test('createDateStringFromEvent - correct formatting', () => {
expect(createDateStringFromEvent(getTestDate('01-01-2023 12:30'), "")).toEqual('heute um 12:30')
expect(createDateStringFromEvent(getTestDate('01-02-2023 12:30'), "")).toEqual('am Montag 02.01 um 12:30')
expect(createDateStringFromEvent(getTestDate('01-03-2023 12:30'), "")).toEqual('am Dienstag 03.01 um 12:30')
})

View File

@ -1,28 +0,0 @@
import { Collection, GuildMember, Role } from "discord.js"
import { filterRolesFromMemberUpdate } from "../../server/helper/roleFilter"
function buildFakeRole(id: string, name: string): Role {
return <Role>{ id, name }
}
test('filterRolesFromMemberUpdate', () => {
const oldMemberRoles: Collection<string, Role> = new Collection<string, Role>()
oldMemberRoles.set('1', buildFakeRole('01', 'Role01'))
oldMemberRoles.set('2', buildFakeRole('02', 'Role02'))
const newMemberRoles: Collection<string, Role> = new Collection<string, Role>()
newMemberRoles.set('1', buildFakeRole('01', 'Role01'))
newMemberRoles.set('2', buildFakeRole('02', 'Role02'))
newMemberRoles.set('3', buildFakeRole('03', 'Role03'))
const oldMember: GuildMember = <GuildMember>{ roles: { cache: oldMemberRoles }, guild: { id: "guildid" } }
const newMember: GuildMember = <GuildMember>{ roles: { cache: newMemberRoles }, guild: { id: "guildid" } }
const output = filterRolesFromMemberUpdate(oldMember, newMember)
const expectedAddedRoles: Collection<string, Role> = new Collection<string, Role>()
expectedAddedRoles.set('3', buildFakeRole('03', 'Role03'))
const expectedRemovedRoles: Collection<string, Role> = new Collection<string, Role>()
expect(output.addedRoles).toEqual(expectedAddedRoles)
expect(output.removedRoles).toEqual(expectedRemovedRoles)
})