Skip to content

Commit

Permalink
feat(morphix): introduce new micro template package with function sup…
Browse files Browse the repository at this point in the history
…port (#133)
  • Loading branch information
PierreDemailly authored Nov 1, 2023
1 parent a01f61e commit 7869a6d
Show file tree
Hide file tree
Showing 29 changed files with 519 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
egress-policy: audit
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@49abf0ba24d0b7953cb586944e918a0b92074c80 # v2.22.4
uses: github/codeql-action/init@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -68,7 +68,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@49abf0ba24d0b7953cb586944e918a0b92074c80 # v2.22.4
uses: github/codeql-action/autobuild@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -81,6 +81,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@49abf0ba24d0b7953cb586944e918a0b92074c80 # v2.22.4
uses: github/codeql-action/analyze@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
egress-policy: audit
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/discord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ jobs:
egress-policy: audit
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Build packages
run: npm run build
- name: Run tests
run: npm run test --workspace=src/discord
2 changes: 1 addition & 1 deletion .github/workflows/logql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
egress-policy: audit
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/morphix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Morphix

on:
push:
branches: [main]
paths:
- src/morphix/src/**
- src/morphix/test/**
pull_request:
paths:
- src/morphix/src/**
- src/morphix/test/**

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
fail-fast: false
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
egress-policy: audit
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test --workspace=src/morphix
4 changes: 2 additions & 2 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@483ef80eb98fb506c348f7d62e28055e49fe2398 # v2.3.0
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
with:
results_file: results.sarif
results_format: sarif
Expand Down Expand Up @@ -73,6 +73,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@49abf0ba24d0b7953cb586944e918a0b92074c80 # v2.22.4
uses: github/codeql-action/upload-sarif@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
with:
sarif_file: results.sarif
4 changes: 3 additions & 1 deletion .github/workflows/slack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ jobs:
egress-policy: audit
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Build packages
run: npm run build
- name: Run tests
run: npm run test --workspace=src/slack
4 changes: 3 additions & 1 deletion .github/workflows/teams.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ jobs:
egress-policy: audit
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Build packages
run: npm run build
- name: Run tests
run: npm run test --workspace=src/teams
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Click on one of the links to access the documentation of the package:
| name | package and link |
| --- | --- |
| logql | [@sigyn/logql](./src/logql) |
| morphix | [@sigyn/morphix](./src/morphix) |

### Notifiers
| name | package and link |
Expand Down
84 changes: 40 additions & 44 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
"src/config",
"src/logql",
"src/agent",
"src/morphix",
"src/discord",
"src/slack",
"src/teams"
],
"devDependencies": {
"@nodesecure/eslint-config": "^1.8.0",
"@types/node": "^20.8.7",
"@types/node": "^20.8.9",
"c8": "^8.0.1",
"cross-env": "^7.0.3",
"glob": "^10.3.10",
Expand Down
3 changes: 1 addition & 2 deletions src/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
"dayjs": "^1.11.10",
"dotenv": "^16.3.1",
"ms": "^2.1.3",
"pino": "^8.16.0",
"pupa": "^3.1.0",
"pino": "^8.16.1",
"toad-scheduler": "^3.0.0"
},
"devDependencies": {
Expand Down
9 changes: 8 additions & 1 deletion src/agent/src/notifiers/notifierQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const kPrivateInstancier = Symbol("instancier");
type NotifierQueueAlert<T> = T & {
_id: symbol;
_nonUniqueMatcher: (notification: T, newNotifications: T) => boolean;
notifierConfig: {
notifier: string;
}
}

export class NotifierQueue<T = any> extends EventEmitter {
Expand Down Expand Up @@ -38,7 +41,11 @@ export class NotifierQueue<T = any> extends EventEmitter {
for (const newNotification of notifications) {
const { _id } = newNotification;
const alreadyInQueue = this.#notificationAlerts
.find((notification) => notification._id === _id && notification._nonUniqueMatcher(newNotification, notification));
.find(
(notification) => notification._id === _id &&
notification._nonUniqueMatcher(newNotification, notification) &&
notification.notifierConfig.notifier === newNotification.notifierConfig.notifier
);

if (alreadyInQueue === undefined) {
this.#notificationAlerts.push(newNotification);
Expand Down
3 changes: 1 addition & 2 deletions src/discord/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"author": "GENTILHOMME Thomas <[email protected]>",
"license": "MIT",
"dependencies": {
"@myunisoft/httpie": "^2.0.3",
"pupa": "^3.1.0"
"@myunisoft/httpie": "^2.0.3"
}
}
Loading

0 comments on commit 7869a6d

Please sign in to comment.