Skip to content

Commit

Permalink
ci: add concurrency configuration to e2e Github Actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Apr 6, 2024
1 parent 6af632b commit 6a1fbd3
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 83 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
- main
schedule:
- cron: '0 0 * * *'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
e2e:
Expand Down
50 changes: 25 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
FROM node:18.18
FROM ghcr.io/agoric/agoric-sdk:20240401190900-a3bdfb-linux_amd64

# Install chrome and necessary dependencies
# Add the Agoric CLI to the PATH so that 'agops' can be accessed from anywhere in the command line.
ENV PATH="/usr/src/agoric-sdk/packages/agoric-cli/bin:${PATH}"

# Setup Node 18.18
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
SHELL ["/bin/bash", "--login", "-c"]
ENV NODE_VERSION=18.18.0
ENV NVM_DIR /tmp/nvm
WORKDIR $NVM_DIR

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default

ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/v$NODE_VERSION/bin:$PATH

# Install necessary dependencies
RUN apt-get update \
&& apt-get install -y wget gnupg ca-certificates jq expect \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& apt-get install -y wget gnupg ca-certificates jq expect xvfb

# Install Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable

# Setup Golang
COPY --from=golang:1.21 /usr/local/go/ /usr/local/go/
ENV PATH="/usr/local/go/bin:${PATH}"
ENV GOPATH="/go"
ENV GOBIN="/go/bin"

# Agoric SDK Setup
WORKDIR /agoric-app
RUN git clone https://github.com/Agoric/agoric-sdk.git && \
cd agoric-sdk && \
yarn && \
yarn build && \
yarn link-cli ~/bin/agoric && \
cd packages/cosmic-swingset && \
make && \
cd ../.. && \
./bin/agd build

ENV PATH="/agoric-app/agoric-sdk/bin:${PATH}"
EXPOSE 26657

# Setup Wallet App
WORKDIR /app
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"@agoric/eslint-config": "^0.3.21",
"@agoric/eventual-send": "^0.13.27",
"@agoric/synpress": "^3.8.1-beta.1",
"@agoric/synpress": "^3.8.1",
"@endo/eslint-config": "^0.3.9",
"@jessie.js/eslint-plugin": "^0.1.3",
"@material/mwc-dialog": "^0.21.0",
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
- ./cypress/videos:/app/test/e2e/videos
- ./cypress/screenshots:/app/test/e2e/screenshots
command: >
bash -c 'echo -n "======> local noVNC URL: http://localhost:8080/vnc.html?autoconnect=true " && yarn wait-on http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && yarn test:e2e:ci'
bash -c 'echo -n "======> local noVNC URL: http://localhost:8080/vnc.html?autoconnect=true " && yarn wait-on http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && source /tmp/nvm/nvm.sh && nvm use 18.18 && yarn test:e2e:ci'
networks:
- x11

Expand Down
82 changes: 33 additions & 49 deletions test/e2e/specs/test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@ describe('Wallet App Test Cases', () => {
cy.get('span').contains('BLD').should('exist');
});

it('should check if agops is working', () => {
cy.exec('agops', { failOnNonZeroExit: false }).then((result) => {
expect(result.code).to.equal(1);
expect(result.stderr).to.contain('Usage: agops [options] [command]');
});
});

it('should check if agd is working', () => {
cy.exec('agd').then((result) => {
expect(result.stderr).to.be.empty;
});
});

it('should add keys using agd from the CLI successfully', () => {
cy.exec('bash ./test/e2e/test-scripts/add-keys.sh').then((result) => {
expect(result.stderr).to.contain('');
Expand All @@ -58,28 +45,26 @@ describe('Wallet App Test Cases', () => {
it('should place a bid by discount from the CLI successfully', () => {
cy.addNewTokensFound();
cy.getTokenAmount('IST').then((initialTokenValue) => {
cy.exec('bash ./test/e2e/test-scripts/place-bid-by-discount.sh').then(
(result) => {
expect(result.stderr).to.contain('');
expect(result.stdout).to.contain('Bid Placed Successfully');
cy.getTokenAmount('IST').then((tokenValue) => {
expect(tokenValue).to.lessThan(initialTokenValue);
});
},
);
cy.exec('bash ./test/e2e/test-scripts/place-bid-by-discount.sh', {
failOnNonZeroExit: false,
}).then((result) => {
expect(result.stderr).to.contain('');
expect(result.stdout).to.contain('Bid Placed Successfully');
cy.getTokenAmount('IST').then((tokenValue) => {
expect(tokenValue).to.lessThan(initialTokenValue);
});
});
});
});

it('should only have one element with specific parameters for the bid created in the previous test case', () => {
it('should see an offer placed in the previous test case', () => {
cy.visit('/wallet/');

cy.get('.RequestSummary h6').contains('Offer');
cy.get('.Body .MuiChip-label').contains('Pending');
cy.get('.OfferEntry h6').contains('Give Bid');
cy.get('.OfferEntry .Token .MuiBox-root').contains('2.00 IST');
cy.get('.OfferEntry .Token').contains('from IST');
cy.get('.OfferEntry h6').contains('Arguments');
cy.get('.Request').should('have.length', 1);
cy.contains('Offer').should('be.visible');
cy.contains('Give Bid').should('be.visible');
cy.contains('2.00 IST').should('be.visible');
cy.contains('from IST').should('be.visible');
cy.contains('Arguments').should('be.visible');
});

it('should cancel the bid by discount and verify IST balance', () => {
Expand All @@ -100,28 +85,25 @@ describe('Wallet App Test Cases', () => {

it('should place a bid by price from the CLI successfully and verify IST balance', () => {
cy.getTokenAmount('IST').then((initialTokenValue) => {
cy.exec('bash ./test/e2e/test-scripts/place-bid-by-price.sh').then(
(result) => {
expect(result.stderr).to.contain('');
expect(result.stdout).to.contain('Bid Placed Successfully');
cy.getTokenAmount('IST').then((tokenValue) => {
expect(tokenValue).to.lessThan(initialTokenValue);
});
},
);
cy.exec('bash ./test/e2e/test-scripts/place-bid-by-price.sh', {
failOnNonZeroExit: false,
}).then((result) => {
expect(result.stderr).to.contain('');
expect(result.stdout).to.contain('Bid Placed Successfully');
cy.getTokenAmount('IST').then((tokenValue) => {
expect(tokenValue).to.lessThan(initialTokenValue);
});
});
});
});

it('should only have one element with specific parameters for the bid created in the previous test case', () => {
it('should see an offer placed in the previous test case', () => {
cy.visit('/wallet/');

cy.get('.RequestSummary h6').contains('Offer');
cy.get('.Body .MuiChip-label').contains('Pending');
cy.get('.OfferEntry h6').contains('Give Bid');
cy.get('.OfferEntry .Token .MuiBox-root').contains('1.00 IST');
cy.get('.OfferEntry .Token').contains('from IST');
cy.get('.OfferEntry h6').contains('Arguments');
cy.get('.Request').should('have.length', 1);
cy.contains('Offer').should('be.visible');
cy.contains('Give Bid').should('be.visible');
cy.contains('1.00 IST').should('be.visible');
cy.contains('from IST').should('be.visible');
cy.contains('Arguments').should('be.visible');
});

it('should cancel the bid by price and verify IST balance', () => {
Expand All @@ -141,7 +123,9 @@ describe('Wallet App Test Cases', () => {
});

it('should view the auction from the CLI successfully', () => {
cy.exec('bash ./test/e2e/test-scripts/view-auction.sh').then((result) => {
cy.exec('bash ./test/e2e/test-scripts/view-auction.sh', {
failOnNonZeroExit: false,
}).then((result) => {
expect(result.stderr).to.contain('');
expect(result.stdout).to.contain('All required fields are present');
});
Expand Down
21 changes: 20 additions & 1 deletion test/e2e/test-scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,30 @@ export mnemonic="orbit bench unit task food shock brand bracket domain regular w
export AGORIC_NET=emerynet
export accountAddress=agoric1p2aqakv3ulz4qfy2nut86j9gx0dx0yw09h96md

# Function to check if field is present using jq
check_field_presence() {
field_value=$(echo "$output" | jq -r ".$1")
if [ -z "$field_value" ]; then
echo "Error: $1 field is missing or empty"
exit 1
fi
}

add_keys() {
commandToExecute="agd keys add $accountName --recover --keyring-backend=test"
mnemonicPrompt="Enter your bip39 mnemonic"

expect -c "
spawn $commandToExecute
expect {
\"override\" {
send \"y\r\"
exp_continue
}
\"$mnemonicPrompt\" {
send \"$mnemonic\r\"
exp_continue
}
}
"
}

1 change: 0 additions & 1 deletion test/e2e/test-scripts/place-bid-by-discount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ source ./test/e2e/test-scripts/common.sh
output=$(agops inter bid by-discount --discount 5 --give 2IST --from $accountAddress --keyring-backend=test | jq)
wait


if echo "$output" | grep -q "Your bid has been accepted"; then
echo "Bid Placed Successfully"
echo "" >&2
Expand Down
1 change: 0 additions & 1 deletion test/e2e/test-scripts/place-bid-by-price.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

source ./test/e2e/test-scripts/common.sh


output=$(agops inter bid by-price --give 1IST --price 8.55 --from $accountAddress --keyring-backend=test | jq)
wait

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,10 @@
resolved "https://registry.yarnpkg.com/@agoric/swingset-xsnap-supervisor/-/swingset-xsnap-supervisor-0.10.2.tgz#09f067695b0ea6ebfeb6ea200cc7f1675f0f8939"
integrity sha512-3PB15aiNHfjTYmtUz9Rxmm6qSHnoO5w5dygRzjx2ytk8yoNn/ZOpxlIOLonhD8kwOaEli5D7btY9OA3jf+Sm6w==

"@agoric/synpress@^3.8.1-beta.1":
version "3.8.1-beta.1"
resolved "https://registry.yarnpkg.com/@agoric/synpress/-/synpress-3.8.1-beta.1.tgz#73da38ed062dc3d39ae5cfc4211f242f6434ae91"
integrity sha512-D7bRxNz/M0ExrojW9qyw1YNdFI3uSxDUkAB9xyPVkOa8US9ETaT7Akmvz16d40UG10n9G3H1WGlymG6nCTnRYQ==
"@agoric/synpress@^3.8.1":
version "3.8.1"
resolved "https://registry.yarnpkg.com/@agoric/synpress/-/synpress-3.8.1.tgz#0c71e16a5ce81b77f8b20588946d55c312acc34d"
integrity sha512-vD8TeKOWup/yrPO7LBiYwvKSy6LAjGJaMiCU52yfp/zqKFBWopfwCdUSpvzTnhBEZAz3VUxsrgzgfil5wCiRNQ==
dependencies:
"@cypress/code-coverage" "^3.11.0"
"@cypress/webpack-dev-server" "^3.5.2"
Expand Down

0 comments on commit 6a1fbd3

Please sign in to comment.