From 88124b976e13ad59d36a6d440a65fa975ebe30a5 Mon Sep 17 00:00:00 2001 From: Nick Italiano Date: Fri, 28 Jun 2024 13:27:26 -0400 Subject: [PATCH] Adds Justfile (#29) * Adds Justfile * Adds an initial local dev setup script * words * Add github actions to install just and share the base setup between everything * fix ordering * fix indent --- .github/actions/setup/action.yml | 18 ++++++++++++++++++ .github/workflows/main.yml | 24 +++++++----------------- Justfile | 17 +++++++++++++++++ scripts/local-dev-setup.sh | 22 ++++++++++++++++++++++ 4 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 .github/actions/setup/action.yml create mode 100644 Justfile create mode 100755 scripts/local-dev-setup.sh diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 00000000..8acd8938 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,18 @@ +name: Setup +runs: + using: composite + steps: + - name: Setup Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '^1.22' + + - name: Setup Just + uses: extractions/setup-just@v1 + with: + just-version: 1.5.0 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 76bf60a9..85e3bc00 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,20 +28,17 @@ jobs: with: submodules: recursive - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly + - name: Setup + uses: ./.github/actions/setup - name: Run Forge build run: | - forge --version - forge build --sizes --root ./contracts + just build-contracts id: build - name: Run Forge tests run: | - forge test -vvv --root ./contracts + just test-contracts id: test go-tests: @@ -50,18 +47,11 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '^1.22' + - name: Setup + uses: ./.github/actions/setup - name: Install dependencies run: go mod download - name: Run tests - run: go test ./... -v + run: just test-go diff --git a/Justfile b/Justfile new file mode 100644 index 00000000..e3b3d3f2 --- /dev/null +++ b/Justfile @@ -0,0 +1,17 @@ +set positional-arguments + +build-contracts: + forge --version + forge build --sizes --root ./contracts + +build-go: + go build ./... + +test-contracts: + forge test -vvv --root ./contracts + +test-go: + go test ./... -v + +start: + go run ./... \ No newline at end of file diff --git a/scripts/local-dev-setup.sh b/scripts/local-dev-setup.sh new file mode 100755 index 00000000..ed78142b --- /dev/null +++ b/scripts/local-dev-setup.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +################## +# Just Setup # +################## + +echo "Checking just setup" + +if ! command -v just > /dev/null 2>&1; then + # create ~/bin + mkdir -p ~/bin + + # download and extract just to ~/bin/just + curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ~/bin + + # add `~/bin` to your path + export PATH="$PATH:$HOME/bin" + + echo "just has been installed" +else + echo "skipping just install, it already exists." +fi