|
1 | 1 | name: Setup |
2 | 2 | description: Common environment setup |
3 | 3 | inputs: |
4 | | - use-node: |
| 4 | + node: |
5 | 5 | description: Whether to set up node |
6 | 6 | required: false |
7 | | - default: 'true' |
8 | | - node-version: |
9 | | - description: Version of node to install (if use-node is true) |
10 | | - required: false |
11 | | - default: '24.x' |
12 | | - use-foundry: |
| 7 | + default: 'on' # 'off' | 'on' | <specific version> |
| 8 | + foundry: |
13 | 9 | description: Whether to set up Foundry |
14 | 10 | required: false |
15 | | - default: 'true' |
16 | | - foundry-version: |
17 | | - description: Version of Foundry to install (if use-foundry is true) |
18 | | - required: false |
19 | | - default: 'stable' |
20 | | - use-java: |
| 11 | + default: 'on' # 'off' | 'on' | <specific version> |
| 12 | + java: |
21 | 13 | description: Whether to set up Java |
22 | 14 | required: false |
23 | | - default: 'false' |
24 | | - java-version: |
25 | | - description: Version of Java to install (if use-java is true) |
26 | | - required: false |
27 | | - default: '21' |
28 | | - use-python: |
| 15 | + default: 'off' # 'off' | 'on' | <specific version> |
| 16 | + python: |
29 | 17 | description: Whether to set up Python |
30 | 18 | required: false |
31 | | - default: 'false' |
32 | | - python-version: |
33 | | - description: Version of Python to install (if use-python is true) |
34 | | - required: false |
35 | | - default: '3.13' |
| 19 | + default: 'off' # 'off' | 'on' | <specific version> |
36 | 20 | python-requirements: |
37 | | - description: Path to Python requirements file (if use-python is true) |
| 21 | + description: Path to Python requirements file (if python is true) |
38 | 22 | required: false |
39 | 23 | default: 'requirements.txt' |
40 | | - use-solc: |
| 24 | + solc: |
41 | 25 | description: Whether to set up solc |
42 | 26 | required: false |
43 | | - default: 'false' |
44 | | - solc-version: |
45 | | - description: Version of solc to install (if use-solc is true) |
46 | | - required: false |
47 | | - default: '0.8.27' |
| 27 | + default: 'off' # 'off' | 'on' | <specific version> |
| 28 | + |
| 29 | +env: |
| 30 | + NODE_DEFAULT_VERSION: "24.x" |
| 31 | + FOUNDRY_DEFAULT_VERSION: "stable" |
| 32 | + JAVA_DEFAULT_VERSION: "21" |
| 33 | + PYTHON_DEFAULT_VERSION: "3.13" |
| 34 | + SOLC_DEFAULT_VERSION: "0.8.27" |
48 | 35 |
|
49 | 36 | runs: |
50 | 37 | using: composite |
51 | 38 | steps: |
| 39 | + - id: versions |
| 40 | + run: | |
| 41 | + ( |
| 42 | + [[ "${{ inputs.node }}" = "on" ]] \ |
| 43 | + && echo "node=$NODE_DEFAULT_VERSION" \ |
| 44 | + || echo "node=${{ inputs.node }}" |
| 45 | + [[ "${{ inputs.foundry }}" = "on" ]] \ |
| 46 | + && echo "foundry=$FOUNDRY_DEFAULT_VERSION" \ |
| 47 | + || echo "foundry=${{ inputs.foundry }}" |
| 48 | + [[ "${{ inputs.java }}" = "on" ]] \ |
| 49 | + && echo "java=$JAVA_DEFAULT_VERSION" \ |
| 50 | + || echo "java=${{ inputs.java }}" |
| 51 | + [[ "${{ inputs.python }}" = "on" ]] \ |
| 52 | + && echo "python=$PYTHON_DEFAULT_VERSION" \ |
| 53 | + || echo "python=${{ inputs.python }}" |
| 54 | + [[ "${{ inputs.solc }}" = "on" ]] \ |
| 55 | + && echo "solc=$SOLC_DEFAULT_VERSION" \ |
| 56 | + || echo "solc=${{ inputs.solc }}" |
| 57 | + ) >> $GITHUB_OUTPUT |
| 58 | + shell: bash |
52 | 59 | # Node & npm setup |
53 | | - - name: Install Node (${{ inputs.node-version }}) |
54 | | - if: inputs.use-node == 'true' |
| 60 | + - name: Install Node (${{ steps.versions.outputs.node }}) |
| 61 | + if: inputs.node != 'off' |
55 | 62 | uses: actions/setup-node@v6 |
56 | 63 | with: |
57 | | - node-version: ${{ inputs.node-version }} |
| 64 | + node-version: ${{ steps.versions.outputs.node }} |
58 | 65 | - name: Try fetch node modules from cache |
59 | 66 | id: cache |
60 | | - if: inputs.use-node == 'true' |
| 67 | + if: inputs.node != 'off' |
61 | 68 | uses: actions/cache@v5 |
62 | 69 | with: |
63 | 70 | path: '**/node_modules' |
64 | | - key: npm-${{ inputs.node-version }}-${{ hashFiles('**/package-lock.json') }} |
| 71 | + key: npm-${{ steps.versions.outputs.node }}-${{ hashFiles('**/package-lock.json') }} |
65 | 72 | - name: Install dependencies |
66 | | - if: inputs.use-node == 'true' && steps.cache.outputs.cache-hit != 'true' |
| 73 | + if: inputs.node != 'off' && steps.cache.outputs.cache-hit != 'true' |
67 | 74 | shell: bash |
68 | 75 | run: npm ci |
69 | 76 | # Foundry setup |
70 | | - - name: Install Foundry (${{ inputs.foundry-version }}) |
71 | | - if: inputs.use-foundry == 'true' |
| 77 | + - name: Install Foundry (${{ steps.versions.outputs.foundry }}) |
| 78 | + if: inputs.foundry != 'off' |
72 | 79 | uses: foundry-rs/foundry-toolchain@v1 |
73 | 80 | with: |
74 | | - version: ${{ inputs.foundry-version }} |
| 81 | + version: ${{ steps.versions.outputs.foundry }} |
75 | 82 | # Java setup |
76 | | - - name: Install java (${{ inputs.java-version }}) |
77 | | - if: ${{ inputs.use-java == 'true' }} |
| 83 | + - name: Install java (${{ steps.versions.outputs.java }}) |
| 84 | + if: ${{ inputs.java != 'off' }} |
78 | 85 | uses: actions/setup-java@v5 |
79 | 86 | with: |
80 | 87 | distribution: temurin |
81 | | - java-version: ${{ inputs.java-version }} |
| 88 | + java-version: ${{ steps.versions.outputs.java }} |
82 | 89 | # Python setup |
83 | | - - name: Install python (${{ inputs.python-version }}) |
84 | | - if: inputs.use-python == 'true' |
| 90 | + - name: Install python (${{ steps.versions.outputs.python }}) |
| 91 | + if: inputs.python != 'off' |
85 | 92 | uses: actions/setup-python@v6 |
86 | 93 | with: |
87 | | - python-version: ${{ inputs.python-version }} |
| 94 | + python-version: ${{ steps.versions.outputs.python }} |
88 | 95 | cache: 'pip' |
89 | 96 | cache-dependency-path: ${{ inputs.python-requirements }} |
90 | 97 | - name: Install python packages |
91 | | - if: inputs.use-python == 'true' |
| 98 | + if: inputs.python != 'off' |
92 | 99 | shell: bash |
93 | 100 | run: pip install -r ${{ inputs.python-requirements }} |
94 | 101 | # Solc setup |
95 | | - - name: Install solc (${{ inputs.solc-version }}) |
96 | | - if: inputs.use-solc == 'true' |
| 102 | + - name: Install solc (${{ steps.versions.outputs.solc }}) |
| 103 | + if: inputs.solc != 'off' |
97 | 104 | shell: bash |
98 | 105 | run: | |
99 | | - wget -q https://github.com/argotorg/solidity/releases/download/v${{ inputs.solc-version }}/solc-static-linux |
| 106 | + wget -q https://github.com/argotorg/solidity/releases/download/v${{ steps.versions.outputs.solc }}/solc-static-linux |
100 | 107 | chmod +x solc-static-linux |
101 | 108 | sudo mv solc-static-linux /usr/local/bin/solc |
0 commit comments