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

Add script test canisters #2652

Merged
merged 6 commits into from
Oct 16, 2024
Merged

Add script test canisters #2652

merged 6 commits into from
Oct 16, 2024

Conversation

lmuntaner
Copy link
Collaborator

@lmuntaner lmuntaner commented Oct 15, 2024

Motivation

Make it easy to run the canisters tests.

Tu run all the tests successfully, the environment needs to be set up. There was a readme file explaining part of it.

Changes

I moved the explanation to a script that can be run and it will download the necessary artifacts needed to run all the tests.


🟡 Some screens were changed

@lmuntaner lmuntaner marked this pull request as ready for review October 15, 2024 11:42
@lmuntaner lmuntaner requested a review from a team as a code owner October 15, 2024 11:42
@lmuntaner
Copy link
Collaborator Author

@frederikrothenberger please review

Copy link
Member

@frederikrothenberger frederikrothenberger left a comment

Choose a reason for hiding this comment

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

Useful script 👍
Left a few comments but already approving.

# Run tests

echo "Running integration tests."
cargo test "${@}"

Choose a reason for hiding this comment

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

Suggested change
cargo test "${@}"
cargo test "${@}"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks!

@@ -0,0 +1,49 @@
#!/bin/bash

Choose a reason for hiding this comment

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

This is the only script with multiple dots in the name. What about calling it test-canisters.sh?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, good point.

#!/bin/bash

POCKET_IC_SERVER_VERSION=6.0.0
POCKET_IC_SERVER_PATH="pocket-ic"

Choose a reason for hiding this comment

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

Given you are dealing with paths here, what about making sure that the working directory really is the repository directory?

Choose a reason for hiding this comment

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

We also usually set flags to fail early on error:

set -euo pipefail

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, done!

scripts/test.canisters.sh Outdated Show resolved Hide resolved
PREVIOUS_ARCHIVE_WASM_PATH="archive_previous.wasm.gz"

# Check if the script is run from the root of the project
project_root=$(git rev-parse --show-toplevel 2>/dev/null)

Choose a reason for hiding this comment

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

We normally just switch to the appropriate directory:

SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPTS_DIR/.."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, ok, changed!

@lmuntaner lmuntaner added this pull request to the merge queue Oct 16, 2024
Merged via the queue into main with commit a537c50 Oct 16, 2024
66 checks passed
@lmuntaner lmuntaner deleted the lm-add-script-test-canisters branch October 16, 2024 07:31
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