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

ci: add integration test to GitHub Action #24

Merged
merged 8 commits into from
Mar 18, 2024
Merged
54 changes: 47 additions & 7 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
name: Lint and Test
name: CI

on:
pull_request:

jobs:
all:
unit:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Use Node.js 18.8.x
uses: actions/setup-node@v3
uses: actions/checkout@v4
- name: Use Node.js 18
uses: actions/setup-node@v4
with:
# use node 18.8.x until Agoric/agoric-sdk#8636
node-version: '18.8.x'
node-version: "18"
- name: yarn install
run: yarn
- name: yarn lint
Expand All @@ -24,3 +23,44 @@ jobs:
run: yarn test
- name: yarn test:e2e
run: yarn test:e2e
integration:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Use Node.js 18
uses: actions/setup-node@v4
with:
node-version: "18"
- name: yarn install
run: yarn
- name: yarn start:docker
run: yarn start:docker
- name: yarn build
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
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
'
- name: yarn start:contract
run: yarn start:contract
Copy link
Member

Choose a reason for hiding this comment

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

Here's hoping we can test that the contracts actually got started.

One way is:

agoric follow -lF :published.agoricNames.instance | grep sellConcertTickets

but that presumes the agoric CLI is available; I'm not sure that's the case.

agoric follow -lF ... is just an HTTP GET, so it can be done with curl too.

I'm working on running the tests for contract functionality in an end-to-end context too. But we're not quite there yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We do now! Jim's slides this morning gave me an idea and we're testing that. Though I don't know why the CI couldn't see swaparoo contract onchain. The other 2 contracts are available on based on the curl response.

Ref: https://github.com/Agoric/dapp-agoric-basics/actions/runs/8332287701/job/22801091735?pr=24

Copy link
Member

Choose a reason for hiding this comment

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

We do now!

nice!

I don't know why the CI couldn't see swaparoo contract onchain.

very strange. it's certainly in the ci log: [\\\\\\\"sellConcertTickets\\\\\\\",\\\\\\\"$23.Alleged: InstanceHandle\\\\\\\"]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It could grep sellConcertTickets and postalService, but not swaparoo

I tried to CTRL+F on the blob and I couldn't find swaparoo in the data blob. Do we need to wait for some time before curling and greping?

Copy link
Member

Choose a reason for hiding this comment

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

oic. I was reading too quickly.

I'm not sure what's up with swaparoo there. But the way it's deployed changes significantly with the addition of governance (#21) so I'm not inclined to worry about it now.

- name: verify contracts started onchain
run: |
curl http://localhost:1317/agoric/vstorage/data/published.agoricNames.instance | grep sellConcertTickets
curl http://localhost:1317/agoric/vstorage/data/published.agoricNames.instance | grep postalService