-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathgateway-contracts-deployment-tests.yml
More file actions
151 lines (137 loc) · 6.92 KB
/
gateway-contracts-deployment-tests.yml
File metadata and controls
151 lines (137 loc) · 6.92 KB
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
name: gateway-contracts-deployment-tests
permissions: {}
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-changes:
name: gateway-contracts-deployment-tests/check-changes
permissions:
actions: 'read' # Required to read workflow run information
contents: 'read' # Required to checkout repository code
pull-requests: 'read' # Required to read pull request information
runs-on: ubuntu-latest
outputs:
changes-gw-contracts: ${{ steps.filter.outputs.gw-contracts }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: 'false'
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: |
gw-contracts:
- .github/workflows/gateway-contracts-deployment-tests.yml
- gateway-contracts/**
sc-deploy:
name: gateway-contracts-deployment-tests/sc-deploy (bpr)
needs: check-changes
if: ${{ needs.check-changes.outputs.changes-gw-contracts == 'true' }}
permissions:
contents: 'read' # Required to checkout repository code
checks: 'write' # Required to create GitHub checks for test results
packages: 'read' # Required to read GitHub packages/container registry
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: 'false'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
- name: Login to Docker Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and start Docker services
working-directory: gateway-contracts
run: |
make docker-compose-build
make docker-compose-up
- name: Check smart contract deployment
working-directory: gateway-contracts
run: |
## Check Contracts Deployment
timeout 300s bash -c 'while docker ps --filter "name=deploy-gateway-contracts" --format "{{.Status}}" | grep -q "Up"; do sleep 5; done'
docker compose logs deploy-gateway-contracts > deployment_logs.txt
EXIT_CODE_SC=$(docker inspect --format='{{.State.ExitCode}}' deploy-gateway-contracts)
# display logs for debugging
# cat deployment_logs.txt
if [ "$EXIT_CODE_SC" -ne 0 ]; then
echo "Deployment failed with exit code $EXIT_CODE_SC"
exit 1
elif ! grep -q "Contract deployment done!" deployment_logs.txt; then
echo "Deployment did not complete successfully - 'Contract deployment done!' message not found in logs"
exit 1
else
echo "Deployment completed successfully with expected completion message"
fi
## Check Host Chain Registration
timeout 300s bash -c 'while docker ps --filter "name=add-host-chains" --format "{{.Status}}" | grep -q "Up"; do sleep 5; done'
docker compose logs add-host-chains > host_chain_registration_logs.txt
EXIT_CODE_HOST_CHAIN=$(docker inspect --format='{{.State.ExitCode}}' add-host-chains)
# display logs for debugging
# cat host_chain_registration_logs.txt
if [ "$EXIT_CODE_HOST_CHAIN" -ne 0 ]; then
echo "Host chain registration failed with exit code $EXIT_CODE_HOST_CHAIN"
exit 1
elif ! grep -q "Host chains registration done!" host_chain_registration_logs.txt; then
echo "Host chain registration did not complete successfully - 'Host chains registration done!' message not found in logs"
exit 1
else
echo "Host chain registration completed successfully with expected completion message"
fi
## Check key generation triggering
timeout 300s bash -c 'while docker ps --filter "name=trigger-keygen" --format "{{.Status}}" | grep -q "Up"; do sleep 5; done'
docker compose logs trigger-keygen > keygen_logs.txt
EXIT_CODE_KEYGEN=$(docker inspect --format='{{.State.ExitCode}}' trigger-keygen)
if [ "$EXIT_CODE_KEYGEN" -ne 0 ]; then
echo "Key generation triggering failed with exit code $EXIT_CODE_KEYGEN"
exit 1
elif ! grep -q "Keygen triggering done!" keygen_logs.txt; then
echo "Key generation triggering did not complete successfully - 'Keygen triggering done!' message not found in logs"
exit 1
else
echo "Key generation triggering completed successfully with expected completion message"
fi
## Check CRS generation triggering
timeout 300s bash -c 'while docker ps --filter "name=trigger-crsgen" --format "{{.Status}}" | grep -q "Up"; do sleep 5; done'
docker compose logs trigger-crsgen > crsgen_logs.txt
EXIT_CODE_CRSGEN=$(docker inspect --format='{{.State.ExitCode}}' trigger-crsgen)
if [ "$EXIT_CODE_CRSGEN" -ne 0 ]; then
echo "CRS generation triggering failed with exit code $EXIT_CODE_CRSGEN"
exit 1
elif ! grep -q "Crsgen triggering done!" crsgen_logs.txt; then
echo "CRS generation triggering did not complete successfully - 'Crsgen triggering done!' message not found in logs"
exit 1
else
echo "CRS generation triggering completed successfully with expected completion message"
fi
- name: Check mock smart contract deployment
working-directory: gateway-contracts
run: |
## Check Mock contracts deployment
timeout 300s bash -c 'while docker ps --filter "name=deploy-gateway-mock-contracts" --format "{{.Status}}" | grep -q "Up"; do sleep 5; done'
docker compose logs deploy-gateway-mock-contracts > mock_contracts_deployment_logs.txt
EXIT_CODE_SC=$(docker inspect --format='{{.State.ExitCode}}' deploy-gateway-mock-contracts)
# display logs for debugging
# cat mock_contracts_deployment_logs.txt
if [ "$EXIT_CODE_SC" -ne 0 ]; then
echo "Mock contract deployment failed with exit code $EXIT_CODE_SC"
exit 1
elif ! grep -q "Mock contract deployment done!" mock_contracts_deployment_logs.txt; then
echo "Mock contract deployment did not complete successfully - 'Mock contract deployment done!' message not found in logs"
exit 1
else
echo "Mock contract deployment completed successfully with expected completion message"
fi
- name: Clean up
working-directory: gateway-contracts
if: always()
run: |
make docker-compose-down