Skip to content

Commit f3d5e88

Browse files
authored
Improve generated CI from feedback (#65)
1 parent 5818ca4 commit f3d5e88

File tree

22 files changed

+475
-175
lines changed

22 files changed

+475
-175
lines changed

.changeset/hot-suns-marry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-solana-program": patch
3+
---
4+
5+
Improve generated CI from feedback

scripts/snapshot.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ for (const projectName of projects) {
8282
// Lint and test clients.
8383
for (const client of CLIENTS) {
8484
if (`clients:${client}:test` in pkg.scripts) {
85+
await executeStep(`format ${client} client`, async () => {
86+
await $`pnpm clients:${client}:format`;
87+
});
8588
await executeStep(`lint ${client} client`, async () => {
8689
await $`pnpm clients:${client}:lint`;
8790
});

template/base/.github/actions/setup/action.yml.njk

Lines changed: 98 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,127 @@ name: Setup environment
33
inputs:
44
{% if programFramework === 'anchor' %}
55
anchor:
6-
description: The Anchor version to install
6+
description: The Anchor version to install. Skips if not provided.
7+
required: false
78
{% endif %}
8-
cache:
9-
description: Enable caching
10-
default: "true"
9+
cargo-cache-key:
10+
description: The key to cache cargo dependencies. Skips cargo caching if not provided.
11+
required: false
12+
cargo-cache-fallback-key:
13+
description: The fallback key to use when caching cargo dependencies. Default to not using a fallback key.
14+
required: false
15+
cargo-cache-local-key:
16+
description: The key to cache local cargo dependencies. Skips local cargo caching if not provided.
17+
required: false
18+
clippy:
19+
description: Install Clippy if `true`. Defaults to `false`.
20+
required: false
1121
node:
12-
description: The Node.js version to install
22+
description: The Node.js version to install. Required.
1323
required: true
24+
rustfmt:
25+
description: Install Rustfmt if `true`. Defaults to `false`.
26+
required: false
1427
solana:
15-
description: The Solana version to install
28+
description: The Solana version to install. Skips if not provided.
29+
required: false
1630

1731
runs:
18-
using: "composite"
32+
using: 'composite'
1933
steps:
2034
- name: Setup pnpm
2135
uses: pnpm/action-setup@v3
36+
2237
- name: Setup Node.js
2338
uses: actions/setup-node@v4
2439
with:
2540
node-version: {% raw %}${{ inputs.node }}{% endraw %}
26-
cache: "pnpm"
27-
- name: Install dependencies
41+
cache: 'pnpm'
42+
43+
- name: Install Dependencies
2844
run: pnpm install --frozen-lockfile
2945
shell: bash
46+
47+
- name: Set Environment Variables
48+
shell: bash
49+
run: pnpm zx ./scripts/ci/set-env.mjs
50+
51+
{% if solanaVersion === '2.0' %}
52+
- name: Install Protobuf Compiler (Temporary Workaround for Solana 2.0)
53+
if: {% raw %}${{ inputs.solana || inputs.rustfmt == 'true' || inputs.clippy == 'true' }}{% endraw %}
54+
shell: bash
55+
run: |
56+
sudo apt-get update
57+
sudo apt-get install -y protobuf-compiler
58+
{% endif %}
59+
60+
- name: Install Rustfmt
61+
if: {% raw %}${{ inputs.rustfmt == 'true' }}{% endraw %}
62+
uses: dtolnay/rust-toolchain@master
63+
with:
64+
toolchain: {% raw %}${{ env.TOOLCHAIN_FORMAT }}{% endraw %}
65+
components: rustfmt
66+
67+
- name: Install Clippy
68+
if: {% raw %}${{ inputs.clippy == 'true' }}{% endraw %}
69+
uses: dtolnay/rust-toolchain@master
70+
with:
71+
toolchain: {% raw %}${{ env.TOOLCHAIN_LINT }}{% endraw %}
72+
components: clippy
73+
3074
- name: Install Solana
31-
if: {% raw %}${{ inputs.solana != '' }}{% endraw %}
75+
if: {% raw %}${{ inputs.solana }}{% endraw %}
3276
uses: metaplex-foundation/actions/install-solana@v1
3377
with:
3478
version: {% raw %}${{ inputs.solana }}{% endraw %}
35-
cache: {% raw %}${{ inputs.cache }}{% endraw %}
79+
cache: true
80+
3681
{% if programFramework === 'anchor' %}
3782
- name: Install Anchor
3883
if: {% raw %}${{ inputs.anchor != '' }}{% endraw %}
3984
uses: metaplex-foundation/actions/install-anchor-cli@v1
4085
with:
4186
version: {% raw %}${{ inputs.anchor }}{% endraw %}
42-
cache: {% raw %}${{ inputs.cache }}{% endraw %}
87+
cache: true
4388
{% endif %}
89+
90+
- name: Cache Cargo Dependencies
91+
if: {% raw %}${{ inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }}{% endraw %}
92+
uses: actions/cache@v4
93+
with:
94+
path: |
95+
~/.cargo/bin/
96+
~/.cargo/registry/index/
97+
~/.cargo/registry/cache/
98+
~/.cargo/git/db/
99+
target/
100+
key: {% raw %}${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}{% endraw %}
101+
restore-keys: {% raw %}${{ runner.os }}-${{ inputs.cargo-cache-key }}{% endraw %}
102+
103+
- name: Cache Cargo Dependencies With Fallback
104+
if: {% raw %}${{ inputs.cargo-cache-key && inputs.cargo-cache-fallback-key }}{% endraw %}
105+
uses: actions/cache@v4
106+
with:
107+
path: |
108+
~/.cargo/bin/
109+
~/.cargo/registry/index/
110+
~/.cargo/registry/cache/
111+
~/.cargo/git/db/
112+
target/
113+
key: {% raw %}${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}{% endraw %}
114+
restore-keys: |
115+
{% raw %}${{ runner.os }}-${{ inputs.cargo-cache-key }}{% endraw %}
116+
{% raw %}${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}-${{ hashFiles('**/Cargo.lock') }}{% endraw %}
117+
{% raw %}${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}{% endraw %}
118+
119+
- name: Cache Local Cargo Dependencies
120+
if: {% raw %}${{ inputs.cargo-cache-local-key }}{% endraw %}
121+
uses: actions/cache@v4
122+
with:
123+
path: |
124+
.cargo/bin/
125+
.cargo/registry/index/
126+
.cargo/registry/cache/
127+
.cargo/git/db/
128+
key: {% raw %}${{ runner.os }}-${{ inputs.cargo-cache-local-key }}-${{ hashFiles('**/Cargo.lock') }}{% endraw %}
129+
restore-keys: {% raw %}${{ runner.os }}-${{ inputs.cargo-cache-local-key }}{% endraw %}

0 commit comments

Comments
 (0)