commit run scripts, bump rust ci img versions (#2526)

This commit is contained in:
Collin Chin 2023-08-15 08:48:18 -07:00 committed by GitHub
parent 12570e4602
commit 92386438fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 10 deletions

View File

@ -50,7 +50,7 @@ commands:
jobs:
check-style:
docker:
- image: cimg/rust:1.70
- image: cimg/rust:1.71
resource_class: xlarge
steps:
- checkout
@ -66,7 +66,7 @@ jobs:
clippy:
docker:
- image: cimg/rust:1.70
- image: cimg/rust:1.71
resource_class: xlarge
steps:
- checkout
@ -83,7 +83,7 @@ jobs:
leo-executable:
docker:
- image: cimg/rust:1.70
- image: cimg/rust:1.71
resource_class: xlarge
steps:
- checkout
@ -102,7 +102,7 @@ jobs:
leo-new:
docker:
- image: cimg/rust:1.70
- image: cimg/rust:1.71
resource_class: xlarge
steps:
- attach_workspace:
@ -115,7 +115,7 @@ jobs:
leo-clean:
docker:
- image: cimg/rust:1.70
- image: cimg/rust:1.71
resource_class: xlarge
steps:
- attach_workspace:
@ -128,7 +128,7 @@ jobs:
test-examples:
docker:
- image: cimg/rust:1.70
- image: cimg/rust:1.71
resource_class: xlarge
steps:
- attach_workspace:

View File

@ -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

View File

@ -5,6 +5,10 @@
To run this program, run:
```bash
leo run play
or
./run.sh
```
## Execute Guide

10
examples/lottery/run.sh Executable file
View File

@ -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

View File

@ -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(),
@ -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()
}
}
}
@ -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(),
}
}
}