@@ -3,41 +3,127 @@ name: Setup environment
3
3
inputs:
4
4
{% if programFramework == = ' anchor' %}
5
5
anchor:
6
- description: The Anchor version to install
6
+ description: The Anchor version to install. Skips if not provided.
7
+ required: false
7
8
{% 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
11
21
node:
12
- description: The Node.js version to install
22
+ description: The Node.js version to install. Required.
13
23
required: true
24
+ rustfmt:
25
+ description: Install Rustfmt if `true`. Defaults to `false`.
26
+ required: false
14
27
solana:
15
- description: The Solana version to install
28
+ description: The Solana version to install. Skips if not provided.
29
+ required: false
16
30
17
31
runs:
18
- using: " composite"
32
+ using: ' composite'
19
33
steps:
20
34
- name: Setup pnpm
21
35
uses: pnpm/action-setup@v3
36
+
22
37
- name: Setup Node.js
23
38
uses: actions/setup-node@v4
24
39
with:
25
40
node-version: {% raw %} ${{ inputs.node }}{% endraw %}
26
- cache: "pnpm"
27
- - name: Install dependencies
41
+ cache: 'pnpm'
42
+
43
+ - name: Install Dependencies
28
44
run: pnpm install --frozen-lockfile
29
45
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
+
30
74
- name: Install Solana
31
- if: {% raw %} ${{ inputs.solana != '' }}{% endraw %}
75
+ if: {% raw %} ${{ inputs.solana }}{% endraw %}
32
76
uses: metaplex-foundation/actions/install-solana@v1
33
77
with:
34
78
version: {% raw %} ${{ inputs.solana }}{% endraw %}
35
- cache: {% raw %} ${{ inputs.cache }}{% endraw %}
79
+ cache: true
80
+
36
81
{% if programFramework == = ' anchor' %}
37
82
- name: Install Anchor
38
83
if: {% raw %} ${{ inputs.anchor != '' }}{% endraw %}
39
84
uses: metaplex-foundation/actions/install-anchor-cli@v1
40
85
with:
41
86
version: {% raw %} ${{ inputs.anchor }}{% endraw %}
42
- cache: {% raw %} ${{ inputs.cache }} {% endraw %}
87
+ cache: true
43
88
{% 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