Skip to content

Commit ad83688

Browse files
authored
Consolidate the github setup action (OpenZeppelin#6239)
1 parent a968789 commit ad83688

File tree

2 files changed

+102
-41
lines changed

2 files changed

+102
-41
lines changed

.github/actions/setup/action.yml

Lines changed: 94 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,108 @@
11
name: Setup
22
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>
328

429
runs:
530
using: composite
631
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.27"
59+
# Node & npm setup
60+
- name: Install Node (${{ steps.versions.outputs.node }})
61+
if: inputs.node != 'off'
62+
uses: actions/setup-node@v6
863
with:
9-
node-version: 24.x
10-
- uses: actions/cache@v5
64+
node-version: ${{ steps.versions.outputs.node }}
65+
- name: Try fetch node modules from cache
1166
id: cache
67+
if: inputs.node != 'off'
68+
uses: actions/cache@v5
1269
with:
1370
path: '**/node_modules'
14-
key: npm-v3-${{ hashFiles('**/package-lock.json') }}
71+
key: npm-${{ steps.versions.outputs.node }}-${{ hashFiles('**/package-lock.json') }}
1572
- name: Install dependencies
16-
run: npm ci
73+
if: inputs.node != 'off' && steps.cache.outputs.cache-hit != 'true'
1774
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'
2079
uses: foundry-rs/foundry-toolchain@v1
2180
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

.github/workflows/formal-verification.yml

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ on:
99
- labeled
1010
workflow_dispatch: {}
1111

12-
env:
13-
PIP_VERSION: '3.11'
14-
JAVA_VERSION: '11'
15-
SOLC_VERSION: '0.8.27'
16-
1712
concurrency: ${{ github.workflow }}-${{ github.ref }}
1813

1914
jobs:
@@ -26,13 +21,16 @@ jobs:
2621

2722
verify:
2823
runs-on: ubuntu-latest
29-
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'formal-verification')
24+
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'formal-verification') || contains(github.event.pull_request.labels.*.name, 'formal-verification-force-all')
3025
steps:
3126
- uses: actions/checkout@v6
32-
with:
33-
fetch-depth: 0
3427
- name: Set up environment
3528
uses: ./.github/actions/setup
29+
with:
30+
solc: 'on'
31+
java: 'on'
32+
python: 'on'
33+
python-requirements: 'fv-requirements.txt'
3634
- name: identify specs that need to be run
3735
id: arguments
3836
run: |
@@ -43,24 +41,6 @@ jobs:
4341
RESULT='--all'
4442
fi
4543
echo "result=$RESULT" >> "$GITHUB_OUTPUT"
46-
- name: Install python
47-
uses: actions/setup-python@v6
48-
with:
49-
python-version: ${{ env.PIP_VERSION }}
50-
cache: 'pip'
51-
cache-dependency-path: 'fv-requirements.txt'
52-
- name: Install python packages
53-
run: pip install -r fv-requirements.txt
54-
- name: Install java
55-
uses: actions/setup-java@v5
56-
with:
57-
distribution: temurin
58-
java-version: ${{ env.JAVA_VERSION }}
59-
- name: Install solc
60-
run: |
61-
wget https://github.com/ethereum/solidity/releases/download/v${{ env.SOLC_VERSION }}/solc-static-linux
62-
sudo mv solc-static-linux /usr/local/bin/solc
63-
chmod +x /usr/local/bin/solc
6444
- name: Verify specification
6545
run: |
6646
make -C fv apply
@@ -74,14 +54,9 @@ jobs:
7454
- uses: actions/checkout@v6
7555
- name: Set up environment
7656
uses: ./.github/actions/setup
77-
- name: Install python
78-
uses: actions/setup-python@v6
7957
with:
80-
python-version: ${{ env.PIP_VERSION }}
81-
cache: 'pip'
82-
cache-dependency-path: 'fv-requirements.txt'
83-
- name: Install python packages
84-
run: pip install -r fv-requirements.txt
58+
python: 'on'
59+
python-requirements: 'fv-requirements.txt'
8560
- name: Run Halmos
8661
run: halmos --match-test '^symbolic|^testSymbolic' -vv
8762
env:

0 commit comments

Comments
 (0)