From bf92c731ffad19ff5a03fc2fcca9bf9449a6ff69 Mon Sep 17 00:00:00 2001 From: Enrico Marconi Date: Wed, 17 Apr 2024 11:13:47 +0200 Subject: [PATCH 1/2] Add workflow to check fmt, clippy and run tests --- .github/actions/iota-sandbox/setup/action.yml | 36 +++++++++++++++++++ .../actions/iota-sandbox/tear-down/action.yml | 12 +++++++ .github/workflows/clippy.yml | 29 +++++++++++++++ .github/workflows/run-tests.yml | 31 ++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 .github/actions/iota-sandbox/setup/action.yml create mode 100644 .github/actions/iota-sandbox/tear-down/action.yml create mode 100644 .github/workflows/clippy.yml create mode 100644 .github/workflows/run-tests.yml diff --git a/.github/actions/iota-sandbox/setup/action.yml b/.github/actions/iota-sandbox/setup/action.yml new file mode 100644 index 0000000..b62c175 --- /dev/null +++ b/.github/actions/iota-sandbox/setup/action.yml @@ -0,0 +1,36 @@ +name: 'iota-sandbox-setup' +description: 'Setup IOTA Sandbox' +runs: + using: "composite" + steps: + - name: Setup iota sandbox + shell: bash + run: | + # Use next lines for using the GitHub release + mkdir iota-sandbox + cd iota-sandbox + mkdir sandbox + cd sandbox + # Use the output of https://api.github.com/repos/iotaledger/iota-sandbox/releases/latest + DOWNLOAD_URL=$(curl "https://api.github.com/repos/iotaledger/iota-sandbox/releases" | jq -r '.[0].assets[] | select(.name | contains("iota_sandbox")) | .browser_download_url') + echo "Downloading sandbox from $DOWNLOAD_URL" + curl -L -o iota_sandbox.tar.gz $DOWNLOAD_URL + tar -xf iota_sandbox.tar.gz + + # Use the next lines to use the main branch + # git clone https://github.com/iotaledger/iota-sandbox + # cd iota-sandbox/sandbox + + # Start Tangle + sudo ./bootstrap.sh + docker compose up -d + - name: Wait for tangle to start + shell: bash + run: wget -qO- https://raw.githubusercontent.com/eficode/wait-for/$WAIT_FOR_VERSION/wait-for | sh -s -- -t 60 http://localhost/health -- echo "Tangle is up" + env: + WAIT_FOR_VERSION: 4df3f9262d84cab0039c07bf861045fbb3c20ab7 # v2.2.3 + - name: Wait for faucet to start + shell: bash + run: wget -qO- https://raw.githubusercontent.com/eficode/wait-for/$WAIT_FOR_VERSION/wait-for | sh -s -- -t 60 http://localhost/faucet/api/info -- echo "Faucet is up" + env: + WAIT_FOR_VERSION: 4df3f9262d84cab0039c07bf861045fbb3c20ab7 # v2.2.3 diff --git a/.github/actions/iota-sandbox/tear-down/action.yml b/.github/actions/iota-sandbox/tear-down/action.yml new file mode 100644 index 0000000..8a0da19 --- /dev/null +++ b/.github/actions/iota-sandbox/tear-down/action.yml @@ -0,0 +1,12 @@ +name: 'iota-sandbox-tear-down' +description: 'tear-down a iota sandbox' +runs: + using: "composite" + steps: + - name: Tear down iota sandbox + shell: bash + run: | + cd iota-sandbox/sandbox + docker-compose down + cd ../.. + sudo rm -rf iota-sandbox diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml new file mode 100644 index 0000000..ecb02d0 --- /dev/null +++ b/.github/workflows/clippy.yml @@ -0,0 +1,29 @@ +name: clippy & fmt + +on: + push: + branches: + - main + pull_request: + types: [ opened, synchronize, reopened, ready_for_review ] + branches: + - main + +jobs: + clippy-and-fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Update local toolchain + run: | + rustup update + rustup component add clippy + - name: Toolchain info + run: | + cargo --version --verbose + rustc --version + cargo clippy --version + - name: Check formatting + run: cargo fmt -- --check + - name: Run clippy + run: cargo clippy -- -D warnings diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..de9d57a --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,31 @@ +name: Run tests + +on: + push: + branches: + - main + pull_request: + types: [ opened, synchronize, reopened, ready_for_review ] + branches: + - main + +jobs: + run-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Update local toolchain + run: | + rustup update + rustup component add clippy + - name: Toolchain info + run: | + cargo --version --verbose + rustc --version + cargo clippy --version + - name: Start iota sandbox + uses: './.github/actions/iota-sandbox/setup' + - name: Run tests + run: cargo test --release + - name: Stop iota sandbox + uses: './.github/actions/iota-sandbox/tear-down' \ No newline at end of file From 5ab83ac7e2a23aef374d39d73c02deacc4832510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eike=20Ha=C3=9F?= Date: Thu, 18 Apr 2024 09:18:59 +0200 Subject: [PATCH 2/2] use facuet profile for sandbox --- .github/actions/iota-sandbox/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/iota-sandbox/setup/action.yml b/.github/actions/iota-sandbox/setup/action.yml index b62c175..8b32b86 100644 --- a/.github/actions/iota-sandbox/setup/action.yml +++ b/.github/actions/iota-sandbox/setup/action.yml @@ -23,7 +23,7 @@ runs: # Start Tangle sudo ./bootstrap.sh - docker compose up -d + docker compose --profile inx-faucet up -d - name: Wait for tangle to start shell: bash run: wget -qO- https://raw.githubusercontent.com/eficode/wait-for/$WAIT_FOR_VERSION/wait-for | sh -s -- -t 60 http://localhost/health -- echo "Tangle is up"