Skip to content

Commit 4d61f00

Browse files
wanwiset25gzliudanwgr523GalaxySciTechwjrjerome
authored
devnet cicd (#114)
* cicd test * typo * test2 * fix * fix2 * fix3 * trig * change workflow name * chekout step * fix * adjust params * re org files * bug * clean output * Feature testdevelop4 (#113) * final update * name * name * add enable-0x-prefix flag (#102) * enable 0x test flag * rm test file * change script repo * API GetTransactionProof, GetReceiptProof (#94) * API GetReceiptProof * API GetReceiptProof test * add ext interface * Trieproof fix (#96) Trieproof fix * add GetTransactionProof to api * merge two API into GetTransactionAndReceiptProof --------- Co-authored-by: wanwiset25 <[email protected]> Co-authored-by: Galaxy <[email protected]> * first copy v1.10 * fix all errs outside rpc by adding functions * fix rpc errors * upgrade xdc to use gorilla for websocket instead of the native net * upgrade go to 1.14 * fix issue with the duplicated name of max_socket_path_size from c * change to self common * add back the missing committed input parameter * EpochNumber ummarshal --------- Co-authored-by: Daniel Liu <[email protected]> Co-authored-by: wgr523 <[email protected]> Co-authored-by: Galaxy <[email protected]> Co-authored-by: Jianrong <[email protected]>
1 parent 647103a commit 4d61f00

File tree

9 files changed

+103
-10
lines changed

9 files changed

+103
-10
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
name: Build and update image
2-
1+
name: Build and publish image
32
on:
43
push:
54
branches:
65
- master
76
tags:
87
- "*"
9-
108
workflow_dispatch: #allow manual trigger to workflow
119

1210
jobs:
13-
test_on_pr:
11+
test_build_and_push_to_docker_registry:
1412
name: Test, build and push image to registry
1513
runs-on: ubuntu-latest
1614
env:
@@ -24,6 +22,7 @@ jobs:
2422
uses: actions/checkout@v3
2523
with:
2624
path: ${{ env.GOPATH }}/src/XDC-Subnet
25+
2726
- name: Use Node.js
2827
uses: actions/setup-node@v1
2928
with:
@@ -42,6 +41,7 @@ jobs:
4241
make test
4342
env:
4443
GO111MODULE: auto
44+
4545
- name: Docker login
4646
env:
4747
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
@@ -53,12 +53,13 @@ jobs:
5353
id: image
5454
run: |
5555
if [[ "${{github.ref_name}}" == "master" ]]; then
56-
echo "name= xinfinorg/xdcsubnets:latest" >> $GITHUB_OUTPUT
56+
echo "name=xinfinorg/xdcsubnets:latest" >> $GITHUB_OUTPUT
5757
else
58-
echo "name= xinfinorg/xdcsubnets:${{github.ref_name}}" >> $GITHUB_OUTPUT
58+
echo "name=xinfinorg/xdcsubnets:${{github.ref_name}}" >> $GITHUB_OUTPUT
5959
fi
6060
6161
- name: Build and push image
6262
run: |
6363
docker build . --file docker/Dockerfile --tag ${{ steps.image.outputs.name }}
6464
docker push ${{ steps.image.outputs.name }}
65+

.github/workflows/pr_deploy.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Build and deploy devnet
2+
on:
3+
pull_request_target:
4+
branches:
5+
- master
6+
7+
jobs:
8+
build_and_deploy:
9+
if: startsWith(github.head_ref, 'feature') || startsWith(github.head_ref, 'fix')
10+
name: Deploy on PR
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out code
14+
uses: actions/checkout@v3
15+
16+
- name: check out trigger branch
17+
run: |
18+
git fetch origin ${{ github.head_ref }}
19+
git checkout ${{ github.head_ref }}
20+
21+
# - name: check envs
22+
# run: |
23+
# echo ${{ github.head_ref }}
24+
# echo ${{ github.repository }}
25+
# echo ${{ github.ref_name }}
26+
# echo ${{ github.sha }}
27+
28+
- name: Record branch env
29+
id: branch
30+
run: |
31+
echo "repo=${{ github.repository }}" >> $GITHUB_OUTPUT
32+
echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
33+
echo "commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
34+
# echo $repo
35+
# echo $branch
36+
# echo $commit
37+
38+
- name: Docker login
39+
env:
40+
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
41+
DOCKER_PASSWORD: ${{secrets.DOCKER_ACCESS_TOKEN}}
42+
run: |
43+
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
44+
45+
- name: Determine Docker Image Name
46+
id: image
47+
run: |
48+
echo "name=xinfinorg/xdcsubnets:${{ steps.branch.outputs.branch }}" >> $GITHUB_OUTPUT
49+
50+
51+
- name: Build and push image
52+
run: |
53+
docker build . --file docker/Dockerfile --tag ${{ steps.image.outputs.name }}
54+
docker push ${{ steps.image.outputs.name }}
55+
56+
- name: trigger deploy workflow
57+
id: trigger_deploy
58+
run: |
59+
echo "RESPONSE_CODE=$( \
60+
curl -L \
61+
-o response.txt \
62+
-w %{response_code} \
63+
-s \
64+
-X POST \
65+
-H "Accept: application/vnd.github+json" \
66+
-H "Authorization: Bearer ${{ secrets.CICD_PAT }}" \
67+
-H "X-GitHub-Api-Version: 2022-11-28" \
68+
https://api.github.com/repos/hash-laboratories-au/subnet-deployment/actions/workflows/subnet-deploy.yaml/dispatches \
69+
-d '{"ref":"master", "inputs":{"caller_repo": "${{ steps.branch.outputs.repo }}", "caller_ref": "${{ steps.branch.outputs.branch }}", "caller_sha": "${{ steps.branch.outputs.commit }}"}}' \
70+
)" >> $GITHUB_ENV
71+
72+
- name: Check response fail or success
73+
run: |
74+
cat response.txt
75+
echo "RESPONSE_CODE=${{ env.RESPONSE_CODE }}"
76+
if [ ${{ env.RESPONSE_CODE }} != 204 ]
77+
then
78+
exit 1
79+
fi
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
name: PR tests
2-
32
on:
43
pull_request:
54
branches:
65
- master
76

87
jobs:
98
test_on_pr:
10-
name: Test
9+
name: Test on PR
1110
runs-on: ubuntu-latest
1211
env:
1312
GOPATH: ${{ github.workspace }}

cmd/XDC/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
165165
common.TIPXDCXCancellationFee = common.TIPXDCXCancellationFeeTestnet
166166
}
167167

168+
if ctx.GlobalBool(utils.Enable0xPrefixFlag.Name) {
169+
common.Enable0xPrefix = true
170+
}
171+
168172
// Rewound
169173
if rewound := ctx.GlobalInt(utils.RewoundFlag.Name); rewound != 0 {
170174
common.Rewound = uint64(rewound)

cmd/XDC/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ var (
112112
//utils.TestnetFlag,
113113
//utils.VMEnableDebugFlag,
114114
utils.XDCTestnetFlag,
115+
utils.Enable0xPrefixFlag,
115116
utils.RewoundFlag,
116117
utils.NetworkIdFlag,
117118
utils.RPCCORSDomainFlag,

cmd/utils/flags.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ var (
116116
Usage: "Rollback chain at hash",
117117
Value: "",
118118
}
119+
Enable0xPrefixFlag = cli.BoolFlag{
120+
Name: "enable-0x-prefix",
121+
Usage: "Addres use 0x-prefix (default = false)",
122+
}
119123
// General settings
120124
AnnounceTxsFlag = cli.BoolFlag{
121125
Name: "announce-txs",

common/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var TIPXDCXCancellationFeeTestnet = big.NewInt(0)
4343

4444
var TIPXDCXTestnet = big.NewInt(0)
4545
var IsTestnet bool = false
46+
var Enable0xPrefix bool = false
4647
var StoreRewardFolder string
4748
var RollbackHash Hash
4849
var BasePrice = big.NewInt(1000000000000000000) // 1

common/types.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,11 @@ func (a *Address) Set(other Address) {
250250
// MarshalText returns the hex representation of a.
251251
func (a Address) MarshalText() ([]byte, error) {
252252
// Handle '0x' or 'xdc' prefix here.
253-
// return hexutil.Bytes(a[:]).MarshalText()
254-
return hexutil.Bytes(a[:]).MarshalXDCText()
253+
if Enable0xPrefix {
254+
return hexutil.Bytes(a[:]).MarshalText()
255+
} else {
256+
return hexutil.Bytes(a[:]).MarshalXDCText()
257+
}
255258
}
256259

257260
// UnmarshalText parses a hash in hex syntax.

docker/start.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,5 @@ XDC $params \
146146
--targetgaslimit "420000000" \
147147
--ws --wsaddr=0.0.0.0 \
148148
--mine \
149+
--enable-0x-prefix \
149150
--wsorigins "*" 2>&1 >>$DATA_DIR/xdc.log | tee --append $DATA_DIR/xdc.log

0 commit comments

Comments
 (0)