Skip to content

Commit 6211bb0

Browse files
committed
fix: update CI configuration and enhance Telegram notification with environment variables
1 parent 73aafad commit 6211bb0

8 files changed

Lines changed: 148 additions & 70 deletions

File tree

.github/workflows/ci.yml

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
uses: actions/setup-node@v4
2626
with:
2727
node-version: 18
28-
cache: 'npm'
28+
cache: "npm"
2929

3030
- name: Install dependencies
3131
run: npm ci
@@ -63,7 +63,7 @@ jobs:
6363
uses: actions/setup-node@v4
6464
with:
6565
node-version: 18
66-
cache: 'npm'
66+
cache: "npm"
6767

6868
- name: Install dependencies
6969
run: npm ci
@@ -94,7 +94,7 @@ jobs:
9494
uses: actions/setup-node@v4
9595
with:
9696
node-version: 18
97-
cache: 'npm'
97+
cache: "npm"
9898

9999
- name: Install dependencies
100100
run: npm ci
@@ -120,8 +120,11 @@ jobs:
120120
uses: actions/checkout@v4
121121
with:
122122
fetch-depth: 0
123-
123+
124124
- name: Send Telegram notification
125+
env:
126+
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
127+
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
125128
run: |
126129
if [ "${IS_ACT}" = "true" ]; then
127130
TEST_RESULT="success"
@@ -132,7 +135,7 @@ jobs:
132135
RELEASE_RESULT="${{ needs.release.result }}"
133136
DEPLOY_RESULT="${{ needs.deploy.result }}"
134137
fi
135-
138+
136139
STATUS="✅ *Pipeline completed successfully*"
137140
if [ "$TEST_RESULT" != "success" ]; then
138141
STATUS="❌ *Tests failed*"
@@ -141,22 +144,26 @@ jobs:
141144
elif [ "$DEPLOY_RESULT" != "success" ]; then
142145
STATUS="❌ *Deploy failed*"
143146
fi
144-
145-
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short HEAD)
147+
148+
VERSION=$(git tag --points-at HEAD)
149+
if [ -z "$VERSION" ]; then
150+
VERSION=$(git rev-parse --short HEAD)
151+
fi
152+
146153
BRANCH=$(git rev-parse --abbrev-ref HEAD)
147154
COMMIT=$(git rev-parse --short HEAD)
148155
REPO_URL="https://github.com/$GITHUB_REPOSITORY"
149156
LAST_AUTHOR=$(git log -1 --pretty=format:'%an')
150-
151-
MESSAGE="$STATUS
152-
🕓 *Date:* $(date)
153-
🏷️ *Version/Tag:* $VERSION
154-
🌿 *Branch:* $BRANCH
155-
🔀 *Commit:* $COMMIT
156-
👤 *Author:* $LAST_AUTHOR
157+
158+
MESSAGE="$STATUS
159+
🕓 *Date:* $(date)
160+
🏷️ *Version/Tag:* $VERSION
161+
🌿 *Branch:* $BRANCH
162+
🔀 *Commit:* $COMMIT
163+
👤 *Author:* $LAST_AUTHOR
157164
🔗 *Repo:* $REPO_URL"
158-
159-
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
160-
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
161-
-d "text=$("$MESSAGE" \
162-
-d "parse_mode=Markdown"
165+
166+
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
167+
-d chat_id="${TELEGRAM_CHAT_ID}" \
168+
-d text="$MESSAGE" \
169+
-d parse_mode=Markdown

.prettierignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Node modules
2+
node_modules/
3+
4+
# Build / dist folders
5+
dist/
6+
build/
7+
out/
8+
9+
# Lock files (Prettier will only format these via overrides in .prettierrc)
10+
*.lock
11+
package-lock.json
12+
yarn.lock
13+
pnpm-lock.yaml
14+
15+
# Git / OS metadata
16+
*.log
17+
*.DS_Store
18+
*.env
19+
20+
# Coverage / test output
21+
coverage/
22+
test-results/
23+
24+
# Ignore general JSON/YAML in project root if not overridden
25+
*.json
26+
*.yml
27+
*.yaml
28+
29+
# Ignore editor settings (unless overridden in .prettierrc)
30+
.vscode/
31+
.idea/
32+
33+
# Documentation files
34+
CHANGELOG.md
35+
README.md
36+
LICENSE

.prettierrc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 4,
4+
"semi": true,
5+
"singleQuote": false,
6+
"endOfLine": "auto",
7+
"overrides": [
8+
{
9+
"files": [
10+
"package.json",
11+
"package-lock.json",
12+
"yarn.lock",
13+
"pnpm-lock.yaml",
14+
".github/workflows/*.yml",
15+
".github/workflows/*.yaml",
16+
".github/actions/**/*.yml",
17+
".github/actions/**/*.yaml",
18+
"ci.yml",
19+
".prettierrc",
20+
".vscode/**/*.json",
21+
".github/**/*.json"
22+
],
23+
"options": {
24+
"tabWidth": 2
25+
}
26+
}
27+
]
28+
}

__tests__/commands/aloha.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ describe("aloha Command", () => {
33
jest.resetModules();
44
jest.clearAllMocks();
55
});
6-
6+
77
test("returns early when groupValidator is false", async () => {
88
jest.doMock("../../bot/utils/groupValidator", () => ({
99
groupValidator: () => false,

__tests__/commands/group.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ describe("groupId commands", () => {
33
jest.resetModules();
44
jest.clearAllMocks();
55
});
6-
6+
77
test("groupID replies with chat id", async () => {
88
const { groupIDCommand } = require("../../bot/commands/groupId");
99
const ctx = { chat: { id: 123 }, reply: jest.fn() };

__tests__/commands/version.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ describe("version commands", () => {
2323
});
2424

2525
test("version error path calls errorReply when reply throws", async () => {
26-
jest.doMock("../../bot/config/config", () => ({ BOT_VERSION: "0.0.0" }));
26+
jest.doMock("../../bot/config/config", () => ({
27+
BOT_VERSION: "0.0.0",
28+
}));
2729
const mockErrorReply = jest.fn();
2830
jest.doMock("../../bot/utils/errorReply", () => ({
2931
errorReply: mockErrorReply,

__tests__/handlers/startMessage.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ describe("startMessage handler", () => {
3434
test("startMessage sends reaction for non-private chat", async () => {
3535
await jest.isolateModulesAsync(async () => {
3636
const sendReaction = jest.fn();
37-
jest.doMock("../../bot/utils/sendReaction", () => ({ sendReaction }));
37+
jest.doMock("../../bot/utils/sendReaction", () => ({
38+
sendReaction,
39+
}));
3840

3941
const bot = { start: (fn) => (bot._handler = fn) };
4042
const register = require("../../bot/handlers/startMessage");

package.json

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,52 @@
11
{
2-
"name": "cs-queue-bot",
3-
"version": "3.1.6",
4-
"description": "Automated Telegram bot for managing the CS Internship queue group, with Azure DevOps integration.",
5-
"main": "./index.js",
6-
"scripts": {
7-
"start": "node index.js",
8-
"dev": "nodemon index.js",
9-
"test": "jest --coverage",
10-
"test:watch": "jest --watch",
11-
"lint": "eslint . --ext .js"
12-
},
13-
"repository": {
14-
"type": "git",
15-
"url": "https://github.com/cs-internship/CS-Queue-Bot.git"
16-
},
17-
"keywords": [
18-
"telegram-bot",
19-
"cs-queue",
20-
"bot",
21-
"nodejs",
22-
"telegraf"
23-
],
24-
"author": "Ali Sadeghi",
25-
"contributors": [
26-
"Ali Sadeghi"
27-
],
28-
"license": "MIT",
29-
"engines": {
30-
"node": ">=18"
31-
},
32-
"dependencies": {
33-
"axios": "^1.8.1",
34-
"dayjs": "^1.11.18",
35-
"dotenv": "^16.4.7",
36-
"express": "^4.21.2",
37-
"jalali-moment": "^3.3.11",
38-
"node-cron": "^4.2.1",
39-
"telegraf": "^4.16.3"
40-
},
41-
"devDependencies": {
42-
"eslint": "^8.57.1",
43-
"nodemon": "^3.0.2",
44-
"prettier": "^3.0.0",
45-
"jest": "^29.6.1",
46-
"@babel/preset-env": "^7.22.20",
47-
"babel-jest": "^29.6.1"
48-
}
2+
"name": "cs-queue-bot",
3+
"version": "3.1.6",
4+
"description": "Automated Telegram bot for managing the CS Internship queue group, with Azure DevOps integration.",
5+
"main": "./index.js",
6+
"scripts": {
7+
"start": "node index.js",
8+
"dev": "nodemon index.js",
9+
"test": "jest --coverage",
10+
"test:watch": "jest --watch",
11+
"lint": "eslint . --ext .js",
12+
"lint:fix": "eslint . --ext .js --fix",
13+
"format": "prettier --write .",
14+
"format:check": "prettier --check ."
15+
},
16+
"repository": {
17+
"type": "git",
18+
"url": "https://github.com/cs-internship/CS-Queue-Bot.git"
19+
},
20+
"keywords": [
21+
"telegram-bot",
22+
"cs-queue",
23+
"bot",
24+
"nodejs",
25+
"telegraf"
26+
],
27+
"author": "Ali Sadeghi",
28+
"contributors": [
29+
"Ali Sadeghi"
30+
],
31+
"license": "MIT",
32+
"engines": {
33+
"node": ">=18"
34+
},
35+
"dependencies": {
36+
"axios": "^1.8.1",
37+
"dayjs": "^1.11.18",
38+
"dotenv": "^16.4.7",
39+
"express": "^4.21.2",
40+
"jalali-moment": "^3.3.11",
41+
"node-cron": "^4.2.1",
42+
"telegraf": "^4.16.3"
43+
},
44+
"devDependencies": {
45+
"eslint": "^8.57.1",
46+
"nodemon": "^3.0.2",
47+
"prettier": "^3.0.0",
48+
"jest": "^29.6.1",
49+
"@babel/preset-env": "^7.22.20",
50+
"babel-jest": "^29.6.1"
51+
}
4952
}

0 commit comments

Comments
 (0)