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

commit run scripts, bump rust ci img versions #2526

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ commands:
jobs:
check-style:
docker:
- image: cimg/rust:1.70
- image: cimg/rust:1.71
resource_class: xlarge
steps:
- checkout
Expand All @@ -66,7 +66,7 @@ jobs:

clippy:
docker:
- image: cimg/rust:1.70
- image: cimg/rust:1.71
resource_class: xlarge
steps:
- checkout
Expand All @@ -83,7 +83,7 @@ jobs:

leo-executable:
docker:
- image: cimg/rust:1.70
- image: cimg/rust:1.71
resource_class: xlarge
steps:
- checkout
Expand All @@ -102,7 +102,7 @@ jobs:

leo-new:
docker:
- image: cimg/rust:1.70
- image: cimg/rust:1.71
resource_class: xlarge
steps:
- attach_workspace:
Expand All @@ -115,7 +115,7 @@ jobs:

leo-clean:
docker:
- image: cimg/rust:1.70
- image: cimg/rust:1.71
resource_class: xlarge
steps:
- attach_workspace:
Expand All @@ -128,7 +128,7 @@ jobs:

test-examples:
docker:
- image: cimg/rust:1.70
- image: cimg/rust:1.71
resource_class: xlarge
steps:
- attach_workspace:
Expand Down
15 changes: 12 additions & 3 deletions .circleci/test-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,18 @@ if [ $EXITCODE -ne 0 ]; then
exit $EXITCODE
fi

# Build the lottery example Leo program.
echo "Building the \`lottery\` program..."
# Build and run the lottery Leo program.
echo "Building and running the \`lottery\` program..."
(
cd $EXAMPLES/lottery || exit
$LEO build || exit

chmod +x $EXAMPLES/lottery/run.sh || exit
export -f leo
$EXAMPLES/lottery/run.sh || exit
)
# Check that the lottery program ran successfully.
EXITCODE=$?
if [ $EXITCODE -ne 0 ]; then
echo "The \`lottery\` program failed to run successfully."
exit $EXITCODE
fi
4 changes: 4 additions & 0 deletions examples/lottery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
To run this program, run:
```bash
leo run play

or

./run.sh
```

## Execute Guide
Expand Down
10 changes: 10 additions & 0 deletions examples/lottery/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# First check that Leo is installed.
if ! command -v leo &> /dev/null
then
echo "leo is not installed."
exit
fi

# Run the lottery example
leo run play || exit
18 changes: 17 additions & 1 deletion leo/cli/commands/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ impl Command for Example {
let readme_file_path_string = readme_file_path.display().to_string();
fs::write(readme_file_path, self.readme_file_string()).map_err(CliError::failed_to_write_file)?;

// Write the run.sh file.
let run_file_path = package_dir.join("run.sh");
fs::write(run_file_path, self.run_file_string()).map_err(CliError::failed_to_write_file)?;

tracing::info!(
"🚀 To run the '{}' program follow the instructions at {}",
self.name().bold(),
Expand Down Expand Up @@ -98,7 +102,9 @@ impl Example {
Self::TicTacToe => {
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/tictactoe/inputs/tictactoe.in")).to_string()
}
Self::Token => include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/token/run.sh")).to_string(),
Self::Token => {
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/token/inputs/token.in")).to_string()
}
}
}

Expand All @@ -113,4 +119,14 @@ impl Example {
Self::Token => include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/token/README.md")).to_string(),
}
}

fn run_file_string(&self) -> String {
match self {
Self::Lottery => include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/lottery/run.sh")).to_string(),
Self::TicTacToe => {
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/tictactoe/run.sh")).to_string()
}
Self::Token => include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/token/run.sh")).to_string(),
}
}
}