Skip to content

Commit 319f39a

Browse files
authored
Initial tuktuk buildout (#1) (#2)
1 parent 502beb0 commit 319f39a

File tree

172 files changed

+44864
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+44864
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: "Upload BPF"
2+
description: "Uploads an anchor program as a bpf"
3+
inputs:
4+
devnet:
5+
description: "Whether to use devnet feature"
6+
required: false
7+
default: "false"
8+
testing:
9+
description: "Whether to use devnet feature"
10+
required: false
11+
default: "false"
12+
network:
13+
description: "The Solana network"
14+
required: true
15+
default: "devnet"
16+
program:
17+
description: "The program to build and upload"
18+
required: true
19+
program-id:
20+
description: "The program id of the program we are uploading"
21+
required: true
22+
keypair:
23+
description: "The keypair to use for deploys"
24+
required: true
25+
buffer-authority:
26+
description: "The buffer authority to set"
27+
required: true
28+
outputs:
29+
buffer:
30+
description: "The buffer address"
31+
value: ${{ steps.buffer-deploy-store.outputs.BUFFER }}
32+
idl-buffer:
33+
description: "The idl buffer address."
34+
value: ${{ steps.buffer-deploy-store.outputs.IDL_BUFFER }}
35+
36+
runs:
37+
using: "composite"
38+
steps:
39+
- uses: ./.github/actions/setup/
40+
- uses: ./.github/actions/setup-anchor/
41+
with:
42+
node-version: ${{ env.NODE_VERSION }}
43+
- run: echo "$DEPLOY_KEYPAIR" > ./deploy-keypair.json && chmod 600 ./deploy-keypair.json
44+
shell: bash
45+
env:
46+
DEPLOY_KEYPAIR: ${{ inputs.keypair }}
47+
working-directory: solana-programs
48+
- run: solana-keygen new -s -o keyp --no-bip39-passphrase
49+
working-directory: solana-programs
50+
shell: bash
51+
- run: ls -l ./target/deploy/
52+
shell: bash
53+
working-directory: solana-programs
54+
- name: Buffer Deploy
55+
if: steps.cache-buffer.outputs.cache-hit != 'true'
56+
id: buffer-deploy
57+
uses: nick-invision/retry@v2
58+
with:
59+
timeout_minutes: 30
60+
max_attempts: 10
61+
shell: bash
62+
command: cd solana-programs && solana program write-buffer --max-sign-attempts 50 --with-compute-unit-price 100000 --use-rpc --buffer ./keyp -k ./deploy-keypair.json ./target/deploy/$PROGRAM.so -u $NETWORK > ./buffer.out
63+
env:
64+
NETWORK: ${{ inputs.network }}
65+
PROGRAM: ${{ inputs.program }}
66+
- name: IDL Buffer Deploy
67+
uses: nick-invision/retry@v2
68+
id: idl-buffer-deploy
69+
if: steps.cache-buffer.outputs.cache-hit != 'true'
70+
with:
71+
timeout_minutes: 10
72+
max_attempts: 50
73+
shell: bash
74+
command: cd solana-programs && ~/.cargo/bin/anchor idl write-buffer $PROGRAM_ID --filepath ./target/idl/$PROGRAM.json --provider.cluster $NETWORK --provider.wallet ./deploy-keypair.json > idl-buffer.out
75+
env:
76+
PROGRAM_ID: ${{ inputs.program-id }}
77+
PROGRAM: ${{ inputs.program }}
78+
NETWORK: ${{ inputs.network }}
79+
- name: Buffer Deploy Store
80+
shell: bash
81+
working-directory: solana-programs
82+
id: buffer-deploy-store
83+
run: |
84+
echo "BUFFER=$(cat buffer.out | sed 's/Buffer: //g' | xargs echo -n)" >> $GITHUB_OUTPUT
85+
echo "IDL_BUFFER=$(tail -n 1 idl-buffer.out | sed 's/Idl buffer created: //g' | xargs echo -n)" >> $GITHUB_OUTPUT
86+
- run: echo "The buffer is ${{ steps.buffer-deploy-store.outputs.BUFFER }}"
87+
shell: bash
88+
working-directory: solana-programs
89+
- run: echo "the idl buffer is ${{ steps.buffer-deploy-store.outputs.IDL_BUFFER }}"
90+
shell: bash
91+
working-directory: solana-programs
92+
- name: Transfer idl buffer to authority
93+
uses: nick-invision/retry@v2
94+
if: steps.cache-buffer.outputs.cache-hit != 'true'
95+
with:
96+
timeout_minutes: 10
97+
max_attempts: 50
98+
shell: bash
99+
command: cd solana-programs && anchor idl set-authority $IDL_BUFFER --provider.cluster $NETWORK --program-id $PROGRAM_ID --new-authority $AUTHORITY --provider.wallet ./deploy-keypair.json
100+
env:
101+
IDL_BUFFER: ${{ steps.buffer-deploy-store.outputs.IDL_BUFFER }}
102+
AUTHORITY: ${{ inputs.buffer-authority }}
103+
NETWORK: ${{ inputs.network }}
104+
PROGRAM_ID: ${{ inputs.program-id }}
105+
- name: Transfer buffer to authority
106+
uses: nick-invision/retry@v2
107+
if: steps.cache-buffer.outputs.cache-hit != 'true'
108+
with:
109+
timeout_minutes: 10
110+
max_attempts: 50
111+
shell: bash
112+
command: cd solana-programs && solana program set-buffer-authority $BUFFER -k ./deploy-keypair.json --new-buffer-authority $AUTHORITY -u $NETWORK
113+
env:
114+
BUFFER: ${{ steps.buffer-deploy-store.outputs.BUFFER }}
115+
AUTHORITY: ${{ inputs.buffer-authority }}
116+
NETWORK: ${{ inputs.network }}
117+
- run: rm ./deploy-keypair.json
118+
shell: bash
119+
if: always()
120+
working-directory: solana-programs
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "Setup Anchor"
2+
description: "Setup Anchor"
3+
inputs:
4+
devnet:
5+
description: "Whether to use devnet feature"
6+
required: false
7+
default: "false"
8+
testing:
9+
description: "Whether to use devnet feature"
10+
required: false
11+
default: "false"
12+
program:
13+
description: "The program to build"
14+
required: false
15+
runs:
16+
using: "composite"
17+
steps:
18+
- uses: ./.github/actions/setup/
19+
- uses: ./.github/actions/setup-anchor/
20+
with:
21+
node-version: ${{ env.NODE_VERSION }}
22+
- uses: actions/cache@v2
23+
name: Cache Cargo registry + index
24+
id: cache-cargo-registry
25+
with:
26+
path: |
27+
~/.cargo/bin/
28+
~/.cargo/registry/index/
29+
~/.cargo/registry/cache/
30+
~/.cargo/git/db/
31+
key: cargo-${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
32+
- name: Cache Anchor Build
33+
uses: actions/cache@v2
34+
id: cache-anchor-build
35+
with:
36+
path: |
37+
./solana-programs/target/
38+
key: build-${{ runner.os }}-${{env.ANCHOR_VERSION}}-${{env.ANCHOR_SHA}}-v0003-${{ inputs.devnet }}-${{ inputs.testing }}-${{ hashFiles('./solana-programs/programs/**/**') }}-${{ inputs.program }}
39+
- run: ${{ inputs.testing == 'true' && 'TESTING=true' || '' }} ~/.cargo/bin/anchor build ${{ (inputs.program != '' && '-p') || '' }} ${{ inputs.program || '' }} ${{ inputs.devnet == 'true' && '-- --features devnet' || '' }}
40+
if: steps.cache-anchor-build.outputs.cache-hit != 'true'
41+
shell: bash
42+
working-directory: solana-programs
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: "Build Verified"
2+
description: "Builds an Anchor Program using solana-verify"
3+
inputs:
4+
devnet:
5+
description: "Whether to use devnet feature"
6+
required: false
7+
default: "false"
8+
testing:
9+
description: "Whether to use devnet feature"
10+
required: false
11+
default: "false"
12+
program:
13+
description: "The program to build and upload"
14+
required: true
15+
program-id:
16+
description: "The program id of the program we are uploading"
17+
required: true
18+
19+
runs:
20+
using: "composite"
21+
steps:
22+
- uses: ./.github/actions/setup/
23+
- uses: ./.github/actions/setup-anchor/
24+
with:
25+
node-version: ${{ env.NODE_VERSION }}
26+
- uses: actions/cache@v2
27+
name: Cache Cargo registry + index
28+
id: cache-cargo-registry
29+
with:
30+
path: |
31+
~/.cargo/registry/index/
32+
~/.cargo/registry/cache/
33+
~/.cargo/git/db/
34+
key: cargo-${{ runner.os }}-v0001-${{ hashFiles('**/Cargo.lock') }}
35+
- uses: actions/cache@v2
36+
name: Cache Solana Verify
37+
id: cache-solana-verify
38+
with:
39+
path: |
40+
~/.cargo/bin/solana-verify
41+
key: cargo-${{ runner.os }}-solana-verify
42+
- run: cargo install solana-verify --locked
43+
if: steps.cache-solana-verify.outputs.cache-hit != 'true'
44+
shell: bash
45+
- run: ${{ inputs.testing == 'true' && 'TESTING=true' || '' }} ~/.cargo/bin/solana-verify build --library-name $PROGRAM ${{ inputs.devnet == 'true' && '-- --features devnet' || '' }}
46+
shell: bash
47+
working-directory: solana-programs
48+
env:
49+
PROGRAM: ${{ inputs.program }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Setup Anchor"
2+
description: "Setup Anchor"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- uses: ./.github/actions/setup/
7+
- uses: ./.github/actions/setup-solana/
8+
- uses: actions/cache@v2
9+
name: Cache Anchor Cli
10+
id: cache-anchor-cli
11+
with:
12+
path: |
13+
~/.cargo/bin/anchor
14+
key: anchor-cli-${{ runner.os }}-v0003-${{ env.ANCHOR_VERSION }}-${{ env.ANCHOR_SHA }}
15+
# if ANCHOR_VERSION is 0, then install the anchor-cli from source
16+
- run: if [ $ANCHOR_VERSION -eq 0 ]; then cargo install --git https://github.com/coral-xyz/anchor --rev $ANCHOR_SHA anchor-cli --locked --force; else cargo install --git https://github.com/coral-xyz/anchor --tag "v$ANCHOR_VERSION" anchor-cli --locked; fi
17+
shell: bash
18+
if: steps.cache-anchor-cli.outputs.cache-hit != 'true'
19+
- uses: actions/cache@v2
20+
name: Cache Toml Cli
21+
id: cache-toml-cli
22+
with:
23+
path: |
24+
~/.cargo/bin/toml
25+
key: toml-cli-${{ runner.os }}-v0002
26+
- run: (cargo install toml-cli || true)
27+
if: steps.cache-toml-cli.outputs.cache-hit != 'true'
28+
shell: bash
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "Setup Solana"
2+
description: "Setup Solana"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- uses: actions/cache@v2
7+
name: Cache Solana Tool Suite
8+
id: cache-solana
9+
with:
10+
path: |
11+
~/.cache/solana/
12+
~/.local/share/solana/
13+
key: solana-${{ runner.os }}-v0000-${{ env.SOLANA_CLI_VERSION }}
14+
- run: sh -c "$(curl -sSfL https://release.solana.com/v${{ env.SOLANA_CLI_VERSION }}/install)"
15+
shell: bash
16+
if: steps.cache-solana.outputs.cache-hit != 'true'
17+
- run: echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
18+
shell: bash
19+
- run: solana-keygen new -s --no-bip39-passphrase --force
20+
shell: bash
21+
- run: solana config set --url localhost
22+
shell: bash
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "Setup ts"
2+
description: "Setup ts"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- uses: actions/setup-node@v2
7+
with:
8+
node-version: ${{ env.NODE_VERSION }}
9+
- uses: actions/cache@v2
10+
name: Cache Typescript node_modules
11+
id: cache-typescript-node-modules
12+
with:
13+
path: |
14+
./solana-programs/node_modules/
15+
key: node-modules-${{ runner.os }}-v0000-${{ env.NODE_VERSION }}-${{ hashFiles('./yarn.lock') }}-${{ hashFiles('./**/*/package.json') }}
16+
- run: corepack enable
17+
shell: bash
18+
working-directory: solana-programs
19+
- run: yarn
20+
shell: bash
21+
working-directory: solana-programs
22+
if: steps.cache-typescript-node-modules.outputs.cache-hit != 'true'
23+
- run: yarn run build
24+
shell: bash
25+
working-directory: solana-programs

.github/actions/setup/action.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "Setup"
2+
description: "Setup"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- run: sudo apt-get update
7+
shell: bash
8+
- run: sudo apt-get install -y pkg-config build-essential libudev-dev
9+
shell: bash
10+
- run: echo "ANCHOR_VERSION=0" >> $GITHUB_ENV
11+
shell: bash
12+
- run: echo "ANCHOR_SHA=98396c0aeffb4745ab08fb9f45e0d31ad0bd1402" >> $GITHUB_ENV
13+
shell: bash
14+
- run: git submodule update --init --recursive --depth 1
15+
shell: bash
16+
- name: Install Protoc
17+
uses: arduino/setup-protoc@v3
18+
- uses: dtolnay/rust-toolchain@stable
19+
with:
20+
toolchain: 1.80.1
21+
- uses: actions/cache@v3
22+
with:
23+
path: |
24+
~/.rustup/toolchains
25+
~/.rustup/update-hashes
26+
~/.rustup/settings.toml
27+
key: rust-components-${{ runner.os }}-${{ hashFiles('**/rust-toolchain', '**/rust-toolchain.toml') }}
28+
- run: rustup component add rustfmt
29+
shell: bash
30+
- run: rustup component add clippy
31+
shell: bash

0 commit comments

Comments
 (0)