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