mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-10-23 01:21:16 +00:00
Implement Branch in Status Command (#1057)
GHCR - Development Branches / ghcr-publish (push) Failing after 32s
Docker Hub - Develop / docker-latest (push) Failing after 34s
Tests / Application Service Integration tests (push) Failing after 13m52s
Tests / Integration tests (push) Failing after 13m54s
Tests / Unit tests (push) Failing after 13m57s
Tests / Build & Lint (push) Failing after 13m59s
GHCR - Development Branches / ghcr-publish (push) Failing after 32s
Docker Hub - Develop / docker-latest (push) Failing after 34s
Tests / Application Service Integration tests (push) Failing after 13m52s
Tests / Integration tests (push) Failing after 13m54s
Tests / Unit tests (push) Failing after 13m57s
Tests / Build & Lint (push) Failing after 13m59s
* Implement Branch in Status Command So now that we have dev branch containers and Cat checked Gnuxies Bot ye Huston we have a problem ala #1056.
This commit is contained in:
1 parent
9902993b6c
commit
b4d105f915
5 files changed
+40
-3
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"draupnir": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add branch information to status command output.
|
||||||
+4
-1
@@ -25,8 +25,11 @@ venv/
|
|||||||
|
|
||||||
/db
|
/db
|
||||||
|
|
||||||
# version file generated from yarn build
|
# version file generated from npm build
|
||||||
version.txt
|
version.txt
|
||||||
|
# branch file generated from npm build
|
||||||
|
branch.txt
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
@@ -9,8 +9,9 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc --project test/tsconfig.json && npm run build:assets",
|
"build": "tsc --project test/tsconfig.json && npm run build:assets",
|
||||||
"build:assets": "cp src/protections/DraupnirNews/news.json dist/protections/DraupnirNews/news.json && npm run describe-version",
|
"build:assets": "cp src/protections/DraupnirNews/news.json dist/protections/DraupnirNews/news.json && npm run describe-version && npm run describe-branch",
|
||||||
"describe-version": "(git describe > version.txt.tmp && mv version.txt.tmp version.txt) || true && rm -f version.txt.tmp",
|
"describe-version": "(git describe > version.txt.tmp && mv version.txt.tmp version.txt) || true && rm -f version.txt.tmp",
|
||||||
|
"describe-branch": "(git rev-parse --abbrev-ref HEAD > branch.txt.tmp && mv branch.txt.tmp branch.txt) || true && rm -f branch.txt.tmp",
|
||||||
"harness-registration": "node dist/appservice/cli.js -r -u \"http://host.docker.internal:9000\" --enable-source-maps",
|
"harness-registration": "node dist/appservice/cli.js -r -u \"http://host.docker.internal:9000\" --enable-source-maps",
|
||||||
"test:unit": "mocha --require './test/tsnode.cjs' --forbid-only 'test/unit/**/*.{ts,tsx}'",
|
"test:unit": "mocha --require './test/tsnode.cjs' --forbid-only 'test/unit/**/*.{ts,tsx}'",
|
||||||
"test:unit:single": "mocha --require test/tsnode.cjs",
|
"test:unit:single": "mocha --require test/tsnode.cjs",
|
||||||
|
|||||||
@@ -8,7 +8,12 @@
|
|||||||
// https://github.com/matrix-org/mjolnir
|
// https://github.com/matrix-org/mjolnir
|
||||||
// </text>
|
// </text>
|
||||||
|
|
||||||
import { DOCUMENTATION_URL, PACKAGE_JSON, SOFTWARE_VERSION } from "../config";
|
import {
|
||||||
|
CURRENT_BRANCH,
|
||||||
|
DOCUMENTATION_URL,
|
||||||
|
PACKAGE_JSON,
|
||||||
|
SOFTWARE_VERSION,
|
||||||
|
} from "../config";
|
||||||
import {
|
import {
|
||||||
ActionResult,
|
ActionResult,
|
||||||
Ok,
|
Ok,
|
||||||
@@ -51,6 +56,7 @@ export type StatusInfo = {
|
|||||||
numberOfProtectedRooms: number;
|
numberOfProtectedRooms: number;
|
||||||
numberOfUniqueMembers: number;
|
numberOfUniqueMembers: number;
|
||||||
version: string;
|
version: string;
|
||||||
|
branch: string;
|
||||||
repository: string;
|
repository: string;
|
||||||
documentationURL: string;
|
documentationURL: string;
|
||||||
} & DraupnirNotificationRoomsInfo &
|
} & DraupnirNotificationRoomsInfo &
|
||||||
@@ -135,6 +141,7 @@ export function draupnirStatusInfo(draupnir: Draupnir): StatusInfo {
|
|||||||
subscribedButPartedLists: watchedListInfo.subscribedButPartedLists,
|
subscribedButPartedLists: watchedListInfo.subscribedButPartedLists,
|
||||||
documentationURL: DOCUMENTATION_URL,
|
documentationURL: DOCUMENTATION_URL,
|
||||||
version: SOFTWARE_VERSION,
|
version: SOFTWARE_VERSION,
|
||||||
|
branch: CURRENT_BRANCH,
|
||||||
repository: (PACKAGE_JSON["repository"] as string | undefined) ?? "Unknown",
|
repository: (PACKAGE_JSON["repository"] as string | undefined) ?? "Unknown",
|
||||||
...extractProtectionNotificationRooms(draupnir),
|
...extractProtectionNotificationRooms(draupnir),
|
||||||
};
|
};
|
||||||
@@ -231,6 +238,9 @@ export function renderStatusInfo(info: StatusInfo): DocumentNode {
|
|||||||
<b>Version: </b>
|
<b>Version: </b>
|
||||||
<code>{info.version}</code>
|
<code>{info.version}</code>
|
||||||
<br />
|
<br />
|
||||||
|
<b>Branch: </b>
|
||||||
|
<code>{info.branch}</code>
|
||||||
|
<br />
|
||||||
<b>Repository: </b>
|
<b>Repository: </b>
|
||||||
<code>{info.repository}</code>
|
<code>{info.repository}</code>
|
||||||
<br />
|
<br />
|
||||||
|
|||||||
@@ -471,6 +471,24 @@ export const SOFTWARE_VERSION = (() => {
|
|||||||
return /^(.*)$/m.exec(versionFile)?.at(0) ?? defaultText;
|
return /^(.*)$/m.exec(versionFile)?.at(0) ?? defaultText;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
export const CURRENT_BRANCH = (() => {
|
||||||
|
let branchFile;
|
||||||
|
const defaultText =
|
||||||
|
"A branch name was either not provided when building Draupnir or could not be read.";
|
||||||
|
try {
|
||||||
|
branchFile = fs.readFileSync(
|
||||||
|
path.join(__dirname, "../branch.txt"),
|
||||||
|
"utf-8"
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
LogService.error("config", "Could not read Draupnir branch", e);
|
||||||
|
branchFile = defaultText;
|
||||||
|
}
|
||||||
|
// it's important to ignore the newline if the branch is going to be put
|
||||||
|
// into <pre> or <code> where it will create an unnecessary newline.
|
||||||
|
return /^(.*)$/m.exec(branchFile)?.at(0) ?? defaultText;
|
||||||
|
})();
|
||||||
|
|
||||||
export const DOCUMENTATION_URL =
|
export const DOCUMENTATION_URL =
|
||||||
"https://the-draupnir-project.github.io/draupnir-documentation/";
|
"https://the-draupnir-project.github.io/draupnir-documentation/";
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user