diff --git a/.github/workflows/default-setup.yml b/.github/workflows/default-setup.yml new file mode 100644 index 0000000..f4348e6 --- /dev/null +++ b/.github/workflows/default-setup.yml @@ -0,0 +1,47 @@ +name: default-setup + +on: + workflow_call: + secrets: + INFURA_API_KEY: + required: true + outputs: + cache-key: + description: "Cache key" + value: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }} + jobs: + setup: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Use Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + cache: "yarn" + cache-dependency-path: "yarn.lock" + + - name: Install dependencies 📦 + run: yarn install --frozen-lockfile + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Generate contract Rust bindings + run: yarn bind + + - name: Cache Cargo registry + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }} + restore-keys: | + ${{ runner.os }}-cargo-registry- diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9a79f56..64af77e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -13,41 +13,15 @@ env: jobs: lint: name: Lint + needs: setup runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Use Node.js 20.x - uses: actions/setup-node@v4 - with: - node-version: 20.x - cache: "yarn" - cache-dependency-path: "yarn.lock" - - - name: Install dependencies 📦 - run: yarn install --frozen-lockfile - - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly - - - name: Generate contract Rust bindings - run: yarn bind - - - name: Cache Cargo registry - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }} - restore-keys: | - ${{ runner.os }}-cargo-registry- + - name: Setup + id: setup + uses: ./.github/workflows/default-setup.yml + secrets: + INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }} - name: Install Rust toolchain via rustup run: | @@ -58,43 +32,16 @@ jobs: run: cargo clippy --all-targets --all-features -- -D warnings test: - needs: lint + needs: [ setup, lint ] name: Test runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Use Node.js 20.x - uses: actions/setup-node@v4 - with: - node-version: 20.x - cache: "yarn" - cache-dependency-path: "yarn.lock" - - - name: Install dependencies 📦 - run: yarn install --frozen-lockfile - - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly - - - name: Generate contract Rust bindings - run: forge bind -b src/bindings/ --module --overwrite - - - name: Cache Cargo registry - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }} - restore-keys: | - ${{ runner.os }}-cargo-registry- + - name: Setup + id: setup + uses: ./.github/workflows/default-setup.yml + secrets: + INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }} - name: Build run: cargo build