Skip to content

Commit 9161616

Browse files
committed
initial
Change-Id: I58aca4933493fd27e186470489d933320d9bc52c Signed-off-by: OhYee <oyohyee@oyohyee.com>
0 parents  commit 9161616

114 files changed

Lines changed: 22203 additions & 0 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.

.eslintrc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint"],
5+
"extends": [
6+
"eslint:recommended",
7+
"plugin:@typescript-eslint/recommended"
8+
],
9+
"env": {
10+
"node": true,
11+
"es2022": true
12+
},
13+
"parserOptions": {
14+
"ecmaVersion": 2022,
15+
"sourceType": "module"
16+
},
17+
"rules": {
18+
"@typescript-eslint/no-explicit-any": "warn",
19+
"@typescript-eslint/explicit-function-return-type": "off",
20+
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
21+
"no-constant-condition": ["error", { "checkLoops": false }]
22+
},
23+
"ignorePatterns": ["dist", "node_modules", "*.js"]
24+
}
25+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/workflows/ci.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [18.x, 20.x, 22.x]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'npm'
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Type check
30+
run: npm run typecheck
31+
32+
- name: Lint
33+
run: npm run lint
34+
35+
- name: Test
36+
run: npm run test
37+
38+
- name: Build
39+
run: npm run build
40+
41+
coverage:
42+
runs-on: ubuntu-latest
43+
needs: build
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Use Node.js 18.x
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: 18.x
52+
cache: 'npm'
53+
54+
- name: Install dependencies
55+
run: npm ci
56+
57+
- name: Run tests with coverage
58+
run: npm run test:coverage
59+
60+
- name: Upload coverage to Codecov
61+
uses: codecov/codecov-action@v4
62+
with:
63+
token: ${{ secrets.CODECOV_TOKEN }}
64+
files: ./coverage/coverage-final.json
65+
fail_ci_if_error: false
66+
67+
publish:
68+
runs-on: ubuntu-latest
69+
needs: [build, coverage]
70+
permissions:
71+
contents: read
72+
id-token: write
73+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
74+
75+
steps:
76+
- uses: actions/checkout@v4
77+
78+
- name: Use Node.js 18.x
79+
uses: actions/setup-node@v4
80+
with:
81+
node-version: 18.x
82+
cache: 'npm'
83+
registry-url: 'https://registry.npmjs.org'
84+
85+
- name: Install dependencies
86+
run: npm ci
87+
88+
- name: Build
89+
run: npm run build
90+
91+
# Only publish if version changed
92+
- name: Check version
93+
id: version
94+
run: |
95+
CURRENT_VERSION=$(node -p "require('./package.json').version")
96+
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
97+
98+
- name: Publish to npm
99+
if: steps.version.outputs.version != ''
100+
run: npm publish --access public
101+
env:
102+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
103+
continue-on-error: true

.github/workflows/publish.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Publish to npm
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
branches:
8+
- main
9+
workflow_dispatch:
10+
inputs:
11+
publish_type:
12+
description: 'Type of publish: official or test'
13+
required: true
14+
default: 'test'
15+
type: choice
16+
options:
17+
- official
18+
- test
19+
test_package_name:
20+
description: 'Optional custom package name for test publish (e.g. @alicloud/agentrun-sdk-test)'
21+
required: false
22+
23+
jobs:
24+
prepare:
25+
name: Build
26+
runs-on: ubuntu-latest
27+
outputs:
28+
built: ${{ steps.build.outputs.built }}
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: '18'
37+
registry-url: 'https://registry.npmjs.org'
38+
39+
- name: Install dependencies
40+
run: npm ci
41+
42+
- name: Build
43+
id: build
44+
run: |
45+
npm run build
46+
echo "built=true" >> $GITHUB_OUTPUT
47+
48+
publish-official:
49+
name: Publish Official Package
50+
needs: prepare
51+
runs-on: ubuntu-latest
52+
permissions:
53+
contents: read
54+
id-token: write
55+
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish_type == 'official')
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
60+
- name: Setup Node.js
61+
uses: actions/setup-node@v4
62+
with:
63+
node-version: '18'
64+
registry-url: 'https://registry.npmjs.org'
65+
always-auth: true
66+
67+
- name: Install dependencies
68+
run: npm ci
69+
70+
- name: Build
71+
run: npm run build
72+
73+
- name: Publish to npm (official)
74+
env:
75+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
76+
run: |
77+
echo "Publishing official package to npm"
78+
npm publish --access public
79+
80+
publish-test:
81+
name: Publish Test Package
82+
needs: prepare
83+
runs-on: ubuntu-latest
84+
permissions:
85+
contents: read
86+
id-token: write
87+
if: (github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish_type == 'test')
88+
steps:
89+
- name: Checkout
90+
uses: actions/checkout@v4
91+
92+
- name: Setup Node.js
93+
uses: actions/setup-node@v4
94+
with:
95+
node-version: '18'
96+
registry-url: 'https://registry.npmjs.org'
97+
always-auth: true
98+
99+
- name: Install dependencies
100+
run: npm ci
101+
102+
- name: Build
103+
run: npm run build
104+
105+
- name: Publish test package (tag=test)
106+
env:
107+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
108+
TEST_PKG_NAME: ${{ github.event.inputs.test_package_name }}
109+
run: |
110+
set -e
111+
echo "Publishing test package (tag=test)"
112+
if [ -n "$TEST_PKG_NAME" ]; then
113+
node -e "const fs=require('fs');const p=JSON.parse(fs.readFileSync('package.json'));p.name=process.env.TEST_PKG_NAME;fs.writeFileSync('package.json.tmp',JSON.stringify(p,null,2));fs.copyFileSync('package.json','package.json.bak');fs.copyFileSync('package.json.tmp','package.json');"
114+
npm publish --tag test --access public
115+
mv package.json.bak package.json
116+
rm -f package.json.tmp
117+
else
118+
npm publish --tag test --access public
119+
fi

0 commit comments

Comments
 (0)