-
Notifications
You must be signed in to change notification settings - Fork 235
131 lines (128 loc) · 6.23 KB
/
smoking_test.yaml
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
name: Smoking test suit
on:
workflow_dispatch:
inputs:
CKB_linux_release_package:
description: 'Linux release package to somking test'
required: false
repository_dispatch:
types: [ smoking-test ]
env:
RUSTFLAGS: "-D warnings"
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
TESTNET_SNAPSHOT_URL: ${{secrets.TESTNET_SNAPSHOT_URL}}
CARGO_TARGET_DIR: ${{ github.workspace }}/../target
PGHOST: ${{ secrets.PGHOST }}
PGPORT: ${{ secrets.PGPORT }}
PGUSER: ${{ secrets.PGUSER }}
PGPASSWORD: ${{ secrets.PGPASSWORD }}
PGDATABASE: "ckbtest"
jobs:
Start_and_sync:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Download&Unzip v0.35.0
run: |
echo "start_time=$(date +%Y-%m-%d' '%H:%M:%S.%6N)" >> $GITHUB_ENV
if [ ! -f "/tmp/ckb_v0.35.0_linux.tar.gz" ]; then
curl -L https://github.com/nervosnetwork/ckb/releases/download/v0.35.0/ckb_v0.35.0_x86_64-unknown-linux-gnu.tar.gz -o /tmp/ckb_v0.35.0_linux.tar.gz
fi
tar -zxf /tmp/ckb_v0.35.0_linux.tar.gz -C /tmp
cp /tmp/ckb_*/ckb ${{ github.workspace }}/ckb
rm -rf /tmp/ckb_*
- name: Update ExecStart&StandardOutput
run: |
sed -i "s#User=.*#User=$USER#g" ${{ github.workspace }}/devtools/smoking_test/ckb.service
sed -i "s#ExecStart=.*#ExecStart=${{github.workspace}}/ckb run -C ${{github.workspace}}#g" ${{ github.workspace }}/devtools/smoking_test/ckb.service
sed -i "s#StandardOutput=.*#StandardOutput=file:${{github.workspace}}/data/logs/run.log#g" ${{ github.workspace }}/devtools/smoking_test/ckb.service
- name: Init&Start ckb testnet with v0.35.0
run: |
${{ github.workspace }}/ckb init -c testnet -C ${{ github.workspace }} --force
sudo cp ${{ github.workspace }}/devtools/smoking_test/ckb.service /etc/systemd/system/ckb.service
sudo systemctl daemon-reload
sudo systemctl enable ckb
sudo service ckb start
sleep 600
sudo service ckb stop
sudo systemctl disable ckb
sudo rm /etc/systemd/system/ckb.service
sudo systemctl daemon-reload
sudo systemctl reset-failed
rm ${{ github.workspace }}/ckb
- run: sudo apt-get update && sudo apt-get install libssl-dev pkg-config libclang-dev -y && sudo apt-get install -y gcc-multilib
- run: sudo apt-get install -y wget ca-certificates && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - && sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' && sudo apt-get update && sudo apt-get install -y postgresql postgresql-contrib
- name: Download target ckb release pkg and copy binary to github workspace
if: |
(github.event_name == 'workflow_dispatch' && github.event.inputs.CKB_linux_release_package != '')
|| contains(github.event_name, 'repository_dispatch')
run: |
if [ -z ${{ github.event.inputs.CKB_linux_release_package }} ]; then
curl -L ${{ github.event.client_payload.CKB_linux_release_package }} -o /tmp/ckb.7z
7za x "/tmp/ckb.7z" -r -o/tmp
fi
if [ -z ${{ github.event.client_payload.CKB_linux_release_package }} ]; then
curl -L ${{ github.event.inputs.CKB_linux_release_package }} -o /tmp/ckb.tar.gz
tar -zxf /tmp/ckb.tar.gz -C /tmp
fi
cp /tmp/ckb_*/ckb ${{ github.workspace }}/ckb
- name: Build CKB binary
if: |
(github.event_name == 'workflow_dispatch' && github.event.inputs.CKB_linux_release_package == '')
&& ! contains(github.event_name, 'repository_dispatch')
run: |
make build
cp ${CARGO_TARGET_DIR}/release/ckb ${{ github.workspace }}/ckb
- name: Update ExecStart&StandardOutput
run: |
sed -i "s#User=.*#User=$USER#g" ${{ github.workspace }}/devtools/smoking_test/ckb.service
sed -i "s#ExecStart=.*#ExecStart=${{github.workspace}}/ckb run -C ${{github.workspace}}#g" ${{ github.workspace }}/devtools/smoking_test/ckb.service
sed -i "s#StandardOutput=.*#StandardOutput=file:${{github.workspace}}/data/logs/run.log#g" ${{ github.workspace }}/devtools/smoking_test/ckb.service
- name: Regenerate testnet configuration
run: |
${{ github.workspace }}/ckb init -c testnet -C ${{ github.workspace }} --force
- name: Migration check
run: |
${{ github.workspace }}/devtools/smoking_test/check-migrate.sh
- name: Start ckb service.
if: ${{ success() }}
run: |
sudo cp ${{ github.workspace }}/devtools/smoking_test/ckb.service /etc/systemd/system/ckb.service
sudo systemctl daemon-reload
sudo systemctl enable ckb
sudo service ckb start
sudo service ckb status
- name: Ensure the ckb service is health.
run: ${{ github.workspace }}/devtools/smoking_test/tip_block_growth_check.sh
- name: Stop & clean ckb service.
if: ${{ success() }}
run: |
rm -rf /tmp/data
rm -rf /tmp/ckb*
sudo service ckb stop
sudo systemctl disable ckb
sudo systemctl daemon-reload
sudo systemctl reset-failed
sudo rm /etc/systemd/system/ckb.service
echo "GITHUB_RUN_STATE=0" >> $GITHUB_ENV
- name: Set test state when test failed.
if: ${{ failure() }}
run: |
echo "GITHUB_RUN_STATE=1" >> $GITHUB_ENV
- name: insert data to DB
if: ${{ always() && github.repository_owner == 'nervosnetwork'}}
env:
PGHOST: ${{ secrets.PGHOST }}
PGPORT: ${{ secrets.PGPORT }}
PGUSER: ${{ secrets.PGUSER }}
PGPASSWORD: ${{ secrets.PGPASSWORD }}
PGDATABASE: ckbtest
run: |
if [ -z "${PGHOST}" ];then
end_time=$(date +%Y-%m-%d' '%H:%M:%S.%6N)
psql -c "INSERT INTO smoking_test (github_run_id,github_run_state,start_time,end_time,github_branch,github_trigger_event,github_run_link) \
VALUES ('$GITHUB_RUN_ID','${{ env.GITHUB_RUN_STATE }}','${{ env.start_time }}','$end_time','${{ github.ref_name }}','${{ github.event_name }}','https://github.com/${{ github.repository }}actions/runs/${{ github.run_id }}');"
fi
env:
CKB_DIR: ${{ github.workspace }}