build.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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: 60
  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.19.3"
  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. terra:
  182. runs-on: ubuntu-20.04
  183. steps:
  184. - uses: actions/checkout@v2
  185. - uses: actions/setup-node@v2
  186. with:
  187. node-version: "16"
  188. - run: cd terra && make test
  189. terra-2:
  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 cosmwasm/deployment/terra2 && make test
  197. cosmwasm:
  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 && make test
  205. cli:
  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 clients/js && make test
  213. # Verify wormhole chain unit tests
  214. wormchain:
  215. runs-on: ubuntu-20.04
  216. steps:
  217. - uses: actions/checkout@v2
  218. - uses: actions/setup-go@v2
  219. with:
  220. go-version: "1.19.3"
  221. - run: |
  222. cd wormchain
  223. make proto -B
  224. 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)
  225. make test
  226. # Verify go sdk unit tests
  227. sdk_vaa:
  228. runs-on: ubuntu-20.04
  229. steps:
  230. - uses: actions/checkout@v2
  231. - uses: actions/setup-go@v2
  232. with:
  233. go-version: "1.19.3"
  234. - run: cd sdk/vaa && go test
  235. # Run Go linters, Go tests and other outside-of-Tilt things.
  236. lint-and-tests:
  237. # The linter is slow enough that we want to run it on the self-hosted runner
  238. runs-on: tilt-kube-public
  239. concurrency:
  240. group: ${{ github.workflow }}-lint-${{ github.ref }}
  241. cancel-in-progress: true
  242. steps:
  243. - name: Clear repository
  244. run: |
  245. rm -rf $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE
  246. - uses: actions/checkout@v2
  247. - uses: actions/setup-go@v2
  248. with:
  249. go-version: "1.19.3"
  250. - name: Install formatter
  251. run: go install golang.org/x/tools/cmd/goimports@latest
  252. - name: Formatting checks
  253. run: ./scripts/lint.sh -l -g format
  254. - name: Install linters
  255. run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2
  256. - name: Run linters
  257. run: make generate && ./scripts/lint.sh -g lint
  258. # The go-ethereum and celo-blockchain packages both implement secp256k1 using the exact same header, but that causes duplicate symbols.
  259. - name: Run golang tests
  260. run: cd node && go test -v -race -ldflags '-extldflags "-Wl,--allow-multiple-definition" ' ./...
  261. - name: Ensure generated proto matches
  262. run: |
  263. rm -rf node/pkg/proto
  264. docker build --target go-export -f Dockerfile.proto -o type=local,dest=node .
  265. 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)
  266. # Run Rust lints and tests
  267. rust-lint-and-tests:
  268. runs-on: ubuntu-20.04
  269. env:
  270. RUSTFLAGS: -Dwarnings
  271. strategy:
  272. matrix:
  273. manifest:
  274. - cosmwasm/Cargo.toml
  275. - terra/Cargo.toml
  276. - sdk/rust/Cargo.toml
  277. steps:
  278. - name: Check out source
  279. uses: actions/checkout@v3
  280. - name: Install rust toolchain
  281. uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb
  282. with:
  283. toolchain: stable
  284. components: "clippy,rustfmt"
  285. - name: Create cache key
  286. id: cachekey
  287. env:
  288. MANIFEST: ${{ matrix.manifest }}
  289. run: |
  290. LOCKFILE="$(dirname "${MANIFEST}")/Cargo.lock"
  291. NAME="${MANIFEST%%/*}"
  292. HASH="$(sha256sum "${LOCKFILE}" | awk '{ print $1 }')"
  293. echo "::set-output name=name::${NAME}"
  294. echo "::set-output name=hash::${HASH}"
  295. - name: Cache rust packages
  296. uses: actions/cache@v3
  297. with:
  298. path: ~/.cargo/registry
  299. key: ${{ runner.os }}-build-${{ steps.cachekey.outputs.name }}-${{ steps.cachekey.outputs.hash }}
  300. restore-keys: |
  301. ${{ runner.os }}-build-${{ matrix.manifest }}-
  302. - name: Run `rustfmt`
  303. env:
  304. MANIFEST: ${{ matrix.manifest }}
  305. # In its infinite wisdom, `cargo fmt --all` will also format path-based dependencies so
  306. # instead we have to manually format each ".rs" file.
  307. run: find "$(dirname "${MANIFEST}")" -name '*.rs' -exec rustfmt --check {} +
  308. - name: Run `cargo clippy`
  309. run: cargo clippy --workspace --tests --locked --manifest-path ${{ matrix.manifest }}
  310. - name: Run unit tests
  311. run: cargo test --workspace --locked --manifest-path ${{ matrix.manifest }}
  312. docker:
  313. runs-on: ubuntu-latest
  314. steps:
  315. - name: Check out source
  316. uses: actions/checkout@v2
  317. - run: chmod 755 ./scripts/check-docker-pin.sh
  318. - run: ./scripts/check-docker-pin.sh
  319. npm-packages:
  320. runs-on: ubuntu-latest
  321. steps:
  322. - name: Check out source
  323. uses: actions/checkout@v2
  324. - run: chmod 755 ./scripts/check-npm-package-scopes.sh
  325. - run: ./scripts/check-npm-package-scopes.sh