build.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. name: Build
  2. on:
  3. workflow_dispatch:
  4. pull_request:
  5. push:
  6. branches:
  7. - main
  8. jobs:
  9. # Run the full Tilt build and wait for it to converge
  10. tilt:
  11. # in the future, we may want to run cheap lints, tests, and builds before firing up the expensive tilt test.
  12. # But for now, we'll kick-off everything at once
  13. # needs: [go-lint-and-tests, node, algorand, ethereum, terra, rust-lint-and-tests]
  14. runs-on: tilt-kube-public
  15. # Cancel previous builds on the same branch/ref. Full runs are expensive
  16. # and capacity is limited, so we want to avoid running multiple builds
  17. # in parallel even if it means skipping CI runs on permanent branches
  18. # (unfortunately, we can't differentiate between temporary and permanent
  19. # refs without duplicating the entire logic).
  20. concurrency:
  21. group: ${{ github.workflow }}-tilt-${{ github.ref }}
  22. cancel-in-progress: true
  23. steps:
  24. - name: Clear repository
  25. run: |
  26. rm -rf $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE
  27. - uses: actions/checkout@v2
  28. - name: Expand for link to Tilt dashboard (only available during build)
  29. run: >
  30. echo "Tilt progress dashboard: https://$DASHBOARD_URL"
  31. - run: |
  32. kubectl config set-context ci --namespace=$DEPLOY_NS
  33. kubectl config use-context ci
  34. - run: tilt ci -- --ci --namespace=$DEPLOY_NS --num=2
  35. timeout-minutes: 20
  36. # Clean up k8s resources
  37. - run: kubectl delete --namespace=$DEPLOY_NS service,statefulset,configmap,pod,job --all
  38. if: always()
  39. # Verify whether the Makefile builds the node (no dependencies other than Go)
  40. node:
  41. runs-on: ubuntu-20.04
  42. steps:
  43. - uses: actions/checkout@v2
  44. - uses: actions/setup-go@v2
  45. with:
  46. go-version: "1.20.4"
  47. - run: make node
  48. algorand:
  49. runs-on: ubuntu-20.04
  50. steps:
  51. - uses: actions/checkout@v3
  52. - uses: actions/setup-python@v3
  53. with:
  54. python-version: "3.10"
  55. - run: pip install -r algorand/requirements.txt
  56. - run: cd algorand && make test
  57. ethereum:
  58. runs-on: ubuntu-20.04
  59. steps:
  60. - uses: actions/checkout@v2
  61. - uses: actions/setup-node@v2
  62. with:
  63. node-version: "16"
  64. - run: cd ethereum && ../scripts/install-foundry
  65. - run: cd ethereum && PATH=$PATH:$HOME/.foundry/bin/ make test
  66. ethereum-upgrade:
  67. runs-on: ubuntu-20.04
  68. steps:
  69. - uses: actions/checkout@v2
  70. - uses: actions/setup-node@v2
  71. with:
  72. node-version: "16"
  73. - run: cd clients/js && make install
  74. - run: cd ethereum && make test-upgrade
  75. solana:
  76. runs-on: ubuntu-20.04
  77. env:
  78. RUSTFLAGS: -Dwarnings
  79. EMITTER_ADDRESS: CiByUvEcx7w2HA4VHcPCBUAFQ73Won9kB36zW9VjirSr
  80. BRIDGE_ADDRESS: Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o
  81. steps:
  82. - uses: actions/checkout@v3
  83. - name: Get rust toolchain version
  84. id: toolchain
  85. run: |
  86. RUST_VERSION="$(awk '/channel =/ { print substr($3, 2, length($3)-2) }' solana/rust-toolchain)"
  87. echo "::set-output name=version::${RUST_VERSION}"
  88. - name: Get solana version
  89. id: solana
  90. run: |
  91. SOLANA_VERSION="$(awk '/solana-program =/ { print substr($3, 3, length($3)-3) }' solana/bridge/program/Cargo.toml)"
  92. echo "::set-output name=version::${SOLANA_VERSION}"
  93. - name: Cache rust toolchain
  94. uses: actions/cache@v3
  95. env:
  96. cache-name: solana-toolchain
  97. with:
  98. path: |
  99. ~/.cargo/bin
  100. ~/.rustup
  101. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.toolchain.outputs.version }}
  102. restore-keys: |
  103. ${{ runner.os }}-build-${{ env.cache-name }}-
  104. ${{ runner.os }}-build-
  105. ${{ runner.os }}-
  106. - name: Install rust toolchain
  107. uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb
  108. with:
  109. toolchain: ${{ steps.toolchain.outputs.version }}
  110. components: "clippy,rustfmt"
  111. - name: Cache rust packages / build cache
  112. uses: actions/cache@v3
  113. env:
  114. cache-name: solana-rust-packages
  115. with:
  116. path: |
  117. ~/.cargo/bin
  118. ~/.cargo/registry
  119. ~/.cargo/git/db
  120. solana/target
  121. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('solana/Cargo.lock') }}
  122. restore-keys: |
  123. ${{ runner.os }}-build-${{ env.cache-name }}-
  124. ${{ runner.os }}-build-
  125. ${{ runner.os }}-
  126. - name: Run `cargo fmt`
  127. run: cargo fmt --check --all --manifest-path solana/Cargo.toml
  128. - name: Run `cargo check`
  129. run: cargo check --workspace --tests --manifest-path solana/Cargo.toml
  130. --features "nft-bridge/instructions token-bridge/instructions wormhole-bridge-solana/instructions"
  131. - name: Run `cargo clippy`
  132. run: cargo clippy --workspace --tests --manifest-path solana/Cargo.toml
  133. --features "nft-bridge/instructions token-bridge/instructions wormhole-bridge-solana/instructions"
  134. - name: Cache solana tools
  135. id: cache-solana
  136. uses: actions/cache@v3
  137. env:
  138. cache-name: solana-tools
  139. with:
  140. path: |
  141. ~/.local/share/solana/install/
  142. ~/.cache/solana/
  143. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.solana.outputs.version }}
  144. - if: ${{ steps.cache-solana.outputs.cache-hit != 'true' }}
  145. name: Install solana tools
  146. env:
  147. SOLANA_VERSION: ${{ steps.solana.outputs.version }}
  148. run: |
  149. sh -c "$(curl -sSfL https://release.solana.com/v${SOLANA_VERSION}/install)"
  150. ~/.local/share/solana/install/active_release/bin/sdk/bpf/scripts/install.sh
  151. - name: Run unit tests
  152. env:
  153. RUST_BACKTRACE: "1"
  154. run: |
  155. cd solana
  156. export BPF_OUT_DIR="$(pwd)/target/deploy"
  157. export PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}"
  158. mkdir -p "${BPF_OUT_DIR}"
  159. cp modules/token_bridge/token-metadata/spl_token_metadata.so "${BPF_OUT_DIR}"
  160. BPF_PACKAGES=(
  161. bridge/program/Cargo.toml
  162. modules/token_bridge/program/Cargo.toml
  163. modules/nft_bridge/program/Cargo.toml
  164. )
  165. for p in "${BPF_PACKAGES[@]}"; do
  166. cargo build-bpf --manifest-path "${p}"
  167. done
  168. cargo test --workspace --features "nft-bridge/instructions token-bridge/instructions wormhole-bridge-solana/instructions"
  169. aptos:
  170. name: Aptos
  171. runs-on: ubuntu-20.04
  172. defaults:
  173. run:
  174. shell: bash
  175. working-directory: ./aptos
  176. steps:
  177. - name: Checkout repository
  178. uses: actions/checkout@v2
  179. - name: Run tests via docker
  180. run: make test-docker
  181. sui:
  182. name: Sui
  183. runs-on: ubuntu-20.04
  184. steps:
  185. - name: Checkout repository
  186. uses: actions/checkout@v2
  187. - name: Run tests via docker
  188. run: cd sui && make test-docker
  189. terra:
  190. runs-on: ubuntu-20.04
  191. steps:
  192. - uses: actions/checkout@v2
  193. - uses: actions/setup-node@v2
  194. with:
  195. node-version: "16"
  196. - run: cd terra && make test
  197. terra-2:
  198. runs-on: ubuntu-20.04
  199. steps:
  200. - uses: actions/checkout@v2
  201. - uses: actions/setup-node@v2
  202. with:
  203. node-version: "16"
  204. - run: cd cosmwasm/deployment/terra2 && make test
  205. cosmwasm:
  206. runs-on: ubuntu-20.04
  207. steps:
  208. - uses: actions/checkout@v2
  209. - uses: actions/setup-node@v2
  210. with:
  211. node-version: "16"
  212. - run: cd cosmwasm && make test
  213. cli:
  214. runs-on: ubuntu-20.04
  215. steps:
  216. - uses: actions/checkout@v2
  217. - uses: actions/setup-node@v2
  218. with:
  219. node-version: "16"
  220. - run: cd clients/js && make test
  221. # Verify wormhole chain unit tests
  222. wormchain:
  223. runs-on: ubuntu-20.04
  224. steps:
  225. - uses: actions/checkout@v2
  226. - uses: actions/setup-go@v2
  227. with:
  228. go-version: "1.19.9"
  229. - run: |
  230. cd wormchain
  231. make proto -B
  232. git diff --name-only --exit-code && echo "✅ Generated proto matches committed proto" || (echo "❌ Generated proto differs from committed proto, run \`make proto -B\` and commit the result" >&2 && exit 1)
  233. make test
  234. # Verify go sdk unit tests
  235. sdk_vaa:
  236. runs-on: ubuntu-20.04
  237. steps:
  238. - uses: actions/checkout@v2
  239. - uses: actions/setup-go@v2
  240. with:
  241. go-version: "1.20.4"
  242. - run: cd sdk/vaa && go test
  243. # Run Go linters
  244. node-lint:
  245. # The linter is slow enough that we want to run it on the self-hosted runner
  246. runs-on: tilt-kube-public
  247. concurrency:
  248. group: ${{ github.workflow }}-lint-${{ github.ref }}
  249. cancel-in-progress: true
  250. steps:
  251. - name: Clear repository
  252. run: |
  253. rm -rf $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE
  254. - uses: actions/checkout@v2
  255. - uses: actions/setup-go@v2
  256. with:
  257. go-version: "1.20.4"
  258. - name: Install formatter
  259. run: go install golang.org/x/tools/cmd/goimports@v0.8.0
  260. - name: Formatting checks
  261. run: ./scripts/lint.sh -l -g format
  262. - name: Install linters
  263. run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.2
  264. - name: Run linters
  265. run: make generate && ./scripts/lint.sh -g lint
  266. - name: Ensure generated proto matches
  267. run: |
  268. rm -rf node/pkg/proto
  269. docker build --target go-export -f Dockerfile.proto -o type=local,dest=node .
  270. git diff --name-only --exit-code && echo "✅ Generated proto matches committed proto" || (echo "❌ Generated proto differs from committed proto, run \`rm -rf node/pkg/proto && docker build --target go-export -f Dockerfile.proto -o type=local,dest=node .\` and commit the result" >&2 && exit 1)
  271. # Run Go tests
  272. node-tests:
  273. # The tests are slow enough that we want to run it on the self-hosted runner
  274. runs-on: tilt-kube-public
  275. concurrency:
  276. group: ${{ github.workflow }}-test-${{ github.ref }}
  277. cancel-in-progress: true
  278. steps:
  279. - name: Clear repository
  280. run: |
  281. rm -rf $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE
  282. - uses: actions/checkout@v2
  283. - uses: actions/setup-go@v2
  284. with:
  285. go-version: "1.20.4"
  286. # The go-ethereum and celo-blockchain packages both implement secp256k1 using the exact same header, but that causes duplicate symbols.
  287. - name: Run golang tests
  288. run: cd node && go test -v -race -ldflags '-extldflags "-Wl,--allow-multiple-definition" ' ./...
  289. # Run Rust lints and tests
  290. rust-lint-and-tests:
  291. runs-on: ubuntu-20.04
  292. env:
  293. RUSTFLAGS: -Dwarnings
  294. strategy:
  295. matrix:
  296. manifest:
  297. - cosmwasm/Cargo.toml
  298. - terra/Cargo.toml
  299. - sdk/rust/Cargo.toml
  300. steps:
  301. - name: Check out source
  302. uses: actions/checkout@v3
  303. - name: Install rust toolchain
  304. uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb
  305. with:
  306. toolchain: stable
  307. components: "clippy,rustfmt"
  308. - name: Create cache key
  309. id: cachekey
  310. env:
  311. MANIFEST: ${{ matrix.manifest }}
  312. run: |
  313. LOCKFILE="$(dirname "${MANIFEST}")/Cargo.lock"
  314. NAME="${MANIFEST%%/*}"
  315. HASH="$(sha256sum "${LOCKFILE}" | awk '{ print $1 }')"
  316. echo "::set-output name=name::${NAME}"
  317. echo "::set-output name=hash::${HASH}"
  318. - name: Cache rust packages
  319. uses: actions/cache@v3
  320. with:
  321. path: ~/.cargo/registry
  322. key: ${{ runner.os }}-build-${{ steps.cachekey.outputs.name }}-${{ steps.cachekey.outputs.hash }}
  323. restore-keys: |
  324. ${{ runner.os }}-build-${{ matrix.manifest }}-
  325. - name: Run `rustfmt`
  326. env:
  327. MANIFEST: ${{ matrix.manifest }}
  328. # In its infinite wisdom, `cargo fmt --all` will also format path-based dependencies so
  329. # instead we have to manually format each ".rs" file.
  330. run: find "$(dirname "${MANIFEST}")" -name '*.rs' -exec rustfmt --check {} +
  331. - name: Run `cargo clippy`
  332. run: cargo clippy --workspace --tests --locked --manifest-path ${{ matrix.manifest }}
  333. - name: Run unit tests
  334. run: cargo test --workspace --locked --manifest-path ${{ matrix.manifest }}
  335. docker:
  336. runs-on: ubuntu-latest
  337. steps:
  338. - name: Check out source
  339. uses: actions/checkout@v2
  340. - run: chmod 755 ./scripts/check-docker-pin.sh
  341. - run: ./scripts/check-docker-pin.sh
  342. npm-packages:
  343. runs-on: ubuntu-latest
  344. steps:
  345. - name: Check out source
  346. uses: actions/checkout@v2
  347. - run: chmod 755 ./scripts/check-npm-package-scopes.sh
  348. - run: ./scripts/check-npm-package-scopes.sh