Skip to content

fix: example building + add CI step to catch failure of any example code#581

Merged
andrew-ifrita merged 11 commits into
mainfrom
fix/example-build-and-testing
Jun 6, 2025
Merged

fix: example building + add CI step to catch failure of any example code#581
andrew-ifrita merged 11 commits into
mainfrom
fix/example-build-and-testing

Conversation

@andrew-ifrita

@andrew-ifrita andrew-ifrita commented Jun 5, 2025

Copy link
Copy Markdown
Contributor

Changes:

  • Removing separate example build script. It is difficult to build separately with tshy, but we can just use tsx to run the examples
  • Update docs and README around building/running examples
  • add tsx as a dev dep
  • add CI step to make sure every example successfully runs
    • includes a list of exceptions so certain examples can bypass the check if desired
  • update examples so that they
    • immediately fail is connection is unavailable ({ throwOnConnect: true })
    • exit with status code 1 if there was an unexpected failure

Build issues were introduced here: #561

Here is an example of a CI Job failing because of examples failing.

Motivation

I noticed that some examples were not working and that the build script no longer worked. Adding a CI step will help maintain the examples, which in turns help new users get familiar with the codebase and how to use it.

Failing examples

Prior to this MR the many examples were failing. They have been added as exception in run_example.sh under the reason for their failing.

	# PalletNotFound: Pallet xTokens not found in the current runtime.
	["examples/paraToParaTransferMultiAsset.ts"]=1
	["examples/claimAssets.ts"]=1
	["examples/paraToSystemTransferMultiAssets.ts"]=1
	["examples/paraToSystemTransferMultiAsset.ts"]=1
	["examples/paraToParaTransferMultiAssetWithFee.ts"]=1
	["examples/paraToRelayTransferMultiAsset.ts"]=1
	["examples/paraToSystemTransferMultiAssetWithFee.ts"]=1
	# getaddrinfo ENOTFOUND moonriver-rpc.dwellir.com
	["examples/paraToParaTransferMultiAssets.ts"]=1
	["examples/paraToSystemParachainPrimaryNative.ts"]=1
	# getaddrinfo ENOTFOUND paseo-asset-hub-rpc.polkadot.io
	["examples/paseoAssetHubToRelay.ts"]=1
	["examples/paseo/assetHub/bridgeTransfers/assetHubWETHToEthereumSepolia.ts"]=1
	["examples/paseo/assetHub/bridgeTransfers/assetHubPASToWestend.ts"]=1
	["examples/paseo/assetHub/bridgeTransfers/assetHubWNDToWestend.ts"]=1
	["examples/paseo/assetHub/foreignAssetTransfers/reserve/assetHubWETHToHydration.ts"]=1
	["examples/paseo/assetHub/foreignAssetTransfers/reserve/assetHubMUSEToHydration.ts"]=1
	["examples/paseo/assetHub/foreignAssetTransfers/reserve/assetHubMUSEToBifrostRemoteReserve.ts"]=1
	["examples/paseo/assetHub/foreignAssetTransfers/local/assetHubWETHTransfer.ts"]=1
	["examples/paseo/assetHub/paysWithFeeOriginTransfers/pasToHydrationPaysWithMUSE.ts"]=1
	# getaddrinfo ENOTFOUND paseo-rpc.polkadot.io
	["examples/paseo/relayChain/bridgeTransfers/paseoPASToWestendAssetHub.ts"]=1
	# getaddrinfo ENOTFOUND bifrost-polkadot-rpc.dwellir.com
	["examples/fetchFeeInfo.ts"]=1
	["examples/polkadot/parachain/paysWithFeeDest/bifrostToAssetHubPaysWithDOT.ts"]=1
	# InvalidAsset: assetId {"parents":"2","interior":{"X1":{"GlobalConsensus":"Kusama"}}} is not a valid symbol, integer asset id or location for statemint
	["examples/polkadot/assetHub/bridgeTransfers/assetHubKSMToKusama.ts"]=1
	["examples/polkadot/assetHub/foreignAssetTransfers/local/assetHubKSMTransfer.ts"]=1
	# AssetNotFound: (SystemToPara) assetId {"parents":"2","interior":{"X1":{"GlobalConsensus":"Kusama"}}} not found for system parachain statemint
	["examples/polkadot/assetHub/foreignAssetTransfers/reserve/assetHubKSMToMoonbeam.ts"]=1
	# AssetNotFound: (SystemToPara) assetId {"parents":"1","interior":{"X1":{"Parachain":"2011"}}} not found for system parachain statemint
	["examples/polkadot/assetHub/foreignAssetTransfers/teleport/assetHubEQToEquilibrium.ts"]=1
	# InvalidAsset: assetId {"parents":"2","interior":{"X1":{"GlobalConsensus":"Polkadot"}}} is not a valid symbol, integer asset id or location for statemine
	["examples/kusama/assetHub/bridgeTransfers/assetHubDOTToPolkadot.ts"]=1
	# AssetNotFound: (SystemToPara) assetId {"parents":"2","interior":{"X1":{"GlobalConsensus":"Polkadot"}}} not found for system parachain statemine
	["examples/kusama/assetHub/foreignAssetTransfers/reserve/assetHubKSMDOTUSDTToBasilisk.ts"]=1

It also seem like for moonriver we get

PalletNotFound: Pallet xTokens not found in the current runtime.

which may correspond with what was going on here: #572

New issue - to be fixed later

I created an issue so we can address these failing examples later: #582

@andrew-ifrita andrew-ifrita marked this pull request as draft June 5, 2025 11:21
Updates docs to use tsx.
It isn't worth the hassle to individually build examples.
@socket-security

socket-security Bot commented Jun 5, 2025

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedresolve-pkg-maps@​1.0.01001009776100
Addedtsx@​4.19.41001008088100
Addedget-tsconfig@​4.10.11001009985100

View full report

@andrew-ifrita andrew-ifrita changed the title fix: Example build fix: example building + add CI step to catch failure of any example code Jun 5, 2025
@andrew-ifrita andrew-ifrita marked this pull request as ready for review June 5, 2025 18:11

@TarikGul TarikGul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good.

I noticed some of the examples are doing:

void (async () => {
	try {
		await main();
	} catch (err) {
		console.error(err);
		process.exit(1);
	} finally {
		process.exit();
	}
})();

And others are the same as before, is there a reason for that?

@andrew-ifrita

andrew-ifrita commented Jun 5, 2025

Copy link
Copy Markdown
Contributor Author

Overall looks good.

I noticed some of the examples are doing:

void (async () => {
	try {
		await main();
	} catch (err) {
		console.error(err);
		process.exit(1);
	} finally {
		process.exit();
	}
})();

And others are the same as before, is there a reason for that?

@TarikGul Good catch. I will fix. Looks like my find/replace wasn't recursive.

edit: and that led to detecting more failing examples

❌ Failed files:
examples/polkadot/parachain/paysWithFeeDest/bifrostToAssetHubPaysWithDOT.ts
examples/polkadot/assetHub/bridgeTransfers/assetHubKSMToKusama.ts
examples/polkadot/assetHub/foreignAssetTransfers/reserve/assetHubKSMToMoonbeam.ts
examples/polkadot/assetHub/foreignAssetTransfers/teleport/assetHubEQToEquilibrium.ts
examples/polkadot/assetHub/foreignAssetTransfers/local/assetHubKSMTransfer.ts
examples/paseo/relayChain/bridgeTransfers/paseoPASToWestendAssetHub.ts
examples/paseo/assetHub/bridgeTransfers/assetHubWETHToEthereumSepolia.ts
examples/paseo/assetHub/bridgeTransfers/assetHubPASToWestend.ts
examples/paseo/assetHub/bridgeTransfers/assetHubWNDToWestend.ts
examples/paseo/assetHub/foreignAssetTransfers/reserve/assetHubWETHToHydration.ts
examples/paseo/assetHub/foreignAssetTransfers/reserve/assetHubMUSEToHydration.ts
examples/paseo/assetHub/foreignAssetTransfers/reserve/assetHubMUSEToBifrostRemoteReserve.ts
examples/paseo/assetHub/foreignAssetTransfers/local/assetHubWETHTransfer.ts
examples/paseo/assetHub/paysWithFeeOriginTransfers/pasToHydrationPaysWithMUSE.ts
examples/kusama/assetHub/bridgeTransfers/assetHubDOTToPolkadot.ts
examples/kusama/assetHub/foreignAssetTransfers/reserve/assetHubKSMDOTUSDTToBasilisk.ts

@andrew-ifrita andrew-ifrita force-pushed the fix/example-build-and-testing branch from 50715f1 to 0960b28 Compare June 5, 2025 19:32
@andrew-ifrita andrew-ifrita merged commit 22df4a2 into main Jun 6, 2025
11 checks passed
@andrew-ifrita andrew-ifrita deleted the fix/example-build-and-testing branch June 6, 2025 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants