adding checker script to ci #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Checker Script CI | |
on: | |
pull_request: | |
branches: | |
- main | |
- master | |
jobs: | |
run-checker: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the code from the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Step 2: Remove any non-rustup installed Rust and Cargo versions | |
- name: Ensure only rustup manages Rust | |
run: | | |
sudo apt-get remove --purge cargo rustc || true | |
brew uninstall --force rust || true | |
sudo rm -rf /usr/local/bin/rustc /usr/local/bin/cargo || true | |
# Step 3: Install rustup if not present | |
- name: Install rustup | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
source $HOME/.cargo/env | |
# Step 4: Install the required wasm32-unknown-unknown target | |
- name: Set up Rust and install the target | |
run: | | |
rustup install stable | |
rustup default stable | |
rustup target add wasm32-unknown-unknown | |
# Step 5: Loop through directories to install specific toolchain versions | |
- name: Install Rust toolchain per directory | |
run: | | |
for dir in example_code/applications/* example_code/basic_examples/*; do | |
if [[ -d "$dir" && -f "$dir/rust-toolchain.toml" ]]; then | |
echo "Installing Rust toolchain for directory: $dir" | |
toolchain_version=$(grep '^channel' "$dir/rust-toolchain.toml" | cut -d '"' -f 2) | |
if rustup toolchain install "$toolchain_version"; then | |
echo "Toolchain $toolchain_version installed for $dir" | |
rustup override set "$toolchain_version" --path "$dir" | |
else | |
echo "Failed to install toolchain $toolchain_version for $dir" | |
exit 1 | |
fi | |
else | |
echo "No rust-toolchain.toml found for $dir, skipping." | |
fi | |
done | |
# Step 6: Install cargo-stylus | |
- name: Install cargo-stylus | |
run: cargo install cargo-stylus | |
# Step 7: Make checker.sh executable | |
- name: Make checker.sh executable | |
run: chmod +x ./checker.sh | |
# Step 8: Run the checker.sh script (it will fetch the latest SDK version) | |
- name: Run checker script | |
run: ./checker.sh | |
# Step 9: Check for the existence of check_results.log and fail if missing | |
- name: Ensure check_results.log exists | |
run: | | |
if [ ! -f check_results.log ]; then | |
echo "check_results.log not found! Failing the check." | |
exit 1 | |
fi | |
# Step 10: Check for issues in the log file | |
- name: Check for issues in the log | |
run: | | |
if grep -q "FAILED" check_results.log; then | |
echo "Checker script failed! Fix the issues before merging." | |
exit 1 | |
else | |
echo "Checker script passed! Ready to merge." | |
fi |