From b32c6265bda9276ff19ff65f3f2a4aab8dc2e127 Mon Sep 17 00:00:00 2001 From: Babur Makhmudov <31780624+bmuddha@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:58:38 +0530 Subject: [PATCH 01/13] CI: add github actions flow build-and-test.yml --- .github/workflows/build-and-test.yml | 77 ++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/build-and-test.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..95a7aa8 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,77 @@ +name: Magic Router Build + +on: + pull_request: + branches: [ "main" ] + +env: + solana_version: v1.18.25 + +jobs: + install: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + name: cache solana cli + id: cache-solana + with: + path: | + ~/.cache/solana/ + ~/.local/share/solana/ + key: solana-${{ runner.os }}-v0000-${{ env.solana_version }} + + - name: install solana + if: steps.cache-solana.outputs.cache-hit != 'true' + run: | + sh -c "$(curl -sSfL https://release.solana.com/${{ env.solana_version }}/install)" + export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH" + solana --version + + + rust-checks: + runs-on: ubuntu-latest + container: + image: rust:latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v3 + with: + path: target/debug + key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-debug- + solana-${{ runner.os }}-v0000-${{ env.solana_version }} + - name: Install rustfmt and clippy + run: rustup component add rustfmt clippy + - name: Run rustfmt + run: cargo fmt --check + - name: Run clippy + run: cargo clippy -- -D warnings + + test-and-build: + runs-on: ubuntu-latest + container: + image: rust:latest + + needs: rust-checks + + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v3 + with: + path: target/debug + key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-debug- + - name: Run tests + run: cargo test + - uses: actions/cache@v3 + with: + path: target/release + key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-release- + - name: Build shared object + run: cargo build-sbf From d7d1091ac8e5c04f1bfd5b4489f34673c2605f2b Mon Sep 17 00:00:00 2001 From: Babur Makhmudov Date: Wed, 18 Dec 2024 23:00:06 +0530 Subject: [PATCH 02/13] fix: CI, correct branch --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 95a7aa8..ec0f3d9 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -2,7 +2,7 @@ name: Magic Router Build on: pull_request: - branches: [ "main" ] + branches: [ "master" ] env: solana_version: v1.18.25 From e8f05df9fb34f399ed7325f01748ea0c5b2c65ea Mon Sep 17 00:00:00 2001 From: Babur Makhmudov Date: Wed, 18 Dec 2024 23:11:37 +0530 Subject: [PATCH 03/13] CI: fix order of steps and caching --- .github/workflows/build-and-test.yml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ec0f3d9..abded26 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -42,7 +42,6 @@ jobs: key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-cargo-debug- - solana-${{ runner.os }}-v0000-${{ env.solana_version }} - name: Install rustfmt and clippy run: rustup component add rustfmt clippy - name: Run rustfmt @@ -55,10 +54,23 @@ jobs: container: image: rust:latest - needs: rust-checks + needs: + - rust-checks + - install steps: - uses: actions/checkout@v4 + - uses: actions/cache@v3 + with: + path: + - target/release + - target/sbf-solana-solana + key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-release- + solana-${{ runner.os }}-v0000-${{ env.solana_version }} + - name: Build shared object + run: cargo build-sbf -- -Znext-lockfile-bump - uses: actions/cache@v3 with: path: target/debug @@ -67,11 +79,3 @@ jobs: ${{ runner.os }}-cargo-debug- - name: Run tests run: cargo test - - uses: actions/cache@v3 - with: - path: target/release - key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-release- - - name: Build shared object - run: cargo build-sbf From 8564008132cdd86b6c265a04f46040b36f360953 Mon Sep 17 00:00:00 2001 From: Babur Makhmudov Date: Wed, 18 Dec 2024 23:13:02 +0530 Subject: [PATCH 04/13] fix(ci): yml syntax --- .github/workflows/build-and-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index abded26..ff8674b 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -62,9 +62,9 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v3 with: - path: - - target/release - - target/sbf-solana-solana + path: | + target/release + target/sbf-solana-solana key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-cargo-release- From 3cfad146dfbb8980ca369267a77b2e108305cb18 Mon Sep 17 00:00:00 2001 From: Babur Makhmudov Date: Wed, 18 Dec 2024 23:16:39 +0530 Subject: [PATCH 05/13] fix(ci): restore solana cache --- .github/workflows/build-and-test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ff8674b..43a7fec 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -66,8 +66,9 @@ jobs: target/release target/sbf-solana-solana key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | + restore-keys: ${{ runner.os }}-cargo-release- + restore-keys: solana-${{ runner.os }}-v0000-${{ env.solana_version }} - name: Build shared object run: cargo build-sbf -- -Znext-lockfile-bump From f2d42758cb235373e3eec69e436a378287ebb9f7 Mon Sep 17 00:00:00 2001 From: Babur Makhmudov Date: Wed, 18 Dec 2024 23:18:41 +0530 Subject: [PATCH 06/13] CI: fix yml syntax --- .github/workflows/build-and-test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 43a7fec..87d49ce 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -66,10 +66,9 @@ jobs: target/release target/sbf-solana-solana key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} - restore-keys: - ${{ runner.os }}-cargo-release- - restore-keys: + restore-keys: | solana-${{ runner.os }}-v0000-${{ env.solana_version }} + ${{ runner.os }}-cargo-release- - name: Build shared object run: cargo build-sbf -- -Znext-lockfile-bump - uses: actions/cache@v3 From d2e722cf80f27c8364933f522fa478a121dbaaca Mon Sep 17 00:00:00 2001 From: Babur Makhmudov Date: Thu, 19 Dec 2024 10:26:57 +0530 Subject: [PATCH 07/13] ci: further experiments --- .github/workflows/build-and-test.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 87d49ce..3ccd716 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -36,9 +36,11 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: - path: target/debug + path: | + ~/.cargo/ + target/debug key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-cargo-debug- @@ -60,7 +62,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | target/release @@ -68,7 +70,6 @@ jobs: key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} restore-keys: | solana-${{ runner.os }}-v0000-${{ env.solana_version }} - ${{ runner.os }}-cargo-release- - name: Build shared object run: cargo build-sbf -- -Znext-lockfile-bump - uses: actions/cache@v3 From 1e1df2cfff1aa164662188db79ae52eac7f27463 Mon Sep 17 00:00:00 2001 From: Babur Makhmudov Date: Thu, 19 Dec 2024 10:35:07 +0530 Subject: [PATCH 08/13] CI: cache restoration --- .github/workflows/build-and-test.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 3ccd716..31aa49c 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -68,11 +68,15 @@ jobs: target/release target/sbf-solana-solana key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - solana-${{ runner.os }}-v0000-${{ env.solana_version }} + - uses: actions/cache@v4 + with: + path: | + ~/.cache/solana/ + ~/.local/share/solana/ + key: solana-${{ runner.os }}-v0000-${{ env.solana_version }} - name: Build shared object run: cargo build-sbf -- -Znext-lockfile-bump - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: target/debug key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }} From 5e272cd5079b321511081276bb10e6eabe753c53 Mon Sep 17 00:00:00 2001 From: Babur Makhmudov Date: Thu, 19 Dec 2024 10:36:01 +0530 Subject: [PATCH 09/13] fix: yml syntax --- .github/workflows/build-and-test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 31aa49c..f8f6d12 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -69,11 +69,11 @@ jobs: target/sbf-solana-solana key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} - uses: actions/cache@v4 - with: - path: | - ~/.cache/solana/ - ~/.local/share/solana/ - key: solana-${{ runner.os }}-v0000-${{ env.solana_version }} + with: + path: | + ~/.cache/solana/ + ~/.local/share/solana/ + key: solana-${{ runner.os }}-v0000-${{ env.solana_version }} - name: Build shared object run: cargo build-sbf -- -Znext-lockfile-bump - uses: actions/cache@v4 From c84dd96166a5601a58090b26b1f0d89f5e9e0b62 Mon Sep 17 00:00:00 2001 From: Babur Makhmudov Date: Thu, 19 Dec 2024 10:48:25 +0530 Subject: [PATCH 10/13] ci: experiments --- .github/workflows/build-and-test.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index f8f6d12..ad4700b 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -10,6 +10,8 @@ env: jobs: install: runs-on: ubuntu-latest + container: + image: rust:latest steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 @@ -69,6 +71,8 @@ jobs: target/sbf-solana-solana key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} - uses: actions/cache@v4 + name: cache solana cli + id: cache-solana with: path: | ~/.cache/solana/ @@ -78,7 +82,9 @@ jobs: run: cargo build-sbf -- -Znext-lockfile-bump - uses: actions/cache@v4 with: - path: target/debug + path: | + ~/.cargo/ + target/debug key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-cargo-debug- From 93215d64d480937a630e6c50004eba6aae8ff5c1 Mon Sep 17 00:00:00 2001 From: Babur Makhmudov Date: Thu, 19 Dec 2024 10:53:38 +0530 Subject: [PATCH 11/13] ci: add solana path setup --- .github/workflows/build-and-test.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ad4700b..c14ab09 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -64,6 +64,14 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/ + target/debug + key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-debug- - uses: actions/cache@v4 with: path: | @@ -78,15 +86,12 @@ jobs: ~/.cache/solana/ ~/.local/share/solana/ key: solana-${{ runner.os }}-v0000-${{ env.solana_version }} + - name: setup solana + run: | + export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" + solana --version + - name: Build shared object run: cargo build-sbf -- -Znext-lockfile-bump - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/ - target/debug - key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-debug- - name: Run tests run: cargo test From 119720b4166ff571c33b7543ac9982c13b66b758 Mon Sep 17 00:00:00 2001 From: Babur Makhmudov Date: Thu, 19 Dec 2024 10:58:42 +0530 Subject: [PATCH 12/13] fix ci --- .github/workflows/build-and-test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index c14ab09..ec68821 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -88,7 +88,8 @@ jobs: key: solana-${{ runner.os }}-v0000-${{ env.solana_version }} - name: setup solana run: | - export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" + export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH" + ls -lah $HOME solana --version - name: Build shared object From 75061cc5323e14140ecc6c498ba602ae1ac29e2b Mon Sep 17 00:00:00 2001 From: Babur Makhmudov Date: Thu, 19 Dec 2024 11:13:20 +0530 Subject: [PATCH 13/13] ci: solana path --- .github/workflows/build-and-test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ec68821..7b7f98a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -89,10 +89,11 @@ jobs: - name: setup solana run: | export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH" - ls -lah $HOME solana --version - name: Build shared object - run: cargo build-sbf -- -Znext-lockfile-bump + run: | + export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH" + cargo build-sbf -- -Znext-lockfile-bump - name: Run tests run: cargo test