Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: starship testing in ci #50

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 64 additions & 25 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,74 @@ jobs:
- run: ls ./contract
- run: yarn test
integration:
runs-on: ubuntu-latest
runs-on: ubuntu-latest-16core

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: corepack enable
- run: yarn install
- run: yarn start:docker
- run: yarn build
# Borrowed from https://github.com/DCFoundation/cosmos-proposal-builder/blob/main/.github/workflows/pr.yml#L43-L61
- name: Wait for Docker container to be ready

- name: Enable Corepack
run: corepack enable

- name: Install deps
run: yarn install

- name: Clone and build agoric-sdk
run: |
git clone https://github.com/Agoric/agoric-sdk.git
cd agoric-sdk
yarn install
yarn build
yarn link-cli
echo "$HOME/bin" >> $GITHUB_PATH

- name: Build dapp-agoric-basics
run: yarn build
Comment on lines +48 to +49
Copy link
Member Author

Choose a reason for hiding this comment

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

Can remove, unless we are interested in testing the UI

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we plan on testing UI interactions in our pipeline, or just rely on unit?


- name: Setup Starship Infrastructure
id: starship-infra
uses: cosmology-tech/starship-action@0.3.0
with:
# uses ghcr.io/agoric/agoric-sdk:dev image (latest master)
values: ./e2e-testing/config.yaml
port-forward: true
version: 0.2.10
timeout: 30m
namespace: agoric-multichain

- name: Fund Provision Pool
run: |
timeout 300 bash -c '
TARGET_HEIGHT=1111
SLEEP=10
echo "Waiting for the Agoric service to be fully ready..."
echo "Target block height: $TARGET_HEIGHT"
while true; do
response=$(curl --silent http://localhost:26657/abci_info);
height=$(echo $response | jq -r ".result.response.last_block_height | tonumber");
if [ "$height" -ge $TARGET_HEIGHT ]; then
echo "Service is ready! Last block height: $height";
break;
else
echo "Waiting for last block height to reach $TARGET_HEIGHT. Current height: $height";
fi;
sleep $SLEEP;
done
'
- run: yarn integration-test
kubectl config set-context --current --namespace=agoric-multichain
kubectl get pods
make fund-provision-pool
working-directory: ./e2e-testing

- name: Ensure ports are forwarded
run: |
curl --fail --retry 3 --retry-delay 10 http://localhost:26657/status || (echo "agoriclocal node is available")
curl --fail --retry 3 --retry-delay 10 http://localhost:8081/chains/agoriclocal || (echo "agoriclocal URL check failed")
curl --fail --retry 3 --retry-delay 10 http://localhost:8081/chains/osmosislocal || (echo "osmosislocal URL check failed")
curl --fail --retry 3 --retry-delay 10 http://localhost:8081/chains/gaialocal || (echo "gaialocal URL check failed")

- name: Override Chain Registry
run: make override-chain-registry
working-directory: ./e2e-testing

- name: Run Integration Test
run: yarn integration-test

- name: Capture and print agoric validator logs
if: always()
run: kubectl logs agoriclocal-genesis-0 --container=validator || true

- name: Capture and print agoric-osmosis relayer logs
if: always()
run: kubectl logs hermes-agoric-osmosis-0 --container=relayer || true

- name: Capture and print agoric-cosmos relayer logs
if: always()
run: kubectl logs hermes-agoric-gaia-0 --container=relayer || true

- name: verify contracts started onchain
run: |
curl http://localhost:1317/agoric/vstorage/data/published.agoricNames.instance | grep orca
5 changes: 4 additions & 1 deletion contract/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# TODO: figure out how to factor with e2e-testing/Makefile

CHAINID=agoriclocal
USER1ADDR=$(shell agd keys show alice -a --keyring-backend="test")
ACCT_ADDR=$(USER1ADDR)
Expand Down Expand Up @@ -275,4 +277,5 @@ e2e:
# yarn node script/deploy-contract.js

lint:
yarn lint --fix-dry-run --ignore-pattern "*patch*"
yarn lint --fix-dry-run --ignore-pattern "*patch*"

9 changes: 3 additions & 6 deletions contract/tools/deploy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/** @file run a builder and deploy it onto the Agoric chain in local Starship cluster */
import { createRequire } from 'module';
import { makeAgdTools } from './agd-tools.js';

const nodeRequire = createRequire(import.meta.url);

export const makeDeployBuilder = (tools, readJSON, execa) =>
async function deployBuilder(builder) {
Expand All @@ -17,9 +13,10 @@ export const makeDeployBuilder = (tools, readJSON, execa) =>
console.log(plan);

console.log('copying files to container');

tools.copyFiles([
nodeRequire.resolve(`../${plan.script}`),
nodeRequire.resolve(`../${plan.permit}`),
`./${plan.script}`,
`./${plan.permit}`,
...plan.bundles.map(b => b.fileName),
]);

Expand Down
6 changes: 2 additions & 4 deletions contract/tools/e2e-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,8 @@ export const makeE2ETools = async (
const { name, title = name, description = title } = info;
// NOTE: name only comes through as orca, not the actual file names
const eval0 = {
// code: `/tmp/contracts/${name}.js`,
// permit: `/tmp/contracts/${name}-permit.json`,
code: `/tmp/contracts/startOrcaContract.js`,
permit: `/tmp/contracts/startOrcaContract-permit.json`,
code: `/tmp/contracts/${name}.js`,
permit: `/tmp/contracts/${name}-permit.json`,
};

const detail = { evals: [eval0], title, description };
Expand Down
4 changes: 3 additions & 1 deletion contract/tools/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export const makeGetFile = ({
export const makeSetupRegistry = getFile => {
let initialized = false;

const setupRegistry = async ({ config = '../config.yaml' } = {}) => {
const setupRegistry = async ({
config = '../../e2e-testing/config.yaml',
} = {}) => {
if (initialized) return { useChain };
const configFile = getFile(config);
console.log('configFile', configFile);
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# TODO, consider removing in favor of e2e-testing (starship)
version: '3.5'

services:
Expand Down
1 change: 1 addition & 0 deletions e2e-testing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
revise-chain-info*
105 changes: 105 additions & 0 deletions e2e-testing/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# see https://github.com/cosmology-tech/starship/blob/0e18757b8393357fc66426c5ee23da4ccf760e74/examples/getting-started/Makefile

NAME = agoric-multichain-testing
FILE = config.yaml

HELM_REPO = starship
HELM_CHART = devnet
HELM_VERSION = v0.2.10

###############################################################################
### All commands ###
###############################################################################

.PHONY: setup
setup: setup-deps setup-kind

.PHONY: stop
stop: stop-forward delete

.PHONY: clean
clean: stop clean-kind

###############################################################################
### Dependency check ###
###############################################################################

.PHONY: check
setup-deps:
bash $(CURDIR)/scripts/dev-setup.sh

###############################################################################
### Helm Charts ###
###############################################################################

install:
bash $(CURDIR)/scripts/install.sh --config $(FILE) --name $(NAME) --version $(HELM_VERSION)

delete:
-helm delete $(NAME)

###############################################################################
### Port forward ###
###############################################################################

.PHONY: port-forward
port-forward:
bash $(CURDIR)/scripts/port-forward.sh --config=$(FILE)

.PHONY: stop-forward
stop-forward:
-pkill -f "port-forward"

###############################################################################
### Local Kind Setup ###
###############################################################################
KIND_CLUSTER=agship

.PHONY: setup-kind
setup-kind:
kind create cluster --name $(KIND_CLUSTER)

.PHONY: clean-kind
clean-kind:
-kind delete cluster --name $(KIND_CLUSTER)

###############################################################################
### Agoric Setup ###
###############################################################################
PROVISION_POOL_ADDR=agoric1megzytg65cyrgzs6fvzxgrcqvwwl7ugpt62346

# add address
add-address:
kubectl exec -i agoriclocal-genesis-0 -c validator -- agd keys add user1

fund-provision-pool:
kubectl exec -i agoriclocal-genesis-0 -c validator -- agd tx bank send faucet $(PROVISION_POOL_ADDR) 1000000000uist -y -b block

override-chain-registry:
../node_modules/.bin/tsx scripts/fetch-starship-chain-info.ts && \
../node_modules/.bin/tsx scripts/deploy-cli.ts proposals/revise-chain-info.builder.js

ADDR=agoric1ldmtatp24qlllgxmrsjzcpe20fvlkp448zcuce
COIN=1000000000uist

fund-wallet:
kubectl exec -i agoriclocal-genesis-0 -c validator -- agd tx bank send faucet $(ADDR) $(COIN) -y -b block

provision-smart-wallet:
kubectl exec -i agoriclocal-genesis-0 -c validator -- agd tx swingset provision-one wallet $(ADDR) SMART_WALLET --from $(ADDR) -y -b block

# view agoric swingset logs from slog file, until we can set `DEBUG=SwingSet:vat,SwingSet:ls`
tail-slog:
kubectl exec -i agoriclocal-genesis-0 -c validator -- tail -f slog.slog

###############################################################################
### Start All ###
###############################################################################

.PHONY: wait-for-pods
wait-for-pods:
../node_modules/.bin/tsx scripts/pod-readiness.ts

.PHONY: start
start: install wait-for-pods port-forward fund-provision-pool override-chain-registry

4 changes: 3 additions & 1 deletion contract/config.yaml → e2e-testing/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ chains:
host_port: 'icqhost'
params:
host_enabled: true
allow_queries: ['*']
allow_queries:
- /cosmos.bank.v1beta1.Query/Balance
- /cosmos.bank.v1beta1.Query/AllBalances
faucet:
enabled: true
type: starship
Expand Down
22 changes: 22 additions & 0 deletions e2e-testing/proposals/revise-chain-info.builder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* global harden */
/// <reference types="ses" />
import { makeHelpers } from '@agoric/deploy-script-support';

import chainInfo from '../starship-chain-info.js';

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
export const defaultProposalBuilder = async () =>
harden({
sourceSpec: '@agoric/orchestration/src/proposals/revise-chain-info.js',
getManifestCall: [
'getManifestForReviseChains',
{
chainInfo,
},
],
});

export default async (homeP, endowments) => {
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('revise-chain-info', defaultProposalBuilder);
};
29 changes: 29 additions & 0 deletions e2e-testing/scripts/deploy-cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env tsx
import '@endo/init/debug.js';

import { execa } from 'execa';
import fse from 'fs-extra';
import childProcess from 'node:child_process';

import { makeAgdTools } from '../../contract/tools/agd-tools.js';
import { makeDeployBuilder } from '../../contract/tools/deploy.js';

async function main() {
const builder = process.argv[2];

if (!builder) {
console.error('USAGE: deploy-cli.ts <builder script>');
process.exit(1);
}

try {
const agdTools = await makeAgdTools(console.log, childProcess);
const deployBuilder = makeDeployBuilder(agdTools, fse.readJSON, execa, './e2e-testing');
await deployBuilder(builder);
} catch (err) {
console.error(err);
process.exit(1);
}
}

main();
Loading
Loading