Skip to content

Commit b69e290

Browse files
authored
Merge branch 'main' into math-util
2 parents 1be6e8c + 67892e7 commit b69e290

File tree

155 files changed

+43513
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+43513
-154
lines changed

.github/workflows/check-pr.yml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# 为了试验,此处作为单独的 Workflow,在实际工作中可 Install -> Lint、Test -> Preview 串行检验
2+
name: Check PR
3+
4+
# 执行 CI 的时机: 当 git push 到 main分支时
5+
on:
6+
pull_request:
7+
branches: main
8+
9+
permissions:
10+
pull-requests: write
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check if commit is from CI
18+
run: |
19+
if [[ "${{ github.event.head_commit.committer.username }}" == "github-actions[bot]" ]]; then
20+
echo "Commit is from CI, skipping the build..."
21+
exit 78
22+
else
23+
echo "Commit is not from CI, continuing with the build..."
24+
fi
25+
- name: see vars
26+
run: |
27+
echo '${{github.event.pull_request.head.ref}}'
28+
echo '${{github.event.pull_request.head.sha}}'
29+
echo '${{github.event.pull_request.head.repo.branches_url}}'
30+
echo '${{github.event.pull_request.head.repo.full_name}}'
31+
echo '${{github.event.pull_request.base.ref}}'
32+
echo '${{github.event.pull_request.base.sha}}'
33+
echo '${{github.event.pull_request.base.repo.branches_url}}'
34+
echo '${{github.event.pull_request.base.repo.full_name}}'
35+
echo '${{github.head_ref}}'
36+
echo '${{github.ref}}'
37+
echo '${{github.ref_name}}'
38+
echo '${{github.repository}}'
39+
echo '${{ github.event.pull_request.number }}'
40+
echo '${{ github.run_id }}'
41+
echo '${{github.event.pull_request.user.name}}'
42+
echo '${{github.event.pull_request.maintainer_can_modify}}'
43+
echo '${{github.event.pull_request.user.id}}'
44+
echo '${{github.event.sender.id}}'
45+
echo '${{github.event.repository.fork}}'
46+
echo '${{github.event.repository.name}}'
47+
echo '${{github.event.repository.full_name}}'
48+
echo '${{github.actor}}'
49+
echo '${{github.triggering_actor}}'
50+
echo '${{github.event.pull_request.user.name}}'
51+
- name: Checkout
52+
uses: actions/checkout/@v3
53+
with:
54+
fetch-depth: 1
55+
56+
- name: Git Identity
57+
run: |
58+
git config --global user.name 'github-actions[bot]'
59+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
60+
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
61+
git fetch --unshallow
62+
env:
63+
GITHUB_TOKEN: ${{ github.token}}
64+
65+
- name: see git1
66+
run: |
67+
git branch --show-current
68+
- name: see git2
69+
run: |
70+
git diff --name-only origin/main...HEAD
71+
72+
- name: Setup Nodejs
73+
uses: actions/setup-node@v3
74+
with:
75+
cache: "npm"
76+
node-version: 16
77+
78+
- name: Install Dep
79+
run: |
80+
npm install
81+
82+
- name: Detect Pull Request Change
83+
run: |
84+
git config --global core.quotepath false
85+
git config --global gui.encoding utf-8
86+
git config --global i18n.commit.encoding utf-8
87+
git config --global i18n.logoutputencoding utf-8
88+
export LESSCHARSET=utf-8
89+
npm run detectPR
90+
{
91+
echo "DIFF_STATE<<EOF"
92+
echo "$(cat diff_stat.json)"
93+
echo "EOF"
94+
} >> "$GITHUB_ENV"
95+
96+
- name: Set up JDK 8
97+
if: ${{fromJson(env.DIFF_STATE).needJAVA}}
98+
uses: actions/setup-java@v4
99+
with:
100+
java-version: "8"
101+
distribution: "temurin"
102+
103+
- name: Install JDK Dependency
104+
if: ${{fromJson(env.DIFF_STATE).needJAVA}}
105+
run: |
106+
mvn install:install-file -Dfile="demo_bjz_JiazhenBao/jar/nasl-metadata-maven-plugin-1.3.0/nasl-metadata-maven-plugin-1.3.0.jar" -DpomFile="demo_bjz_JiazhenBao/jar/nasl-metadata-maven-plugin-1.3.0/pom.xml"
107+
mvn install:install-file -DgroupId=com.netease.lowcode -DartifactId=nasl-metadata-collector -Dversion=0.8.0 -Dpackaging=jar -Dfile="demo_bjz_JiazhenBao/jar/nasl-metadata-collector-0.8.0.jar"
108+
109+
- name: Install LCAP
110+
run: |
111+
npm install -g [email protected]
112+
lcap config set platform https://defaulttenant.lcap.hadri.163yun.com
113+
lcap config set username admin
114+
lcap config set password Admin@123456
115+
116+
- name: Check Pull Request
117+
run: |
118+
npm run checkPR
119+
{
120+
echo 'CHECK_RESULT<<EOF'
121+
echo $(cat pr_result.json)
122+
echo EOF
123+
} >> "$GITHUB_ENV"
124+
125+
env:
126+
GITHUB_TOKEN: ${{ github.token}}
127+
PULL_REQUEST_ID: ${{ github.event.pull_request.number }}
128+
HEAD_BRANCH_NAME: ${{github.head_ref}}
129+
HEAD_REPOSITORY: ${{github.event.pull_request.head.repo.full_name}}
130+
GITHUB_REPOSITORY: ${{github.repository}}
131+
ACTION_ID: ${{github.run_id}}
132+
133+
- name: Upload PR Result Error
134+
if: ${{fromJson(env.CHECK_RESULT).hasError}}
135+
uses: actions/upload-artifact@v4
136+
with:
137+
name: pr_result
138+
path: pr_result.json
139+
140+
- name: Exit If Error
141+
if: ${{fromJson(env.CHECK_RESULT).hasError}}
142+
run: |
143+
exit 1
144+
145+
- name: Upload Assets
146+
if: ${{fromJson(env.DIFF_STATE).packages[0]}}
147+
uses: actions/upload-artifact@v4
148+
id: upload_assets
149+
with:
150+
name: dist
151+
path: dist/
152+
153+
- name: Append Assets Download url
154+
if: ${{fromJson(env.DIFF_STATE).packages[0]}}
155+
run: |
156+
npm run successPR
157+
env:
158+
ARTIFACT_ID: ${{steps.upload_assets.outputs.artifact-id}}
159+
GITHUB_TOKEN: ${{ github.token}}
160+
PULL_REQUEST_ID: ${{ github.event.pull_request.number }}
161+
HEAD_BRANCH_NAME: ${{github.head_ref}}
162+
HEAD_REPOSITORY: ${{github.event.pull_request.head.repo.full_name}}
163+
GITHUB_REPOSITORY: ${{github.repository}}
164+
ACTION_ID: ${{github.run_id}}
165+
166+
- name: Upload PR Result Error
167+
if: ${{fromJson(env.DIFF_STATE).packages[0]}}
168+
uses: actions/upload-artifact@v4
169+
with:
170+
name: pr_result
171+
path: pr_result.json

.github/workflows/comment-pr.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Comment on the pull request
2+
3+
# read-write repo token
4+
# access to secrets
5+
on:
6+
workflow_run:
7+
workflows: ['Check PR']
8+
types:
9+
- completed
10+
11+
permissions:
12+
pull-requests: write
13+
14+
jobs:
15+
upload:
16+
runs-on: ubuntu-latest
17+
if: >
18+
github.event.workflow_run.event == 'pull_request'
19+
steps:
20+
- name: 'Download artifact'
21+
uses: actions/github-script@v6
22+
with:
23+
script: |
24+
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
run_id: context.payload.workflow_run.id,
28+
});
29+
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
30+
return artifact.name == "pr_result"
31+
})[0];
32+
let download = await github.rest.actions.downloadArtifact({
33+
owner: context.repo.owner,
34+
repo: context.repo.repo,
35+
artifact_id: matchArtifact.id,
36+
archive_format: 'zip',
37+
});
38+
let fs = require('fs');
39+
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_result.zip`, Buffer.from(download.data));
40+
41+
- run: unzip pr_result.zip
42+
- name: 'Comment on PR'
43+
uses: actions/github-script@v6
44+
with:
45+
github-token: ${{ github.token }}
46+
script: |
47+
const fs = require('fs');
48+
const fileContent = fs.readFileSync('./pr_result.json', 'utf-8');
49+
const { message, pull_request_id } = JSON.parse(fileContent);
50+
await github.rest.issues.createComment({
51+
owner: context.repo.owner,
52+
repo: context.repo.repo,
53+
issue_number: pull_request_id,
54+
body: message
55+
});

.github/workflows/release.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# 为了试验,此处作为单独的 Workflow,在实际工作中可 Install -> Lint、Test -> Preview 串行检验
2+
name: Release
3+
4+
# 执行 CI 的时机: 当 git push 到 main分支时
5+
on:
6+
push:
7+
branches: main
8+
9+
permissions:
10+
pull-requests: write
11+
issues: write
12+
contents: write
13+
14+
jobs:
15+
build:
16+
# 仅在pr关闭后执行
17+
if: startsWith(github.event.head_commit.message, 'Merge pull request ')
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Check if commit is from CI
22+
run: |
23+
if [[ "${{ github.event.head_commit.committer.username }}" == "github-actions[bot]" ]]; then
24+
echo "Commit is from CI, skipping the build..."
25+
exit 78
26+
else
27+
echo "Commit is not from CI, continuing with the build..."
28+
fi
29+
- name: see vars
30+
run: |
31+
echo '${{github.head_ref}}'
32+
echo '${{github.ref}}'
33+
echo '${{github.ref_name}}'
34+
echo '${{github.repository}}'
35+
echo '${{ github.run_id }}'
36+
echo '${{github.event.sender.id}}'
37+
echo '${{github.event.repository.fork}}'
38+
echo '${{github.event.repository.name}}'
39+
echo '${{github.event.repository.full_name}}'
40+
echo '${{github.actor}}'
41+
echo '${{github.triggering_actor}}'
42+
- name: Checkout
43+
uses: actions/checkout/@v3
44+
with:
45+
fetch-depth: 1
46+
token: ${{secrets.RELEASE_TOKEN}}
47+
48+
- name: Git Identity
49+
run: |
50+
git config --global user.name 'github-actions[bot]'
51+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
52+
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
53+
git fetch --unshallow
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN}}
56+
57+
- name: Setup Nodejs
58+
uses: actions/setup-node@v3
59+
with:
60+
cache: 'npm'
61+
node-version: 16
62+
63+
- name: Install Dep
64+
run: |
65+
npm install
66+
67+
- name: Detect Pull Request Change
68+
run: |
69+
git config --global core.quotepath false
70+
git config --global gui.encoding utf-8
71+
git config --global i18n.commit.encoding utf-8
72+
git config --global i18n.logoutputencoding utf-8
73+
export LESSCHARSET=utf-8
74+
npm run detectPR from-release
75+
{
76+
echo "DIFF_STATE<<EOF"
77+
echo "$(cat diff_stat.json)"
78+
echo "EOF"
79+
} >> "$GITHUB_ENV"
80+
81+
- name: Set up JDK 8
82+
if: ${{fromJson(env.DIFF_STATE).needJAVA}}
83+
uses: actions/setup-java@v4
84+
with:
85+
java-version: '8'
86+
distribution: 'temurin'
87+
88+
- name: Install JDK Dependency
89+
if: ${{fromJson(env.DIFF_STATE).needJAVA}}
90+
run: |
91+
mvn install:install-file -Dfile="demo_bjz_JiazhenBao/jar/nasl-metadata-maven-plugin-1.3.0/nasl-metadata-maven-plugin-1.3.0.jar" -DpomFile="demo_bjz_JiazhenBao/jar/nasl-metadata-maven-plugin-1.3.0/pom.xml"
92+
mvn install:install-file -DgroupId=com.netease.lowcode -DartifactId=nasl-metadata-collector -Dversion=0.8.0 -Dpackaging=jar -Dfile="demo_bjz_JiazhenBao/jar/nasl-metadata-collector-0.8.0.jar"
93+
94+
- name: Install LCAP
95+
run: |
96+
npm install -g [email protected]
97+
lcap config set platform https://defaulttenant.lcap.hadri.163yun.com
98+
lcap config set username admin
99+
lcap config set password Admin@123456
100+
101+
- name: Check Pull Request
102+
run: |
103+
npm run release from-release
104+
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN}}
107+
HEAD_BRANCH_NAME: ${{github.head_ref}}
108+
GITHUB_REPOSITORY: ${{github.repository}}
109+
ACTION_ID: ${{github.run_id}}

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,17 @@ build/
4242

4343
### node_modules ###
4444
!**/node_modules/
45+
46+
dist/
47+
48+
node_modules/
49+
50+
**/dist-theme/
51+
**/*.zip
52+
53+
**/target/
54+
55+
56+
diff_stat.json
57+
pr_result.json
58+
test.md

StringUtils_fdddf/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
target/
3+
.DS_Store

0 commit comments

Comments
 (0)