Skip to content

Commit 31c3eb2

Browse files
committed
Add setup-all action and use it in test workflow
1 parent 4666076 commit 31c3eb2

File tree

7 files changed

+166
-441
lines changed

7 files changed

+166
-441
lines changed

.github/actions/build-anchor/action.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ inputs:
55
description: "Whether to run tests"
66
required: false
77
default: "true"
8-
devnet:
9-
description: "Whether to build for devnet"
10-
required: false
11-
default: "false"
128
program:
139
description: "Program to build"
1410
required: true

.github/actions/run-tests/action.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,12 @@ runs:
1111
- uses: Woody4618/solana-github-action-workflow/.github/actions/extract-versions@main
1212
id: versions
1313

14-
- uses: Woody4618/solana-github-action-workflow/.github/actions/setup@main
15-
16-
- uses: Woody4618/solana-github-action-workflow/.github/actions/setup-solana@main
17-
18-
- uses: Woody4618/solana-github-action-workflow/.github/actions/setup-anchor@main
19-
with:
20-
anchor-version: ${{ env.ANCHOR_VERSION }}
21-
22-
- uses: actions/setup-node@v3
14+
- uses: Woody4618/solana-github-action-workflow/.github/actions/setup-all@main
2315
with:
24-
node-version: "18"
16+
solana-version: ${{ steps.versions.outputs.solana_version }}
17+
anchor-version: ${{ steps.versions.outputs.anchor_version }}
18+
verify-version: ${{ env.VERIFY_VERSION }}
19+
node-version: 18
2520

2621
- name: Cache node_modules
2722
uses: actions/cache@v3
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
name: "Setup All Development Tools"
2+
description: "Sets up Solana, Anchor, and verification tools with optional installations"
3+
4+
inputs:
5+
solana_version:
6+
description: "Solana version to install (leave empty to skip)"
7+
required: false
8+
default: ""
9+
anchor_version:
10+
description: "Anchor version to install (leave empty to skip)"
11+
required: false
12+
default: ""
13+
verify_version:
14+
description: "Solana verify version to install (leave empty to skip)"
15+
required: false
16+
default: ""
17+
node_version:
18+
description: "Node version to install (leave empty to skip)"
19+
required: false
20+
default: ""
21+
22+
runs:
23+
using: "composite"
24+
steps:
25+
- run: sudo apt-get update
26+
shell: bash
27+
- run: sudo apt-get install -y pkg-config build-essential libudev-dev
28+
shell: bash
29+
- run: git submodule update --init --recursive --depth 1
30+
shell: bash
31+
32+
- uses: actions/cache@v4
33+
if: inputs.solana_version != ''
34+
name: Cache Solana Tool Suite
35+
id: cache-solana
36+
with:
37+
path: |
38+
~/.cache/solana/
39+
~/.local/share/solana/
40+
key: solana-${{ runner.os }}-v0001-${{ env.SOLANA_VERSION }}
41+
42+
- name: Debug Solana Version Values
43+
if: inputs.solana_version != ''
44+
shell: bash
45+
run: |
46+
echo "=== Debug Solana Version Information ==="
47+
VERSION="${{ inputs.solana_version }}"
48+
echo "Using Solana version: $VERSION"
49+
echo "Cache key being used: solana-${{ runner.os }}-v0001-${{ env.SOLANA_VERSION }}"
50+
echo "========================="
51+
52+
- name: Install Solana
53+
shell: bash
54+
if: steps.cache-solana.outputs.cache-hit != 'true' && inputs.solana_version != ''
55+
run: |
56+
# Parse version numbers
57+
MAJOR=$(echo $SOLANA_VERSION | cut -d. -f1)
58+
MINOR=$(echo $SOLANA_VERSION | cut -d. -f2)
59+
PATCH=$(echo $SOLANA_VERSION | cut -d. -f3)
60+
61+
# Determine which URL to use based on version
62+
if [ "$MAJOR" -eq 1 ] && [ "$MINOR" -eq 18 ] && [ "$PATCH" -le 23 ]; then
63+
INSTALL_URL="https://release.solana.com/v${SOLANA_VERSION}/install"
64+
else
65+
INSTALL_URL="https://release.anza.xyz/v${SOLANA_VERSION}/install"
66+
fi
67+
68+
echo "Installing Solana from: $INSTALL_URL"
69+
sh -c "$(curl -sSfL $INSTALL_URL)"
70+
env:
71+
SOLANA_VERSION: ${{ env.SOLANA_VERSION }}
72+
73+
- name: Set Solana Path variables
74+
if: inputs.solana_version != ''
75+
run: echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
76+
shell: bash
77+
78+
- name: Create default keypair
79+
if: inputs.solana_version != ''
80+
run: solana-keygen new -s --no-bip39-passphrase --force
81+
shell: bash
82+
83+
- name: Set rpc connection to local host
84+
if: inputs.solana_version != ''
85+
run: solana config set --url localhost
86+
shell: bash
87+
88+
- name: Debug Version Values
89+
if: inputs.anchor_version != ''
90+
shell: bash
91+
run: |
92+
echo "=== Debug Version Information ==="
93+
VERSION="${{ inputs.anchor-version || env.ANCHOR_VERSION }}"
94+
echo "Using Anchor version: $VERSION"
95+
echo "Cache key being used: anchor-cli-${{ runner.os }}-v0003-$VERSION"
96+
echo "========================="
97+
98+
- uses: actions/cache@v4
99+
if: inputs.anchor_version != ''
100+
name: Cache Anchor Cli
101+
id: cache-anchor-cli
102+
with:
103+
path: |
104+
~/.cargo/bin/anchor
105+
key: anchor-cli-${{ runner.os }}-v0003-${{ inputs.anchor-version || env.ANCHOR_VERSION }}
106+
107+
- name: Install Anchor CLI
108+
shell: bash
109+
if: steps.cache-anchor-cli.outputs.cache-hit != 'true' && inputs.anchor_version != ''
110+
run: |
111+
VERSION="${{ inputs.anchor-version || env.ANCHOR_VERSION }}"
112+
echo "=== Installation Debug Info ==="
113+
echo "Installing Anchor version: $VERSION"
114+
echo "=== Starting Installation ==="
115+
cargo install --git https://github.com/coral-xyz/anchor --tag "v$VERSION" anchor-cli --force
116+
echo "=== Installation Complete ==="
117+
anchor --version
118+
119+
- name: Verify Anchor Installation
120+
if: inputs.anchor_version != ''
121+
shell: bash
122+
run: anchor --version
123+
124+
- name: Debug Version Values
125+
if: inputs.verify-version != ''
126+
shell: bash
127+
run: |
128+
echo "=== Debug Version Information ==="
129+
echo "Using solana-verify version: ${{ inputs.verify-version }}"
130+
echo "Cache key being used: solana-verify-${{ runner.os }}-v0001-${{ inputs.verify-version }}"
131+
echo "========================="
132+
133+
- uses: actions/cache@v4
134+
if: inputs.verify-version != ''
135+
name: Cache Solana Verify
136+
id: cache-solana-verify
137+
with:
138+
path: |
139+
~/.cargo/bin/solana-verify
140+
key: solana-verify-${{ runner.os }}-v0001-${{ inputs.verify-version }}
141+
142+
- name: Install Solana Verify
143+
if: steps.cache-solana-verify.outputs.cache-hit != 'true' && inputs.verify-version != ''
144+
shell: bash
145+
run: cargo install solana-verify --version ${{ inputs.verify-version }}
146+
147+
- name: Verify Installation
148+
if: inputs.verify-version != ''
149+
shell: bash
150+
run: solana-verify --version
151+
152+
- uses: actions/setup-node@v3
153+
if: inputs.node_version != ''
154+
with:
155+
node-version: ${{ inputs.node_version }}

.github/actions/setup-anchor/action.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,3 @@ runs:
4040
echo "=== Installation Complete ==="
4141
anchor --version
4242
43-
- uses: actions/cache@v4
44-
name: Cache Toml Cli
45-
id: cache-toml-cli
46-
with:
47-
path: |
48-
~/.cargo/bin/toml
49-
key: toml-cli-${{ runner.os }}-v0002
50-
- run: (cargo install toml-cli || true)
51-
if: steps.cache-toml-cli.outputs.cache-hit != 'true'
52-
shell: bash

.github/actions/setup/action.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ description: "Setup"
33
runs:
44
using: "composite"
55
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: git submodule update --init --recursive --depth 1
11-
shell: bash
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: git submodule update --init --recursive --depth 1
11+
shell: bash

0 commit comments

Comments
 (0)