-
Notifications
You must be signed in to change notification settings - Fork 3
173 lines (148 loc) · 4.53 KB
/
CI.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
166
167
168
169
170
171
172
173
name: Continuous Integration
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "TNLS-Relayers/**"
- "TNLS-Gateways/public-gateway/**"
- "TNLS-Gateways/secret/**"
- ".github/workflows/ci.yml"
pull_request:
branches:
- main
paths:
- "TNLS-Relayers/**"
- "TNLS-Gateways/public-gateway/**"
- "TNLS-Gateways/secret/**"
- ".github/workflows/ci.yml"
jobs:
foundry_tests:
name: Foundry Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install forge dependencies
working-directory: TNLS-Gateways/public-gateway
run: forge install
- name: Run tests
working-directory: TNLS-Gateways/public-gateway
run: forge test -vvv
- name: Check gas snapshots
working-directory: TNLS-Gateways/public-gateway
run: forge snapshot --check --tolerance 1
secret_unit_tests:
name: Secret Gateway Unit Tests
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
env:
CARGO_TERM_COLOR: always
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- uses: mozilla-actions/[email protected]
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Run Unit Tests
working-directory: TNLS-Gateways/secret
run: cargo test --release
secret_integration_tests:
name: Secret Gateway Integration Tests
runs-on: ubuntu-latest
needs: secret_unit_tests
services:
secret:
image: ghcr.io/scrtlabs/localsecret:v1.13.3
ports:
- 1317:1317
- 5000:5000
- 9091:9091
- 26657:26657
env:
CARGO_TERM_COLOR: always
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- uses: mozilla-actions/[email protected]
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: wasm32-unknown-unknown
- name: Install dependencies
working-directory: TNLS-Gateways/secret
run: npm --prefix tests/ install
- name: Install latest Binaryen
run: |
BINARYEN_VERSION=version_118
wget https://github.com/WebAssembly/binaryen/releases/download/${BINARYEN_VERSION}/binaryen-${BINARYEN_VERSION}-x86_64-linux.tar.gz
tar -xzf binaryen-${BINARYEN_VERSION}-x86_64-linux.tar.gz
sudo mv binaryen-${BINARYEN_VERSION} /usr/local/binaryen
echo "/usr/local/binaryen/bin" >> $GITHUB_PATH
- name: Verify installation
run: wasm-opt --version
- name: Build wasm contract
working-directory: TNLS-Gateways/secret
run: make build-mainnet
- name: Run integration tests
working-directory: TNLS-Gateways/secret
run: make integration-test
build_and_push:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs:
- foundry_tests
- secret_integration_tests
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
IMAGE_NAME: secretpath
IMAGE_TAG: latest
DOCKER_BUILDKIT: 1
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Docker Image
working-directory: TNLS-Relayers
run: |
docker compose build --pull
docker compose push