Skip to content

Commit 8af78ab

Browse files
test travis streamline
1 parent 6d2e82c commit 8af78ab

5 files changed

+225
-171
lines changed

.travis.yml

+22-171
Original file line numberDiff line numberDiff line change
@@ -1,182 +1,33 @@
11
language: generic
22
sudo: required
33
cache:
4-
timeout: 600
4+
timeout: 1024
55
directories:
6-
- $TRAVIS_BUILD_DIR/target/debug
7-
- /opt/.cargo/git
8-
- /opt/.cargo/registry
9-
services:
10-
- docker
11-
git:
12-
depth: 1
6+
- "./docker/release"
137
stages:
14-
- CheckShell
15-
- Release
16-
- IntegrateTest
8+
- secp256k1
9+
- sm2
10+
- blake2b
1711
before_install:
1812
- docker pull cita/cita-build:ubuntu-18.04-20191128
1913
jobs:
20-
include:
21-
22-
- stage: CheckShell
14+
include:
15+
- stage: secp256k1
2316
script:
24-
# Fail if any of these files have warnings
25-
- shellcheck scripts/*.sh env.sh
26-
27-
- stage: Release
28-
name: Release for Integrate Test
29-
language: node_js
30-
node_js:
31-
# - lts/*
32-
- 8.10.0
33-
cache:
34-
directories:
35-
- $TRAVIS_BUILD_DIR/target/release-cache
36-
env: HASH_ALGO=sha3hash CRYPTO_ALGO=secp256k1
37-
before_script:
38-
- cd $TRAVIS_BUILD_DIR
39-
- ./scripts/replace_default_feature.sh ./ sha3hash ${HASH_ALGO}
40-
- ./scripts/replace_default_feature.sh ./ secp256k1 ${CRYPTO_ALGO}
41-
script: ./env.sh make release
42-
before_cache:
43-
- cd $TRAVIS_BUILD_DIR
44-
- rm -rf target/release-cache
45-
- mv -vf target/install target/release-cache
46-
47-
- &stage-contract-test-sha3-secp256k1
48-
stage: IntegrateTest
49-
name: Unit Group
50-
language: node_js
51-
node_js:
52-
# - lts/*
53-
- 8.10.0
54-
cache:
55-
directories:
56-
- $TRAVIS_BUILD_DIR/target/release-cache
57-
env: HASH_ALGO=sha3hash CRYPTO_ALGO=secp256k1
58-
before_install:
59-
- cd $TRAVIS_BUILD_DIR
60-
- rm -rf target/install
61-
- cp -rv target/release-cache target/install
62-
install:
63-
- rm -rf /opt/cita-run/test-chain
64-
- cd $TRAVIS_BUILD_DIR/target/install
65-
- ./bin/cita create
66-
--nodes "127.0.0.1:4100"
67-
--super_admin "0x4b5ae4567ad5d9fb92bc9afd6a657e6fa13a2523"
68-
- ./bin/cita setup test-chain/0
69-
- ./bin/cita start test-chain/0
70-
before_script:
71-
- cd $TRAVIS_BUILD_DIR/target/install/scripts/contracts/tests
72-
- travis_retry yarn install
73-
script: npm run-script unit_group
74-
- <<: *stage-contract-test-sha3-secp256k1
75-
name: Unit Permission
76-
script: npm run-script unit_permission
77-
- <<: *stage-contract-test-sha3-secp256k1
78-
name: Unit Auth
79-
script: npm run-script unit_auth
80-
- <<: *stage-contract-test-sha3-secp256k1
81-
name: Unit Chain
82-
script: npm run-script unit_chain
83-
- <<: *stage-contract-test-sha3-secp256k1
84-
name: Unit Group Management
85-
script: npm run-script unit_gm
86-
- <<: *stage-contract-test-sha3-secp256k1
87-
name: Unit Permission Management
88-
script: npm run-script unit_pm
89-
- <<: *stage-contract-test-sha3-secp256k1
90-
name: Unit Role Management
91-
script: npm run-script unit_rm
92-
- <<: *stage-contract-test-sha3-secp256k1
93-
name: Unit Quota Management
94-
script: npm run-script unit_qm
95-
- <<: *stage-contract-test-sha3-secp256k1
96-
name: Unit Quota
97-
script: npm run-script unit_quota
98-
- <<: *stage-contract-test-sha3-secp256k1
99-
name: Unit Abi
100-
script: npm run-script abi
101-
- <<: *stage-contract-test-sha3-secp256k1
102-
name: Unit Admin
103-
script: npm run-script unit_admin
104-
- <<: *stage-contract-test-sha3-secp256k1
105-
name: Unit Store
106-
script: npm run-script store
107-
- <<: *stage-contract-test-sha3-secp256k1
108-
name: Unit Batch Tx
109-
script: npm run-script batch_tx
110-
- <<: *stage-contract-test-sha3-secp256k1
111-
name: Unit Uint8
112-
script: npm run-script uint8
113-
- <<: *stage-contract-test-sha3-secp256k1
114-
name: Unit VersionManager
115-
script: npm run-script unit_vm
116-
117-
- <<: *stage-contract-test-sha3-secp256k1
118-
name: Unit Node
119-
install:
120-
- cd $TRAVIS_BUILD_DIR/target/install
121-
- ./bin/cita create
122-
--nodes "127.0.0.1:4000,127.0.0.1:4001,127.0.0.1:4002"
123-
--super_admin "0x4b5ae4567ad5d9fb92bc9afd6a657e6fa13a2523"
124-
- for i in {0..2} ; do
125-
./bin/cita setup test-chain/$i
126-
&& ./bin/cita start test-chain/$i ;
127-
done
17+
- "./scripts/release_sha3.sh"
18+
- stage: sm2
12819
script:
129-
- npm run-script unit_node
130-
131-
- <<: *stage-contract-test-sha3-secp256k1
132-
name: Integrate Quota
133-
install:
134-
- cd $TRAVIS_BUILD_DIR/target/install
135-
- ./bin/cita create
136-
--nodes "127.0.0.1:4100"
137-
--contract_arguments "SysConfig.checkQuota=true"
138-
--super_admin "0x4b5ae4567ad5d9fb92bc9afd6a657e6fa13a2523"
139-
- ./bin/cita setup test-chain/0
140-
- ./bin/cita start test-chain/0
20+
- "./scripts/release_sm2.sh"
21+
- stage: blake2b
14122
script:
142-
- npm run-script integrate_quota
143-
144-
- <<: *stage-contract-test-sha3-secp256k1
145-
name: Integrate Permission
146-
install:
147-
- cd $TRAVIS_BUILD_DIR/target/install
148-
- ./bin/cita create
149-
--nodes "127.0.0.1:4100"
150-
--contract_arguments "SysConfig.checkCallPermission=true"
151-
--super_admin "0x4b5ae4567ad5d9fb92bc9afd6a657e6fa13a2523"
152-
- ./bin/cita setup test-chain/0
153-
- ./bin/cita start test-chain/0
154-
script:
155-
- npm run-script permission
156-
157-
- <<: *stage-contract-test-sha3-secp256k1
158-
name: Integrate AutoExec
159-
install:
160-
- cd $TRAVIS_BUILD_DIR/target/install
161-
- ./bin/cita create
162-
--nodes "127.0.0.1:4100"
163-
--contract_arguments "SysConfig.autoExec=true"
164-
--super_admin "0x4b5ae4567ad5d9fb92bc9afd6a657e6fa13a2523"
165-
- ./bin/cita setup test-chain/0
166-
- ./bin/cita start test-chain/0
167-
script:
168-
- npm run-script auto_exec
169-
170-
- <<: *stage-contract-test-sha3-secp256k1
171-
name: Integrate Lifetime
172-
install:
173-
- cd $TRAVIS_BUILD_DIR/target/install
174-
- ./bin/cita create
175-
--nodes "127.0.0.1:4100"
176-
--contract_arguments "SysConfig.economicalModel=1 PriceManager.quotaPrice=1"
177-
--super_admin "0x4b5ae4567ad5d9fb92bc9afd6a657e6fa13a2523"
178-
--init_token 0x1000000
179-
- ./bin/cita setup test-chain/0
180-
- ./bin/cita start test-chain/0
181-
script:
182-
- npm run-script lifetime
23+
- "./scripts/release_black2b.sh"
24+
deploy:
25+
provider: releases
26+
api_key:
27+
secure: UmH2AT2HhPBL3wkaFa5lCRnK5j1PbqeT7w4LpJ7LqS7/YakpIYlMLmLutEVH2Gu8tvhUHM7Wm2soHMWUgo08L+eN7RPeV6t2r6z/5N9aD4I+l7ki5W6XwwZ5kYcs05xuSFn6cJxyPHR4TeM1aZmJ+/ngKAUhdGr6f16z1XAt4HUvg/HKVOZRukbnHp3pKQeMuXYlMSJBsaAvyY64cwGnKQMngAnZJxEG7s/5LfJb3zrlfxm2gRSnvcvTjdfeYSk4kXaWvWVQXeNIwEjNkKu7/EnoaYr5hmylTGukA8lIMeDdmJClroBZeTESJLSZ0gLNIlX03PyM50IVMayKp16+aAf6IY0/CPFYZSCGtR6MyV4GpQBMHgNkNR+B6TtzR9N7CRoXtoKfK5Gb/sba3Y01koaFRwq6Fu0rjofl+u04R8JEMaBKzY/OgjK2nbhYReU63dRWEesFZOxVYhp9v9/Tv+0ZFluq9Aukn7c4ePs96YBaUgCVbtzCebyNx85t05C0RmXaB/EsX7VwXwoJltE8CGJ9A9ZuBusZsjupFNOxsqzrNzhfkro5BVp7jgBgSn0X9D2dx1PL6xNkMneLz5npyrcbshFXjOkMV9d0w9gMX543tQlfuVIBPmrGGFGqX2cRWADwoRKKfxVSoWrHR0RhQk8dF3pcVsmILS70PCoSqGI=
28+
file:
29+
- "./docker/release/cita_secp256k1_sha3.tar.gz"
30+
- "./docker/release/cita_sm2_sm3.tar.gz"
31+
- "./docker/release/cita_ed25519_blake2b.tar.gz"
32+
on:
33+
tags: true

scripts/release_black2b.sh

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
DIR=./docker/release
3+
SOURCE_DIR=`pwd`
4+
echo "pwd travis is " "$(pwd)"
5+
git submodule init
6+
git submodule update
7+
8+
function replace_default_feature () {
9+
local workspacedir="${1}"
10+
local old_feature="${2}"
11+
local new_feature="${3}"
12+
if [ "${old_feature}" = "${new_feature}" ]; then
13+
return
14+
fi
15+
local before_feature='[ \t]*default[ \t]*=[ \t]*\[.*\"'
16+
local before_feature2='[ \t]*features[ \t]*=[ \t]*\[.*\"'
17+
local all_feature='[ \t]*\(features\|default\)[ \t]*=[ \t]*\[.*\"'
18+
local after_feature='\".*'
19+
find "${workspacedir}" -mindepth 2 -name "Cargo.toml" -print0 \
20+
| xargs -0 grep -l "^${all_feature}${old_feature}${after_feature}" \
21+
| while read -r cargotoml; do
22+
if [ -f "${cargotoml}" ]; then
23+
echo "[Info ] Replace [${old_feature}] by [${new_feature}] for [${cargotoml}] ..."
24+
sed -i "s/\(${before_feature}\)${old_feature}\(${after_feature}\)\$/\1${new_feature}\2/" "${cargotoml}"
25+
sed -i "s/\(${before_feature2}\)${old_feature}\(${after_feature}\)\$/\1${new_feature}\2/" "${cargotoml}"
26+
else
27+
echo "[Error] [${cargotoml}] is not a file."
28+
fi
29+
done
30+
}
31+
32+
DEFAULT_HASH="sha3hash"
33+
DEFAULT_CRYPT="secp256k1"
34+
35+
# blake2b
36+
SELECT_HASH_Blake2b="blake2bhash"
37+
SELECT_CRYPT_Blake2b="ed25519"
38+
39+
function replace_algorithm_blake2b() {
40+
replace_default_feature "${SOURCE_DIR}" "${DEFAULT_HASH}" "${SELECT_HASH_Blake2b}"
41+
replace_default_feature "${SOURCE_DIR}" "${DEFAULT_CRYPT}" "${SELECT_CRYPT_Blake2b}"
42+
}
43+
44+
replace_algorithm_blake2b
45+
sudo rm -rf target
46+
sudo ./env.sh make release > /dev/null
47+
cp -r target/install $DIR/cita_ed25519_blake2b
48+

scripts/release_multi_algorithm.sh

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/bash
2+
DIR=./docker/release
3+
SOURCE_DIR=`pwd`
4+
echo "pwd travis is " "$(pwd)"
5+
git submodule init
6+
git submodule update
7+
8+
function replace_default_feature () {
9+
local workspacedir="${1}"
10+
local old_feature="${2}"
11+
local new_feature="${3}"
12+
if [ "${old_feature}" = "${new_feature}" ]; then
13+
return
14+
fi
15+
local before_feature='[ \t]*default[ \t]*=[ \t]*\[.*\"'
16+
local before_feature2='[ \t]*features[ \t]*=[ \t]*\[.*\"'
17+
local all_feature='[ \t]*\(features\|default\)[ \t]*=[ \t]*\[.*\"'
18+
local after_feature='\".*'
19+
find "${workspacedir}" -mindepth 2 -name "Cargo.toml" -print0 \
20+
| xargs -0 grep -l "^${all_feature}${old_feature}${after_feature}" \
21+
| while read -r cargotoml; do
22+
if [ -f "${cargotoml}" ]; then
23+
echo "[Info ] Replace [${old_feature}] by [${new_feature}] for [${cargotoml}] ..."
24+
sed -i "s/\(${before_feature}\)${old_feature}\(${after_feature}\)\$/\1${new_feature}\2/" "${cargotoml}"
25+
sed -i "s/\(${before_feature2}\)${old_feature}\(${after_feature}\)\$/\1${new_feature}\2/" "${cargotoml}"
26+
else
27+
echo "[Error] [${cargotoml}] is not a file."
28+
fi
29+
done
30+
}
31+
32+
# sha256
33+
sudo rm -rf target
34+
sed -i "s/\"\${USE_TTY}\" \"\${CONTAINER_NAME}\"/\${USE_TTY} \${CONTAINER_NAME}/" ./env.sh
35+
sudo ./env.sh make release
36+
37+
cp -r target/install $DIR/cita_secp256k1_sha3
38+
39+
DEFAULT_HASH="sha3hash"
40+
DEFAULT_CRYPT="secp256k1"
41+
42+
# sm2
43+
SELECT_HASH_SM2="sm3hash"
44+
SELECT_CRYPT_SM2="sm2"
45+
function replace_algorithm_sm2() {
46+
replace_default_feature "${SOURCE_DIR}" "${SELECT_HASH}" "${SELECT_HASH_SM2}"
47+
replace_default_feature "${SOURCE_DIR}" "${SELECT_CRYPT}" "${SELECT_CRYPT_SM2}"
48+
}
49+
replace_algorithm_sm2
50+
sudo rm -rf target
51+
sudo ./env.sh make release > /dev/null
52+
cp -r target/install $DIR/cita_sm2_sm3
53+
54+
55+
# blake2b
56+
SELECT_HASH_Blake2b="blake2bhash"
57+
SELECT_CRYPT_Blake2b="ed25519"
58+
59+
function replace_algorithm_blake2b() {
60+
replace_default_feature "${SOURCE_DIR}" "${DEFAULT_HASH}" "${SELECT_HASH_Blake2b}"
61+
replace_default_feature "${SOURCE_DIR}" "${DEFAULT_CRYPT}" "${SELECT_CRYPT_Blake2b}"
62+
}
63+
64+
replace_algorithm_blake2b
65+
sudo rm -rf target
66+
sudo ./env.sh make release > /dev/null
67+
cp -r target/install $DIR/cita_ed25519_blake2b
68+
69+
# tar.gz
70+
cd $DIR
71+
tar -zcf cita_secp256k1_sha3.tar.gz cita_secp256k1_sha3
72+
tar -zcf cita_sm2_sm3.tar.gz cita_sm2_sm3
73+
tar -zcf cita_ed25519_blake2b.tar.gz cita_ed25519_blake2b
74+
75+
# build image
76+
CITA_REPOSITORY_NAME=hhliyan/cli-test-20
77+
cat "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
78+
docker push "$CITA_CLI_REPOSITORY_NAME":"$TRAVIS_TAG"
79+
80+
81+
docker build . --build-arg ENCRYPTION_ALG=secp256k1 --build-arg HASH_ALG=sha3 -t $CITA_REPOSITORY_NAME:$TRAVIS_TAG-secp256k1-sha3
82+
docker push $CITA_REPOSITORY_NAME:$TRAVIS_TAG-secp256k1-sha3
83+
84+
docker build . --build-arg ENCRYPTION_ALG=sm2 --build-arg HASH_ALG=sm3 -t $CITA_REPOSITORY_NAME:$TRAVIS_TAG-sm2-sm3
85+
docker push $CITA_REPOSITORY_NAME:$TRAVIS_TAG-sm2-sm3
86+
87+
88+
docker build . --build-arg ENCRYPTION_ALG=ed25519 --build-arg HASH_ALG=blake2b -t $CITA_REPOSITORY_NAME:$TRAVIS_TAG-ed25519-blake2b
89+
docker push $CITA_REPOSITORY_NAME:$TRAVIS_TAG-ed25519-blake2b
90+
91+
92+
93+
94+

scripts/release_sha3.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
#!/bin/bash
3+
git submodule init
4+
git submodule update
5+
6+
DIR=./docker/release
7+
8+
sudo rm -rf target
9+
10+
sed -i "s/\"\${USE_TTY}\" \"\${CONTAINER_NAME}\"/\${USE_TTY} \${CONTAINER_NAME}/" ./env.sh
11+
sudo ./env.sh make release
12+
13+
cp -r target/install $DIR
14+
cd $DIR
15+
tar czvf cita_secp256k1_sha3.tar.gz cita_secp256k1_sha3

0 commit comments

Comments
 (0)