Skip to content

Commit 2f358b2

Browse files
Merge branch 'staging-new' of https://github.com/hcengineering/platform
Signed-off-by: Artem Savchenko <armisav@gmail.com>
2 parents 9235d52 + a94c7e5 commit 2f358b2

41 files changed

Lines changed: 533 additions & 353 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Reusable action: set all @hcengineering package versions from a v tag ref
2+
# (e.g. refs/tags/v0.7.370 → 0.7.370) using common/scripts/bump.js.
3+
# Call only when github.ref is a v* tag (e.g. if: startsWith(github.ref, 'refs/tags/v')).
4+
name: 'Set package versions'
5+
description: 'Set all @hcengineering package versions from a v tag ref using bump.js'
6+
inputs:
7+
ref:
8+
description: 'Git ref for the tag (e.g. github.ref, e.g. refs/tags/v0.7.370)'
9+
required: true
10+
outputs:
11+
version:
12+
description: 'Semver version derived from the tag (e.g. 0.7.370)'
13+
runs:
14+
using: 'composite'
15+
steps:
16+
- id: bump
17+
run: |
18+
VERSION="${INPUT_REF#refs/tags/v}"
19+
echo "version=$VERSION" >> $GITHUB_OUTPUT
20+
echo "VERSION=$VERSION" >> $GITHUB_ENV
21+
node common/scripts/bump.js "$VERSION"
22+
shell: bash

.github/workflows/main.yml

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
name: CI
44

5+
permissions:
6+
contents: read
7+
58
concurrency:
69
group: ${{ github.workflow }}-${{ github.ref }}
710
cancel-in-progress: true
@@ -19,6 +22,16 @@ on:
1922

2023
# Allows you to run this workflow manually from the Actions tab
2124
workflow_dispatch:
25+
inputs:
26+
ref:
27+
description: 'Ref to run as (e.g. refs/tags/v0.7.370 to test release flow)'
28+
required: false
29+
default: 'refs/heads/develop'
30+
skip_publish:
31+
description: 'Skip all publishing (npm, Docker, R2) when testing release flow'
32+
required: false
33+
default: false
34+
type: boolean
2235

2336
env:
2437
CacheFolders: |
@@ -57,12 +70,18 @@ jobs:
5770
steps:
5871
- uses: actions/checkout@v6
5972
with:
73+
ref: ${{ github.event.inputs.ref || github.ref }}
6074
fetch-depth: 0
6175
filter: tree:0
6276
submodules: recursive
6377
- uses: actions/setup-node@v6
6478
with:
6579
node-version-file: '.nvmrc'
80+
- name: Set package versions
81+
if: startsWith(github.event.inputs.ref || github.ref, 'refs/tags/v')
82+
uses: ./.github/actions/set-package-versions
83+
with:
84+
ref: ${{ github.event.inputs.ref || github.ref }}
6685
- name: Cache node modules
6786
uses: actions/cache@v5
6887
env:
@@ -74,6 +93,15 @@ jobs:
7493
restore-keys: |
7594
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
7695
96+
- name: Installing...
97+
run: |
98+
REF="${{ github.event.inputs.ref || github.ref }}"
99+
if [[ "$REF" == refs/tags/v* ]]; then
100+
node common/scripts/install-run-rush.js update
101+
else
102+
node common/scripts/install-run-rush.js install
103+
fi
104+
77105
# - name: Cheking model is updated...
78106
# run: node common/scripts/check_model_version.js
79107

@@ -83,9 +111,6 @@ jobs:
83111
- name: Checking for mis-matching transitive dependencies...
84112
run: node common/scripts/check-versions.js
85113

86-
- name: Installing...
87-
run: node common/scripts/install-run-rush.js install
88-
89114
- name: Model version from git tags
90115
run: node common/scripts/install-run-rush.js model-version
91116

@@ -698,12 +723,12 @@ jobs:
698723
# if: ${{ github.ref == 'refs/heads/main' }}
699724
# run: node common/scripts/install-run-rush.js docker:staging -v
700725
- name: Docker push tag
701-
if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/s') }}
726+
if: ${{ (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/s')) && (github.event_name != 'workflow_dispatch' || github.event.inputs.skip_publish != 'true') }}
702727
run: |
703728
echo Pushing release of tag ${{ github.ref }}
704729
node common/scripts/install-run-rush.js docker:push -v
705730
- name: Docker push love-agent
706-
if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/s') }}
731+
if: ${{ (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/s')) && (github.event_name != 'workflow_dispatch' || github.event.inputs.skip_publish != 'true') }}
707732
run: |
708733
echo Pushing love-agent release of tag ${{ github.ref }}
709734
cd ./services/ai-bot/love-agent
@@ -782,6 +807,7 @@ jobs:
782807
node ../common/scripts/install-run-rushx.js dist-signed --macos --x64 --arm64
783808
./scripts/copy-publish-artifacts.sh ${{ env.PublishTempFolder}}
784809
- name: Publish distribution assets and version
810+
if: github.event_name != 'workflow_dispatch' || github.event.inputs.skip_publish != 'true'
785811
uses: ryand56/r2-upload-action@latest
786812
with:
787813
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
@@ -884,6 +910,7 @@ jobs:
884910
node ../common/scripts/install-run-rushx.js dist-signed --macos --x64 --arm64
885911
./scripts/copy-publish-artifacts.sh ${{ env.PublishTempFolder}}
886912
- name: Publish distribution assets and version
913+
if: github.event_name != 'workflow_dispatch' || github.event.inputs.skip_publish != 'true'
887914
uses: ryand56/r2-upload-action@latest
888915
with:
889916
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
@@ -912,3 +939,34 @@ jobs:
912939
with:
913940
name: TraceX-Linux
914941
path: ./qms-desktop-package/deploy/TraceX-linux-*.zip
942+
943+
publish-npm:
944+
if: startsWith(github.event.inputs.ref || github.ref, 'refs/tags/v') && (github.event_name != 'workflow_dispatch' || github.event.inputs.skip_publish != 'true')
945+
needs: build
946+
runs-on: ubuntu-latest
947+
timeout-minutes: 30
948+
steps:
949+
- uses: actions/checkout@v6
950+
with:
951+
ref: ${{ github.event.inputs.ref || github.ref }}
952+
fetch-depth: 0
953+
- uses: actions/setup-node@v6
954+
with:
955+
node-version-file: '.nvmrc'
956+
- name: Cache node modules
957+
uses: actions/cache@v5
958+
env:
959+
cache-name: cache-node-platform
960+
with:
961+
path: common/temp
962+
key: ${{ runner.os }}-build-cache-node-platform-${{ hashFiles('**/pnpm-lock.yaml') }}
963+
restore-keys: ${{ runner.os }}-build-cache-node-platform-
964+
- name: Installing...
965+
run: node common/scripts/install-run-rush.js install
966+
- name: Publish to npm
967+
env:
968+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
969+
run: |
970+
REF="${{ github.event.inputs.ref || github.ref }}"
971+
VERSION="${REF#refs/tags/v}"
972+
node common/scripts/bump.js "$VERSION" --publish

common/scripts/bump.js

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,51 @@
11
const fs = require('fs')
2+
const path = require('path')
23
const execSync = require('child_process').execSync
34
const repo = '@hcengineering'
45

56
const packages = {}
67
const pathes = {}
78
const jsons = {}
9+
const repoRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf-8' }).trim()
810

911
function fillPackages (config) {
10-
for (const package of config.projects) {
11-
if (!package.name.startsWith(repo)) continue
12+
for (const project of config.projects) {
13+
const packageName = project.name ?? project.packageName
14+
if (typeof packageName !== 'string' || !packageName.startsWith(repo)) continue
15+
const projectPath = project.path ?? project.projectFolder ?? path.relative(repoRoot, project.fullPath ?? '')
16+
if (typeof projectPath !== 'string' || projectPath.length === 0) continue
17+
const fullProjectPath = path.resolve(repoRoot, projectPath)
18+
19+
packages[packageName] = {
20+
version: project.version,
21+
path: fullProjectPath
22+
}
23+
pathes[fullProjectPath] = packageName
1224

13-
packages[package.name] = {
14-
version: package.version,
15-
path: package.path
25+
const file = path.join(fullProjectPath, 'package.json')
26+
if (!fs.existsSync(file)) {
27+
console.log('skip, package.json not found:', file)
28+
continue
1629
}
17-
pathes[package.path] = package.name
1830

19-
const file = package.path + '/package.json'
20-
const raw = fs.readFileSync(file)
21-
jsons[package.name] = JSON.parse(raw)
31+
const raw = fs.readFileSync(file)
32+
jsons[packageName] = JSON.parse(raw)
2233
}
2334
}
2435

2536
function bumpPackage (name, newVersion) {
2637
const json = jsons[name]
2738

39+
if (json === undefined) return
2840
json.version = newVersion
29-
if (typeof json.dependencies === 'object') {
30-
for (const [dependency] of Object.entries(json.dependencies)) {
41+
const depTypes = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']
42+
for (const depType of depTypes) {
43+
if (typeof json[depType] !== 'object') continue
44+
for (const [dependency, currentVersion] of Object.entries(json[depType])) {
3145
if (packages[dependency] !== undefined) {
32-
json.dependencies[dependency] = `^${newVersion}`
46+
json[depType][dependency] = String(currentVersion).startsWith('workspace:')
47+
? `workspace:^${newVersion}`
48+
: `^${newVersion}`
3349
}
3450
}
3551
}
@@ -44,7 +60,7 @@ function publish (name) {
4460
const package = packages[name]
4561
try {
4662
console.log('publishing', name)
47-
execSync(`cd ${package.path} && npm publish && cd ../..`, { encoding: 'utf-8' })
63+
execSync('npm publish', { encoding: 'utf-8', cwd: package.path })
4864
} catch (err) {
4965
console.log(err)
5066
}
@@ -54,7 +70,7 @@ function fix (name) {
5470
const package = packages[name]
5571
try {
5672
console.log('fixing', name)
57-
execSync(`cd ${package.path} && npm pkg fix && cd ../..`, { encoding: 'utf-8' })
73+
execSync('npm pkg fix', { encoding: 'utf-8', cwd: package.path })
5874
} catch (err) {
5975
console.log(err)
6076
}
@@ -78,7 +94,20 @@ function main () {
7894

7995
console.log('bump version ...', version)
8096

81-
const config = JSON.parse(execSync('rush list -p --json', { encoding: 'utf-8' }))
97+
const output = execSync('node common/scripts/install-run-rush.js list -p --json', { encoding: 'utf-8', cwd: repoRoot })
98+
const lines = output.split('\n')
99+
let jsonStart = -1
100+
for (let i = 0; i < lines.length; i++) {
101+
if (lines[i].trim().startsWith('{')) {
102+
jsonStart = i
103+
break
104+
}
105+
}
106+
if (jsonStart === -1) {
107+
console.error('Could not find JSON output from rush list')
108+
process.exit(1)
109+
}
110+
const config = JSON.parse(lines.slice(jsonStart).join('\n'))
82111

83112
fillPackages(config)
84113

@@ -89,7 +118,8 @@ function main () {
89118

90119
for (const packageName of packageNames) {
91120
const package = packages[packageName]
92-
const file = package.path + '/package.json'
121+
if (jsons[packageName] === undefined) continue
122+
const file = path.join(package.path, 'package.json')
93123
const res = JSON.stringify(jsons[packageName], undefined, 2)
94124
fs.writeFileSync(file, res + '\n')
95125
}

foundations/hulypulse/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

foundations/hulypulse/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hulypulse"
3-
version = "0.4.0"
3+
version = "0.4.1"
44
edition = "2024"
55

66
[dependencies]
@@ -30,7 +30,7 @@ hulyrs = { git = "https://github.com/hcengineering/hulyrs.git", features = [ "ac
3030
secrecy = { version = "0.10.3", optional = true }
3131

3232
#redis
33-
redis = { version = "=0.32.5", features = ["aio", "tokio-comp", "sentinel"], optional = true }
33+
redis = { version = "=0.32.5", features = ["aio", "tokio-comp", "sentinel"] }
3434

3535
[[bin]]
3636
name = "hulypulse"
@@ -43,7 +43,6 @@ tokio-tungstenite = { version = "0.21", default-features = false, features = [
4343
] }
4444

4545
[features]
46-
default = ["db-redis","auth"] # lopt
46+
default = ["auth"] # lopt
4747
auth = ["regorus", "uuid", "hulyrs", "secrecy"]
4848
lopt = []
49-
db-redis = ["redis"]

foundations/hulypulse/README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,14 @@ Size of data is limited to some reasonable size
190190
- `{"message":"Del","key":"00000000-0000-0000-0000-000000000001/foo/bar"}`
191191

192192
## Special options in config/default.toml
193-
- ```memory_mode = true``` Use native memory storage instead Redis
193+
- ```backend = "memory"``` Use native memory storage instead Redis
194194
- ```max_size = 100``` Max value size in bytes
195195

196196
## Special cargo build options
197-
- "db-redis" (default) - use Redis (Memory instead)
198197
- "auth" (default) - use huly-authorization
199-
Disable both:
198+
Disable auth:
200199
cargo build --no-default-features
201-
Enable one:
200+
Enable auth:
202201
cargo build --no-default-features --features "auth"
203202

204203
## Running
@@ -207,7 +206,17 @@ Pre-build docker images is available at: hardcoreeng/service_hulypulse:{tag}.
207206

208207
You can use the following command to run the image locally:
209208
```bash
210-
docker run -p 8095:8095 -it --rm hardcoreeng/service_hulypulse:{tag}"
209+
docker run -p 8095:8095 -it --rm hardcoreeng/service_hulypulse:{tag}
210+
```
211+
212+
Run from source using Redis:
213+
```bash
214+
HULY_REDIS_URLS=redis://huly.local:6379 cargo run
215+
```
216+
217+
Run from source in in-memory mode:
218+
```bash
219+
HULY_BACKEND=memory cargo run
211220
```
212221

213222
If you want to run the service as a part of local huly development environment use the following command:
@@ -228,6 +237,7 @@ The following environment variables are used to configure hulypulse:
228237
- ```HULY_BIND_HOST```: host to bind the server to (default: 0.0.0.0)
229238
- ```HULY_BIND_PORT```: port to bind the server to (default: 8094)
230239
- ```HULY_TOKEN_SECRET```: secret used to sign JWT tokens (default: secret)
240+
- ```HULY_BACKEND```: storage backend "redis" or "memory" (default: "redis")
231241
- ```HULY_REDIS_URLS```: redis connection string (default: redis://huly.local:6379)
232242
- ```HULY_REDIS_PASSWORD```: redis password (default: "&lt;invalid&gt;")
233243
- ```HULY_REDIS_MODE```: redis mode "direct" or "sentinel" (default: "direct")

0 commit comments

Comments
 (0)