Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add program and all extra steps #13

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

joncinque
Copy link
Contributor

@joncinque joncinque commented Dec 18, 2024

Problem

The token program now lives in its program-specific repo, but no part of it is being exercised by CI.

Summary of changes

Integrate the token program properly into CI. This includes:

  • add it to the Cargo workspace, and removing spl-token-client, since it's currently empty
  • run lint / format / test on the program
  • run spellcheck / audit / semver checks on the Rust packages
  • move rust scripts to scripts/rust and make them reusable
  • update to Solana 2.1 and proper rust toolchains
  • move js scripts to scripts/js

#### Problem

The token program now lives in its program-specific repo, but no part of
it is being exercised by CI.

#### Summary of changes

Integrate the token program properly into CI. This includes:

* add it to the Cargo workspace, and removing spl-token-client, since
  it's currently empty
* run lint / format / test on the program
* run spellcheck / audit / semver checks on the Rust packages
* move rust scripts to `scripts/rust` and make them reusable
* update to Solana 2.1 and proper rust toolchains
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 8ff7d1e..46166f3 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -142,10 +142,40 @@ jobs:
           git status --porcelain
           test -z "$(git status --porcelain)"

+  build_program:
+    name: Build Program
+    runs-on: ubuntu-latest
+    needs: format_and_lint_program
+    steps:
+      - name: Git Checkout
+        uses: actions/checkout@v4
+
+      - name: Setup Environment
+        uses: ./.github/actions/setup
+        with:
+          cargo-cache-key: cargo-build-program
+          solana: true
+
+      - name: Build
+        run: pnpm programs:build
+
+      - name: Upload Program Builds
+        uses: actions/upload-artifact@v4
+        with:
+          name: program-builds
+          path: ./target/deploy/*.so
+          if-no-files-found: error
+
+      - name: Save Program Builds For Client Jobs
+        uses: actions/cache/save@v4
+        with:
+          path: ./**/*.so
+          key: ${{ runner.os }}-builds-${{ github.sha }}
+
   test_client_js:
     name: Test Client JS
     runs-on: ubuntu-latest
-    needs: format_and_lint_client_js
+    needs: [format_and_lint_client_js, build_program]
     steps:
       - name: Git Checkout
         uses: actions/checkout@v4
@@ -155,6 +185,12 @@ jobs:
         with:
           solana: true

+      - name: Restore Program Builds
+        uses: actions/cache/restore@v4
+        with:
+          path: ./**/*.so
+          key: ${{ runner.os }}-builds-${{ github.sha }}
+
       - name: Test Client JS
         run: pnpm clients:js:test

@@ -187,7 +223,7 @@ jobs:
       - name: Setup Environment
         uses: ./.github/actions/setup
         with:
-          cargo-cache-key: cargo-rust-client
+          cargo-cache-key: cargo-test-program
           solana: true

       - name: Test
diff --git a/package.json b/package.json
index d9827dc..9a3d3fb 100644
--- a/package.json
+++ b/package.json
@@ -12,10 +12,10 @@
     "validator:start": "zx ./scripts/start-validator.mjs",
     "validator:restart": "pnpm validator:start --restart",
     "validator:stop": "zx ./scripts/stop-validator.mjs",
-    "clients:js:format": "zx ./scripts/client/format-js.mjs",
-    "clients:js:lint": "zx ./scripts/client/lint-js.mjs",
-    "clients:js:publish": "zx ./scripts/client/publish-js.mjs",
-    "clients:js:test": "zx ./scripts/client/test-js.mjs",
+    "clients:js:format": "zx ./scripts/js/format.mjs",
+    "clients:js:lint": "zx ./scripts/js/lint.mjs",
+    "clients:js:publish": "zx ./scripts/js/publish.mjs",
+    "clients:js:test": "zx ./scripts/js/test.mjs",
     "clients:rust:format": "zx ./scripts/rust/format.mjs clients/rust",
     "clients:rust:lint": "zx ./scripts/rust/lint.mjs clients/rust",
     "clients:rust:publish": "zx ./scripts/rust/publish.mjs clients/rust",
diff --git a/program/Cargo.toml b/program/Cargo.toml
index 95f5e97..cfff306 100644
--- a/program/Cargo.toml
+++ b/program/Cargo.toml
@@ -35,3 +35,6 @@ targets = ["x86_64-unknown-linux-gnu"]

 [lints]
 workspace = true
+
+[package.metadata.solana]
+program-id = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
diff --git a/scripts/client/format-js.mjs b/scripts/js/format.mjs
similarity index 100%
rename from scripts/client/format-js.mjs
rename to scripts/js/format.mjs
diff --git a/scripts/client/lint-js.mjs b/scripts/js/lint.mjs
similarity index 100%
rename from scripts/client/lint-js.mjs
rename to scripts/js/lint.mjs
diff --git a/scripts/client/publish-js.mjs b/scripts/js/publish.mjs
similarity index 100%
rename from scripts/client/publish-js.mjs
rename to scripts/js/publish.mjs
diff --git a/scripts/client/test-js.mjs b/scripts/js/test.mjs
similarity index 100%
rename from scripts/client/test-js.mjs
rename to scripts/js/test.mjs
@joncinque joncinque merged commit f8bbbb7 into solana-program:main Dec 18, 2024
11 checks passed
@joncinque joncinque deleted the programci branch December 18, 2024 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants