build.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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: "22"
  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: "22"
  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: "22"
  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. CHAIN_ID: 1
  98. steps:
  99. - uses: actions/checkout@v3
  100. - name: Get rust toolchain version
  101. id: toolchain
  102. run: |
  103. RUST_VERSION="$(awk '/channel =/ { print substr($3, 2, length($3)-2) }' solana/rust-toolchain)"
  104. echo "::set-output name=version::${RUST_VERSION}"
  105. - name: Get solana version
  106. id: solana
  107. run: |
  108. SOLANA_VERSION="$(awk '/solana-program =/ { print substr($3, 3, length($3)-3) }' solana/bridge/program/Cargo.toml)"
  109. echo "::set-output name=version::${SOLANA_VERSION}"
  110. - name: Cache rust toolchain
  111. uses: actions/cache@v3
  112. env:
  113. cache-name: solana-toolchain
  114. with:
  115. path: |
  116. ~/.cargo/bin
  117. ~/.rustup
  118. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.toolchain.outputs.version }}
  119. restore-keys: |
  120. ${{ runner.os }}-build-${{ env.cache-name }}-
  121. ${{ runner.os }}-build-
  122. ${{ runner.os }}-
  123. - name: Install rust toolchain
  124. uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb
  125. with:
  126. toolchain: ${{ steps.toolchain.outputs.version }}
  127. components: "clippy,rustfmt"
  128. - name: Cache rust packages / build cache
  129. uses: actions/cache@v3
  130. env:
  131. cache-name: solana-rust-packages
  132. with:
  133. path: |
  134. ~/.cargo/bin
  135. ~/.cargo/registry
  136. ~/.cargo/git/db
  137. solana/target
  138. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('solana/Cargo.lock') }}
  139. restore-keys: |
  140. ${{ runner.os }}-build-${{ env.cache-name }}-
  141. ${{ runner.os }}-build-
  142. ${{ runner.os }}-
  143. - name: Run `cargo fmt`
  144. run: cargo fmt --check --all --manifest-path solana/Cargo.toml
  145. - name: Run `cargo check`
  146. run: cargo check --workspace --tests --manifest-path solana/Cargo.toml
  147. --features "nft-bridge/instructions token-bridge/instructions wormhole-bridge-solana/instructions"
  148. - name: Run `cargo clippy`
  149. run: cargo clippy --workspace --tests --manifest-path solana/Cargo.toml
  150. --features "nft-bridge/instructions token-bridge/instructions wormhole-bridge-solana/instructions"
  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 external/mpl_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. shell: bash
  170. aptos:
  171. name: Aptos
  172. runs-on: ubuntu-24.04
  173. defaults:
  174. run:
  175. shell: bash
  176. working-directory: ./aptos
  177. steps:
  178. - name: Checkout repository
  179. uses: actions/checkout@v2
  180. - name: Run tests via docker
  181. run: make test-docker
  182. sui:
  183. name: Sui
  184. runs-on: ubuntu-24.04
  185. steps:
  186. - name: Checkout repository
  187. uses: actions/checkout@v2
  188. - name: Run tests via docker
  189. run: cd sui && make test-docker
  190. # NOTE: While Terra2 is deprecated, this job may be related to testing CosmWasm functionality in Wormchain.
  191. terra-2:
  192. runs-on: ubuntu-24.04
  193. steps:
  194. - uses: actions/checkout@v2
  195. - uses: actions/setup-node@v2
  196. with:
  197. node-version: "22"
  198. - run: cd cosmwasm/deployment/terra2 && make test
  199. cosmwasm:
  200. runs-on: ubuntu-24.04
  201. steps:
  202. - uses: actions/checkout@v2
  203. - uses: actions/setup-node@v2
  204. with:
  205. node-version: "22"
  206. - run: cd cosmwasm && make test
  207. cli:
  208. runs-on: ubuntu-24.04
  209. steps:
  210. - uses: actions/checkout@v2
  211. - uses: actions/setup-node@v2
  212. with:
  213. node-version: "22"
  214. - run: |
  215. cd clients/js && make test
  216. make docs
  217. 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)
  218. # Verify wormhole chain unit tests
  219. wormchain:
  220. runs-on: ubuntu-24.04
  221. steps:
  222. - uses: actions/checkout@v2
  223. - uses: actions/setup-go@v2
  224. with:
  225. go-version: "1.19.9"
  226. - run: |
  227. cd wormchain
  228. make proto -B
  229. 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)
  230. make test
  231. # Verify go sdk unit/fuzz tests
  232. sdk_vaa:
  233. runs-on: ubuntu-24.04
  234. steps:
  235. - uses: actions/checkout@v2
  236. - uses: actions/setup-go@v2
  237. with:
  238. go-version: "1.23.3"
  239. - run: cd sdk/vaa && go test && go test -v -fuzz FuzzCalculateQuorum -run FuzzCalculateQuorum -fuzztime 15s
  240. # Run Go linters
  241. node-lint:
  242. # The linter is slow enough that we want to run it on the self-hosted runner
  243. runs-on: tilt-kube-public
  244. concurrency:
  245. group: ${{ github.workflow }}-lint-${{ github.ref }}
  246. cancel-in-progress: true
  247. steps:
  248. - name: Clear repository
  249. run: |
  250. rm -rf $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE
  251. - uses: actions/checkout@v2
  252. - uses: actions/setup-go@v2
  253. with:
  254. go-version: "1.23.3"
  255. - name: Install formatter
  256. run: go install golang.org/x/tools/cmd/goimports@v0.8.0
  257. - name: Formatting checks
  258. run: ./scripts/lint.sh -l -g format
  259. - name: Install linters
  260. run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.5.0
  261. - name: Run linters
  262. run: make generate && golangci-lint --version && ./scripts/lint.sh -g lint
  263. - name: Ensure generated proto matches
  264. run: |
  265. rm -rf node/pkg/proto
  266. docker build --target go-export -f Dockerfile.proto -o type=local,dest=node .
  267. 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)
  268. spellcheck:
  269. runs-on: ubuntu-latest
  270. steps:
  271. - uses: actions/checkout@v4
  272. # Pinned version of the v6 tag, which is a lightweight and hence mutable tag
  273. - uses: streetsidesoftware/cspell-action@214db1e3138f326d33b7a6a51c92852e89ab0618
  274. with:
  275. # For now, only lint markdown files
  276. files: "**/*.md"
  277. inline: warning
  278. # Only check files in the PR or push
  279. incremental_files_only: true
  280. # Run Go tests
  281. node-tests:
  282. # The tests are slow enough that we want to run it on the self-hosted runner
  283. runs-on: tilt-kube-public
  284. concurrency:
  285. group: ${{ github.workflow }}-test-${{ github.ref }}
  286. cancel-in-progress: true
  287. steps:
  288. - name: Clear repository
  289. run: |
  290. rm -rf $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE
  291. - uses: actions/checkout@v2
  292. - uses: actions/setup-go@v2
  293. with:
  294. go-version: "1.23.3"
  295. # The go-ethereum and celo-blockchain packages both implement secp256k1 using the exact same header, but that causes duplicate symbols.
  296. - name: Run golang tests
  297. run: cd node && go test -v -timeout 5m -race ./...
  298. # Run Rust lints and tests
  299. rust-lint-and-tests:
  300. runs-on: ubuntu-24.04
  301. env:
  302. # Deny all warnings. Since we also build with stable, this causes newly-added clippy lints to fail when new Rust
  303. # versions are released. This means that the CI runs will occasionally fail as new warnings are flagged in the
  304. # codebase, but it's a good way to force us to keep the codebase in good shape.
  305. RUSTFLAGS: -Dwarnings
  306. strategy:
  307. matrix:
  308. manifest:
  309. # NOTE: The `test_args` flag is used to forward job-specific flags to Rust tests while allowing us to use the matrix strategy for configuring jobs.
  310. # CosmWasm
  311. - path: cosmwasm/Cargo.toml
  312. args: "--workspace --locked --exclude 'shutdown-*'"
  313. test_args: ""
  314. - path: cosmwasm/Cargo.toml
  315. args: "-p 'shutdown-*' --no-default-features --locked"
  316. test_args: ""
  317. # Rust SDK
  318. - path: sdk/rust/Cargo.toml
  319. args: "--all-features --all-targets"
  320. test_args: ""
  321. # SVM directory (shims code)
  322. - path: svm/wormhole-core-shims/Cargo.toml
  323. args: "--workspace --no-default-features --features solana" # The crate by default requires environment variables. If solana is specified, mainnet values are used.
  324. test_args: "--lib" # Skip integration tests; they require compiled BPF programs
  325. - path: svm/wormhole-core-shims/anchor/Cargo.toml
  326. args: "--workspace"
  327. test_args: "--lib" # Skip doctests; anchor interfaces lack solana_program dependency
  328. name: rust-lint-and-tests (${{ matrix.manifest.path }})
  329. steps:
  330. - name: Check out source
  331. uses: actions/checkout@v3
  332. - name: Get rust toolchain version
  333. id: toolchain
  334. env:
  335. MANIFEST: ${{ matrix.manifest.path }}
  336. run: |
  337. WORKSPACE_DIR="$(dirname "${MANIFEST}")"
  338. if [ -f "${WORKSPACE_DIR}/rust-toolchain.toml" ]; then
  339. # Extract the Rust version from rust-toolchain.toml
  340. # Searches for lines matching 'channel =' and extracts the quoted version string
  341. # Example: 'channel = "1.83.0"' -> extracts "1.83.0" by:
  342. # $3 = third field ("1.83.0")
  343. # substr($3, 2, length($3)-2) = strips first and last character (the quotes)
  344. RUST_VERSION="$(awk '/channel =/ { print substr($3, 2, length($3)-2) }' "${WORKSPACE_DIR}/rust-toolchain.toml")"
  345. else
  346. RUST_VERSION="stable"
  347. fi
  348. echo "::set-output name=version::${RUST_VERSION}"
  349. - name: Install rust toolchain
  350. uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb
  351. with:
  352. toolchain: ${{ steps.toolchain.outputs.version }}
  353. components: "clippy,rustfmt"
  354. - name: Create cache key
  355. id: cachekey
  356. env:
  357. MANIFEST: ${{ matrix.manifest.path }}
  358. run: |
  359. LOCKFILE="$(dirname "${MANIFEST}")/Cargo.lock"
  360. NAME="${MANIFEST%%/*}"
  361. HASH="$(sha256sum "${LOCKFILE}" | awk '{ print $1 }')"
  362. echo "::set-output name=name::${NAME}"
  363. echo "::set-output name=hash::${HASH}"
  364. - name: Cache rust packages
  365. uses: actions/cache@v3
  366. with:
  367. path: ~/.cargo/registry
  368. key: ${{ runner.os }}-build-${{ steps.cachekey.outputs.name }}-${{ steps.cachekey.outputs.hash }}
  369. restore-keys: |
  370. ${{ runner.os }}-build-${{ matrix.manifest.path }}-
  371. - name: Run `rustfmt`
  372. run: cd $(dirname ${{ matrix.manifest.path }}) && cargo fmt --check
  373. - name: Run `cargo clippy`
  374. run: cargo clippy ${{ matrix.manifest.args }} --tests --manifest-path ${{ matrix.manifest.path }}
  375. - name: Run unit tests
  376. run: cargo test ${{ matrix.manifest.args }} ${{ matrix.manifest.test_args }} --manifest-path ${{ matrix.manifest.path }}
  377. docker:
  378. runs-on: ubuntu-latest
  379. steps:
  380. - name: Check out source
  381. uses: actions/checkout@v2
  382. - run: chmod 755 ./scripts/check-docker-pin.sh
  383. - run: ./scripts/check-docker-pin.sh
  384. npm-packages:
  385. runs-on: ubuntu-latest
  386. steps:
  387. - name: Check out source
  388. uses: actions/checkout@v2
  389. - run: chmod 755 ./scripts/check-npm-package-scopes.sh
  390. - run: ./scripts/check-npm-package-scopes.sh
  391. prettier:
  392. runs-on: ubuntu-latest
  393. steps:
  394. - uses: actions/checkout@v3
  395. - uses: actions/setup-node@v3
  396. with:
  397. node-version: "22"
  398. - run: npx prettier@2.3.2 --check ./clients/js/src ./sdk/js/src