-
Notifications
You must be signed in to change notification settings - Fork 4
165 lines (163 loc) · 6.92 KB
/
test-upload.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: test upload
on:
workflow_dispatch:
jobs:
#--------
check-commit:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 20
matrix:
iotdb_version: [ rel/0.12 ]
outputs:
check_date: ${{ steps.sys-info.outputs.date }}
# commit_id: dc2062c0dc2146b9967572c3989b3a234765a033
commit_id: ${{ steps.iotdb-info.outputs.commit_id }}
# commit_id_short: dc2062c
commit_id_short: ${{ steps.iotdb-info.outputs.commit_id_short }}
# commit_time: 2022-08-15 14:09:59 +0800
commit_time: ${{ steps.iotdb-info.outputs.commit_time }}
# branch: master, rel/0.12, rel/0.13
branch: ${{ steps.iotdb-info.outputs.branch }}
# version, eg: 0.13.2-SNAPSHOT
version: ${{ steps.iotdb-info.outputs.version }}
# commit_timestamp: 1660550464
commit_timestamp: ${{ steps.check-commit.outputs.commit_timestamp }}
steps:
# 收集公共信息
- name: collect common info
shell: bash
id: sys-info
run: echo "::set-output name=date::$(date +"%Y-%m-%d")"
# clone iotdb
- name: checkout apache/iotdb
uses: actions/checkout@v2
with:
path: iotdb
repository: 'apache/iotdb'
ref: ${{ matrix.iotdb_version }}
fetch-depth: 0
# 收集iotdb信息
- name: collect IoTDB information
id: iotdb-info
run: |
cd ${{ github.workspace }}/iotdb
echo "::set-output name=commit_id::$(git rev-parse HEAD)"
echo "::set-output name=commit_id_short::$(git rev-parse --short HEAD)"
echo "::set-output name=commit_time::$(git log -n1 --pretty='format:%cd' --date=iso)"
echo "::set-output name=branch::$(git branch |grep ^*|cut -d ' ' -f 2)"
echo "::set-output name=version::$(cat pom.xml | grep -e '^ <version>' | sed 's# ##g' | sed 's#<version>##g' | sed 's#</version>##g')"
# clone 本程序
- name: checkout iotdb-daily-build
uses: actions/checkout@v2
with:
path: iotdb-daily-build
repository: 'xiaoyekanren/iotdb-daily-build'
ref: master
fetch-depth: 0
# clone 本程序 db分支
- name: Checkout db for save results
uses: actions/checkout@v2
with:
path: db
repository: 'xiaoyekanren/iotdb-daily-build'
ref: db
fetch-depth: 0
# 检查db文件,如果有commit就更新db,并开始后续测试
- name: check
id: check-commit
env:
PYTHONPATH: $PYTHONPATH:${{ github.workspace }}/iotdb-daily-build/action-test-build_rel012
run: |
cd ${{ github.workspace }}/iotdb-daily-build/action-test-build_rel012
result=$(python3 check_commit.py '${{ github.workspace }}/db/db/db.db' '${{ steps.iotdb-info.outputs.branch }}' '${{ steps.iotdb-info.outputs.commit_id }}' '${{ steps.iotdb-info.outputs.commit_time }}')
echo "::set-output name=result::$(echo $result)"
commit_timestamp=$(python3 time_switch.py '${{ steps.iotdb-info.outputs.commit_time }}')
echo "::set-output name=commit_timestamp::$(echo $commit_timestamp)"
# 输出检查结果
- name: echo check status
run: |
echo ${{ steps.check-commit.outputs.result }}
# 判断是stop还是update
# exit 0 是正常退出,exit 其他数 是错误退出
- name: check check's results
if: ${{ steps.check-commit.outputs.result == 'stop' }}
run: exit 0
## 上传db文件
# - name: upload db
# if: ${{ steps.check-commit.outputs.result == 'update' }}
# env:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# run: |
# cd ${{ github.workspace }}/db
# git config --local user.email "876670773+github-actions[bot]@qq.com"
# git config --local user.name "github-actions[bot]"
# cd db
# git add db.db
# git commit -m "${{steps.sys-info.outputs.date}} github-actions[bot] push update "
# git push -u origin db
## debug
# - name: check
# id: check-commit
# env:
# PYTHONPATH: $PYTHONPATH:${{ github.workspace }}/iotdb-daily-build/action-test-build_rel012
# run: |
# cd ${{ github.workspace }}/iotdb-daily-build/action-test-build_rel012
# python3 test_db.py '${{ github.workspace }}/db/db/db.db' 'select * from commit_last'
#--------
build:
needs: [ check-commit ]
strategy:
matrix:
java_version: [ 8,11 ]
runs-on: ubuntu-latest
steps:
# set java
- name: Set java ${{ matrix.java_version }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java_version }}
# clone iotdb
- name: Checkout apache/iotdb
uses: actions/checkout@v2
with:
path: iotdb
repository: 'apache/iotdb'
ref: ${{ needs.check-commit.outputs.branch }}
fetch-depth: 0
# 编译打包iotdb
- name: compile iotdb
id: iotdb-info
run: |
cd ${{ github.workspace }}/iotdb
git checkout ${{ needs.check-commit.outputs.commit_id }}
mvn clean package -DskipTests
# 给压缩包重命名,最终上传的文件名称
- name: reanme zip
id: rename
run: |
echo "::set-output name=all::$(echo ${{ github.workspace }}/upload_folder/apache-iotdb-${{ needs.check-commit.outputs.version }}-all-bin-${{ needs.check-commit.outputs.commit_timestamp }}-${{ needs.check-commit.outputs.commit_id_short }}-java${{ matrix.java_version }}.zip)"
echo "::set-output name=cli::$(echo ${{ github.workspace }}/upload_folder/apache-iotdb-${{ needs.check-commit.outputs.version }}-cli-bin-${{ needs.check-commit.outputs.commit_timestamp }}-${{ needs.check-commit.outputs.commit_id_short }}-java${{ matrix.java_version }}.zip)"
# 拷贝要上传的文件到外层目录
- name: ready to upload file
run: |
mkdir -p ${{ github.workspace }}/upload_folder
cd ${{ github.workspace }}/upload_folder
cp ${{ github.workspace }}/iotdb/distribution/target/apache-iotdb-${{ needs.check-commit.outputs.version }}-all-bin.zip ${{ steps.rename.outputs.all }}
cp ${{ github.workspace }}/iotdb/distribution/target/apache-iotdb-${{ needs.check-commit.outputs.version }}-cli-bin.zip ${{ steps.rename.outputs.cli }}
# 上传iotdb包
- name: copy file via ssh password
uses: appleboy/scp-action@master
with:
host: ${{ secrets.FILE_SERVER_IP }}
username: ${{ secrets.FILE_SERVER_IP_USER }}
password: ${{ secrets.FILE_SERVER_IP_PASSWORD }}
port: ${{ secrets.FILE_SERVER_IP_PORT }}
timeout: 120s
command_timeout: 60m
source: "${{ steps.rename.outputs.all }},${{ steps.rename.outputs.cli }}"
target: "files/${{ needs.check-commit.outputs.version }}"
tar_tmp_path: "/tmp"
# strip_components - remove the specified number of leading path elements.
strip_components: 3