build.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. name: Build
  2. on:
  3. workflow_dispatch:
  4. pull_request:
  5. push:
  6. branches:
  7. - main
  8. permissions:
  9. contents: read
  10. jobs:
  11. # Run the full Tilt build and wait for it to converge
  12. tilt:
  13. # in the future, we may want to run cheap lints, tests, and builds before firing up the expensive tilt test.
  14. # But for now, we'll kick-off everything at once
  15. # needs: [go-lint-and-tests, node, algorand, ethereum, terra, rust-lint-and-tests]
  16. runs-on: tilt-kube-public
  17. # Cancel previous builds on the same branch/ref. Full runs are expensive
  18. # and capacity is limited, so we want to avoid running multiple builds
  19. # in parallel even if it means skipping CI runs on permanent branches
  20. # (unfortunately, we can't differentiate between temporary and permanent
  21. # refs without duplicating the entire logic).
  22. concurrency:
  23. group: ${{ github.workflow }}-tilt-${{ github.ref }}
  24. cancel-in-progress: true
  25. steps:
  26. - name: Clear repository
  27. run: |
  28. rm -rf $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE
  29. - uses: actions/checkout@v2
  30. - name: Expand for link to Tilt dashboard (only available during build)
  31. run: >
  32. echo "Tilt progress dashboard: https://$DASHBOARD_URL"
  33. - run: |
  34. kubectl config set-context ci --namespace=$DEPLOY_NS
  35. kubectl config use-context ci
  36. - run: tilt ci --timeout 45m0s -- --ci --namespace=$DEPLOY_NS --num=2
  37. timeout-minutes: 60
  38. # Clean up k8s resources
  39. - run: kubectl delete --namespace=$DEPLOY_NS service,statefulset,configmap,pod,job --all
  40. if: always()
  41. # Verify whether the Makefile builds the node (no dependencies other than Go)
  42. node:
  43. runs-on: ubuntu-24.04
  44. steps:
  45. - uses: actions/checkout@v2
  46. - uses: actions/setup-go@v2
  47. with:
  48. go-version: "1.23.3"
  49. - run: make node
  50. algorand:
  51. runs-on: ubuntu-24.04
  52. steps:
  53. - uses: actions/checkout@v3
  54. - uses: actions/setup-python@v3
  55. with:
  56. python-version: "3.10"
  57. - run: pip install -r algorand/requirements.txt
  58. - run: cd algorand && make test
  59. ethereum:
  60. runs-on: ubuntu-latest
  61. steps:
  62. - uses: actions/checkout@v2
  63. - uses: actions/setup-node@v2
  64. with:
  65. node-version: "16"
  66. - name: Install Foundry
  67. uses: foundry-rs/foundry-toolchain@v1
  68. - run: cd ethereum && make test-push0 && make test
  69. relayer-ethereum:
  70. runs-on: ubuntu-latest
  71. steps:
  72. - uses: actions/checkout@v2
  73. - uses: actions/setup-node@v2
  74. with:
  75. node-version: "16"
  76. - name: Install Foundry
  77. uses: foundry-rs/foundry-toolchain@v1
  78. - run: cd relayer/ethereum && make test-push0 && make test
  79. ethereum-upgrade:
  80. runs-on: ubuntu-latest
  81. steps:
  82. - uses: actions/checkout@v2
  83. - uses: actions/setup-node@v2
  84. with:
  85. node-version: "16"
  86. - name: Install Foundry
  87. uses: foundry-rs/foundry-toolchain@v1
  88. - run: cd clients/js && make install
  89. - run: cd ethereum && make test-upgrade
  90. solana:
  91. runs-on: ubuntu-24.04
  92. container: ghcr.io/wormhole-foundation/solana:1.10.31@sha256:d31e8db926a1d3fbaa9d9211d9979023692614b7b64912651aba0383e8c01bad
  93. env:
  94. RUSTFLAGS: -Dwarnings
  95. EMITTER_ADDRESS: CiByUvEcx7w2HA4VHcPCBUAFQ73Won9kB36zW9VjirSr
  96. BRIDGE_ADDRESS: Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o
  97. steps:
  98. - uses: actions/checkout@v3
  99. - name: Get rust toolchain version
  100. id: toolchain
  101. run: |
  102. RUST_VERSION="$(awk '/channel =/ { print substr($3, 2, length($3)-2) }' solana/rust-toolchain)"
  103. echo "::set-output name=version::${RUST_VERSION}"
  104. - name: Get solana version
  105. id: solana
  106. run: |
  107. SOLANA_VERSION="$(awk '/solana-program =/ { print substr($3, 3, length($3)-3) }' solana/bridge/program/Cargo.toml)"
  108. echo "::set-output name=version::${SOLANA_VERSION}"
  109. - name: Cache rust toolchain
  110. uses: actions/cache@v3
  111. env:
  112. cache-name: solana-toolchain
  113. with:
  114. path: |
  115. ~/.cargo/bin
  116. ~/.rustup
  117. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.toolchain.outputs.version }}
  118. restore-keys: |
  119. ${{ runner.os }}-build-${{ env.cache-name }}-
  120. ${{ runner.os }}-build-
  121. ${{ runner.os }}-
  122. - name: Install rust toolchain
  123. uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb
  124. with:
  125. toolchain: ${{ steps.toolchain.outputs.version }}
  126. components: "clippy,rustfmt"
  127. - name: Cache rust packages / build cache
  128. uses: actions/cache@v3
  129. env:
  130. cache-name: solana-rust-packages
  131. with:
  132. path: |
  133. ~/.cargo/bin
  134. ~/.cargo/registry
  135. ~/.cargo/git/db
  136. solana/target
  137. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('solana/Cargo.lock') }}
  138. restore-keys: |
  139. ${{ runner.os }}-build-${{ env.cache-name }}-
  140. ${{ runner.os }}-build-
  141. ${{ runner.os }}-
  142. - name: Run `cargo fmt`
  143. run: cargo fmt --check --all --manifest-path solana/Cargo.toml
  144. - name: Run `cargo check`
  145. run: cargo check --workspace --tests --manifest-path solana/Cargo.toml
  146. --features "nft-bridge/instructions token-bridge/instructions wormhole-bridge-solana/instructions"
  147. - name: Run `cargo clippy`
  148. run: cargo clippy --workspace --tests --manifest-path solana/Cargo.toml
  149. --features "nft-bridge/instructions token-bridge/instructions wormhole-bridge-solana/instructions"
  150. - name: Run unit tests
  151. env:
  152. RUST_BACKTRACE: "1"
  153. run: |
  154. cd solana
  155. export BPF_OUT_DIR="$(pwd)/target/deploy"
  156. export PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}"
  157. mkdir -p "${BPF_OUT_DIR}"
  158. cp external/mpl_token_metadata.so "${BPF_OUT_DIR}"
  159. BPF_PACKAGES=(
  160. bridge/program/Cargo.toml
  161. modules/token_bridge/program/Cargo.toml
  162. modules/nft_bridge/program/Cargo.toml
  163. )
  164. for p in "${BPF_PACKAGES[@]}"; do
  165. cargo build-bpf --manifest-path "${p}"
  166. done
  167. cargo test --workspace --features "nft-bridge/instructions token-bridge/instructions wormhole-bridge-solana/instructions"
  168. shell: bash
  169. aptos:
  170. name: Aptos
  171. runs-on: ubuntu-24.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-24.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-24.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-24.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-24.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-24.04
  215. steps:
  216. - uses: actions/checkout@v2
  217. - uses: actions/setup-node@v2
  218. with:
  219. node-version: "20"
  220. - run: |
  221. cd clients/js && make test
  222. make docs
  223. git diff --name-only --exit-code && echo "✅ Generated CLI docs match committed docs" || (echo "❌ Generated CLI docs differs from committed CLI docs, run \`make docs\` and commit the result" >&2 && exit 1)
  224. # Verify wormhole chain unit tests
  225. wormchain:
  226. runs-on: ubuntu-24.04
  227. steps:
  228. - uses: actions/checkout@v2
  229. - uses: actions/setup-go@v2
  230. with:
  231. go-version: "1.19.9"
  232. - run: |
  233. cd wormchain
  234. make proto -B
  235. 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)
  236. make test
  237. # Verify go sdk unit/fuzz tests
  238. sdk_vaa:
  239. runs-on: ubuntu-24.04
  240. steps:
  241. - uses: actions/checkout@v2
  242. - uses: actions/setup-go@v2
  243. with:
  244. go-version: "1.23.3"
  245. - run: cd sdk/vaa && go test && go test -v -fuzz FuzzCalculateQuorum -run FuzzCalculateQuorum -fuzztime 15s
  246. # Run Go linters
  247. node-lint:
  248. # The linter is slow enough that we want to run it on the self-hosted runner
  249. runs-on: tilt-kube-public
  250. concurrency:
  251. group: ${{ github.workflow }}-lint-${{ github.ref }}
  252. cancel-in-progress: true
  253. steps:
  254. - name: Clear repository
  255. run: |
  256. rm -rf $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE
  257. - uses: actions/checkout@v2
  258. - uses: actions/setup-go@v2
  259. with:
  260. go-version: "1.23.3"
  261. - name: Install formatter
  262. run: go install golang.org/x/tools/cmd/goimports@v0.8.0
  263. - name: Formatting checks
  264. run: ./scripts/lint.sh -l -g format
  265. - name: Install linters
  266. run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.0.2
  267. - name: Run linters
  268. run: make generate && golangci-lint --version && ./scripts/lint.sh -g lint
  269. - name: Ensure generated proto matches
  270. run: |
  271. rm -rf node/pkg/proto
  272. docker build --target go-export -f Dockerfile.proto -o type=local,dest=node .
  273. 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)
  274. spellcheck:
  275. runs-on: ubuntu-latest
  276. steps:
  277. - uses: actions/checkout@v4
  278. # Pinned version of the v6 tag, which is a lightweight and hence mutable tag
  279. - uses: streetsidesoftware/cspell-action@214db1e3138f326d33b7a6a51c92852e89ab0618
  280. with:
  281. # For now, only lint markdown files
  282. files: "**/*.md"
  283. inline: warning
  284. # Only check files in the PR or push
  285. incremental_files_only: true
  286. # Run Go tests
  287. node-tests:
  288. # The tests are slow enough that we want to run it on the self-hosted runner
  289. runs-on: tilt-kube-public
  290. concurrency:
  291. group: ${{ github.workflow }}-test-${{ github.ref }}
  292. cancel-in-progress: true
  293. steps:
  294. - name: Clear repository
  295. run: |
  296. rm -rf $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE
  297. - uses: actions/checkout@v2
  298. - uses: actions/setup-go@v2
  299. with:
  300. go-version: "1.23.3"
  301. # The go-ethereum and celo-blockchain packages both implement secp256k1 using the exact same header, but that causes duplicate symbols.
  302. - name: Run golang tests
  303. run: cd node && go test -v -timeout 5m -race ./...
  304. # Run Rust lints and tests
  305. rust-lint-and-tests:
  306. runs-on: ubuntu-24.04
  307. env:
  308. RUSTFLAGS: -Dwarnings
  309. strategy:
  310. matrix:
  311. manifest:
  312. - path: cosmwasm/Cargo.toml
  313. args: "--workspace --locked --exclude 'shutdown-*'"
  314. - path: cosmwasm/Cargo.toml
  315. args: "-p 'shutdown-*' --no-default-features --locked"
  316. - path: terra/Cargo.toml
  317. args: "--workspace --locked"
  318. - path: sdk/rust/Cargo.toml
  319. args: "--all-features --all-targets"
  320. name: rust-lint-and-tests (${{ matrix.manifest.path }})
  321. steps:
  322. - name: Check out source
  323. uses: actions/checkout@v3
  324. - name: Install rust toolchain
  325. uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb
  326. with:
  327. toolchain: stable
  328. components: "clippy,rustfmt"
  329. - name: Create cache key
  330. id: cachekey
  331. env:
  332. MANIFEST: ${{ matrix.manifest.path }}
  333. run: |
  334. LOCKFILE="$(dirname "${MANIFEST}")/Cargo.lock"
  335. NAME="${MANIFEST%%/*}"
  336. HASH="$(sha256sum "${LOCKFILE}" | awk '{ print $1 }')"
  337. echo "::set-output name=name::${NAME}"
  338. echo "::set-output name=hash::${HASH}"
  339. - name: Cache rust packages
  340. uses: actions/cache@v3
  341. with:
  342. path: ~/.cargo/registry
  343. key: ${{ runner.os }}-build-${{ steps.cachekey.outputs.name }}-${{ steps.cachekey.outputs.hash }}
  344. restore-keys: |
  345. ${{ runner.os }}-build-${{ matrix.manifest.path }}-
  346. - name: Run `rustfmt`
  347. run: cd $(dirname ${{ matrix.manifest.path }}) && cargo fmt --check
  348. - name: Run `cargo clippy`
  349. run: cargo clippy ${{ matrix.manifest.args }} --tests --manifest-path ${{ matrix.manifest.path }}
  350. - name: Run unit tests
  351. run: cargo test ${{ matrix.manifest.args }} --manifest-path ${{ matrix.manifest.path }}
  352. docker:
  353. runs-on: ubuntu-latest
  354. steps:
  355. - name: Check out source
  356. uses: actions/checkout@v2
  357. - run: chmod 755 ./scripts/check-docker-pin.sh
  358. - run: ./scripts/check-docker-pin.sh
  359. npm-packages:
  360. runs-on: ubuntu-latest
  361. steps:
  362. - name: Check out source
  363. uses: actions/checkout@v2
  364. - run: chmod 755 ./scripts/check-npm-package-scopes.sh
  365. - run: ./scripts/check-npm-package-scopes.sh
  366. prettier:
  367. runs-on: ubuntu-latest
  368. steps:
  369. - uses: actions/checkout@v3
  370. - uses: actions/setup-node@v3
  371. with:
  372. node-version: 16
  373. - run: npx prettier@2.3.2 --check ./clients/js/src ./sdk/js/src