-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
action.yml
156 lines (138 loc) · 4.99 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: 'ape-github-action'
author: 'ApeWorX Ltd.'
description: 'Run an ape command'
branding:
icon: 'check-circle'
color: 'green'
inputs:
python-version:
description: 'Override version of python used to run ape- default 3.10'
required: False
default: '3.10'
ape-version-pin:
description: 'Override version of eth-ape, can also use a `git+` prefixed value'
required: False
ape-plugins-list:
description: 'Space seperated list of plugins to install with relevant pinning applied'
required: False
default: ''
outputs:
ape-version:
description: 'The version of Ape installed'
runs:
using: 'composite'
steps:
- uses: actions/cache@v4
name: Compilers cache
with:
path: |
/home/runner/.solcx
/home/runner/.vvm/vyper-*
key: ${{ runner.os }}-compiler-cache
- uses: actions/cache@v4
name: Build cache
with:
path: |
${{ github.workspace }}/.build
key: ${{ runner.os }}-build-cache
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Set pip cache directory path
id: pip-cache-dir-path
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
shell: bash
- name: Determine ape version to use
id: determine-version
run: |
if [[ "${{ inputs.ape-version-pin }}" != "" && "${{ inputs.ape-version-pin }}" != "''" ]]; then
echo "ape-version=${{ inputs.ape-version-pin }}" >> $GITHUB_OUTPUT
else
latest_version=$(curl -s https://pypi.org/pypi/eth-ape/json | jq -r '.info.version')
echo "ape-version=${latest_version}" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Restore pip cache
uses: actions/cache@v4
id: pip-cache
with:
path: |
${{ steps.pip-cache-dir-path.outputs.dir }}
key: ${{ inputs.python-version }}-pip-${{ steps.determine-version.outputs.ape-version }}
- name: Install Ape
run: |
pip install --upgrade pip
if [[ "${{ steps.determine-version.outputs.ape-version }}" == git+* ]]
then
echo "INFO: Installing from a remote git version."
pip install ${{ steps.determine-version.outputs.ape-version }}
else
version_regex='^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'
if [[ ${{ steps.determine-version.outputs.ape-version }} =~ $version_regex ]]; then
# Allows for excluding `==` to `ape-version-pin`
echo "Installing with == prefix"
pip install eth-ape==${{ steps.determine-version.outputs.ape-version }}
else
echo "Installing using given constraints"
pip install eth-ape${{ steps.determine-version.outputs.ape-version }}
fi
fi
shell: bash
- name: Check ape-config.yaml exists
id: check-ape-config-yaml
uses: andstor/file-existence-action@v3
with:
files: 'ape-config.yaml'
- name: Check version specs in config
id: check-plugin-version-specs
run: |
if [[ "${{ steps.check-ape-config-yaml.outputs.files_exists }}" == "true" ]]; then
version_present=$(sed -n '/^plugins:/,/^[^ ]/{/version:/p;}' "ape-config.yaml" | grep -c version || true)
if [[ -z "${version_present}" ]]; then
echo "version_present=0" >> $GITHUB_OUTPUT
else
echo "version_present=1" >> $GITHUB_OUTPUT
fi
else
echo "version_present=0" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Install Plugins
run: |
if [[ "${{ steps.check-plugin-version-specs.outputs.version_present }}" == "1" ]] && [[ -z "${{ inputs.ape-plugins-list }}" ]]; then
plugins_value="."
elif [[ -z "${{ inputs.ape-plugins-list }}" ]]; then
plugins_value="--upgrade ."
else
plugins_value="${{ inputs.ape-plugins-list }}"
fi
ape plugins install $plugins_value
shell: bash
- name: Check requirments.txt exists
id: check-requirements-txt
uses: andstor/file-existence-action@v3
with:
files: 'requirements.txt'
- name: Install requirements.txt
run: pip install -r requirements.txt
shell: bash
if: steps.check-requirements-txt.outputs.files_exists == 'true'
- name: Ensure cache directories exist
shell: bash
run: |
# NOTE: Workaround for an unrepressible warning
# in the cache action:
# https://github.com/actions/cache/issues/1241
if [ ! -d "/home/runner/.solcx" ]; then
mkdir "/home/runner/.solcx"
echo "Solcx directory created."
fi
if [ ! -d "/home/runner/.vvm" ]; then
mkdir "/home/runner/.vvm"
echo "VVM directory created."
fi
if [ ! -d "${{ github.workspace }}/.build" ]; then
mkdir "${{ github.workspace }}/.build"
echo ".build directory created."
fi