-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
97 lines (97 loc) · 3.62 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: 'Setup Solana SDK'
description: 'Setup the Solana SDK and the rust toolchain to build and test smart contracts'
inputs:
solana-version:
description: "Version of the solana sdk to install (eg. 'v1.16.18'). Avoid symbolic channels (stable, beta and edge) as cache won't get invalidated properly"
required: true
anchor-version:
description: "Optional version of Anchor CLI to install (eg. 'v0.28.0')"
rust-version:
description: "Version of rust to install (eg. 'stable'). Will install fmt and clippy"
default: 'stable'
required: true
setup-node:
description: 'Optional version of node.js to install (eg. 19). Latest yarn, mocha, ts-mocha and typescript is also installed. If enabled it will also install dependencies with yarn'
rust-shared-key:
description: 'To share the rust dependencies cache among jobs, provide a common key here.'
workspace:
description: "Optional path to the rust workspace. Default: '.'"
default: '.'
skip-yarn:
description: "Set to true to disable automatic dependency installation with yarn. Default: 'false'"
default: 'false'
outputs:
rust-cache-hit:
description: "'true' if rust cache has been restored"
value: ${{ steps.rust-cache.outputs.cache-hit }}
runs:
using: "composite"
steps:
- uses: actions/checkout@v3
- name: Install dependency
run: |
sudo apt-get update
sudo apt-get install -y pkg-config build-essential libudev-dev
shell: bash
- uses: dtolnay/rust-toolchain@master
with:
components: rustfmt, clippy
toolchain: ${{ inputs.rust-version }}
- name: Rust Cache
id: rust-cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
shared-key: ${{ inputs.rust-shared-key }}
key: solana-${{ inputs.solana-version }}
workspaces: ${{ inputs.workspace }}
- uses: actions/cache@v3
name: Cache Solana Tool Suite
id: cache-solana
with:
path: |
~/.cache/solana/
~/.local/share/solana/
key: solana-${{ runner.os }}-v0001-${{ inputs.solana-version }}
- name: Cache Node Modules
if: inputs.setup-node != null
uses: actions/cache@v3
id: cache-node-modules
with:
path: |
~/.npm/
~/.yarn/
${{ inputs.workspace }}/node_modules
key: npm-${{ runner.os }}-v0001-${{ hashFiles('**/package-lock.json') }}
- uses: actions/setup-node@v3
with:
node-version: ${{ inputs.setup-node }}
if: inputs.setup-node != null
- name: Install global npm dependencies
if: inputs.setup-node != null
run: |
npm install -g yarn
npm install -g mocha
npm install -g ts-mocha
npm install -g typescript
shell: bash
- name: Install Solana
if: steps.cache-solana.outputs.cache-hit != 'true'
run: |
sh -c "$(curl -sSfL https://release.solana.com/${{ inputs.solana-version }}/install)"
shell: bash
- name: Enable Solana bins
run: |
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
shell: bash
- name: Install Anchor
if: inputs.anchor-version != null
run: |
cargo install --git https://github.com/coral-xyz/anchor --tag ${{ inputs.anchor-version }} anchor-cli --locked
shell: bash
- name: yarn install
if: inputs.setup-node != null && inputs.skip-yarn == 'false'
run: |
cd ${{ inputs.workspace }}
yarn install
shell: bash