-
Notifications
You must be signed in to change notification settings - Fork 2
225 lines (213 loc) · 7.84 KB
/
ci.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: "CI"
on:
pull_request:
branches:
- main
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: open-turo/actions-gha/lint@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fast:
name: Test / Fast
runs-on: ubuntu-latest
steps:
- uses: open-turo/actions-gha/test@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
TEST_FAST: "1"
NO_TEST_JAVA: "1"
# Runs unit tests
test:
name: Test
needs: [lint, fast]
runs-on: ubuntu-latest
steps:
- uses: open-turo/actions-gha/test@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
NO_TEST_JAVA: "1"
# Build and run the action from this repo to test full functionality
action:
name: Test / Inputs
needs: [lint, fast]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/action-test
with:
use-versions: false
env:
IGNORE_INSTALLED: "true"
# Build and run the action from this repo to test full functionality
action-versions:
name: Test / Version files
needs: [lint, fast]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/action-test
with:
use-versions: true
env:
IGNORE_INSTALLED: "true"
action-asdf:
name: Test / Pre-installed
needs: [lint, fast]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
# Create .tool-versions for asdf
{
echo "golang 1.17.6"
echo "java temurin-17.0.2+8"
echo "nodejs 16.13.2"
echo "python 3.10.2"
echo "terraform 1.1.5"
} > .tool-versions
- uses: asdf-vm/actions/install@v2
- run: |
# Test versions
go version | grep "1.17.6"
java -version 2>&1 | grep "17.0.2"
node --version | grep "16.13.2"
python --version || grep "3.10.2"
terraform --version | grep "1.1.5"
- uses: ./.github/actions/action-test
env:
TEST_PRE_INSTALL: "true"
- run: |
# Test versions again
go version | grep "1.17.6"
java -version 2>&1 | grep "17.0.2"
node --version | grep "16.13.2"
python --version || grep "3.10.2"
terraform --version | grep "1.1.5"
# Build and run the action from this repo to test full functionality
action-python-system:
name: Test / Regresstion / System python
# needs: [lint] # TODO: Reinstate this after done with fast testing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Debug system python
# if: "false" # Comment this out for add'l debug
run: |
echo "::debug:: $(python --version)"
- name: Set python version
run: echo "3.10.4" > .python-version
- uses: ./
- name: Debug configured python
# if: "false" # Comment this out for add'l debug
run: |
echo "::debug::python --version; $(python --version || true)"
echo "::debug::pip --version: $(pip --version || true)"
- run: |
# Test versions
python --version || exit 10
pip --version || exit 11
# Build and run the action from this repo to test full functionality
action-regression:
name: Test / Regression / pyenv
# needs: [lint] # TODO: Reinstate this after done with fast testing
runs-on: ubuntu-latest
env:
DESIRED_PYTHON_VERSION: 3.9.13
UPGRADE_PYTHON_VERSION: 3.10.6
steps:
- uses: actions/checkout@v4
- name: Install pyenv on hosted runner
run: |
# Installing pyenv
echo "::debug::Installing pyenv"
curl https://pyenv.run | bash
echo "::debug::Exporting environment"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
echo "::debug::Intializing pyenv"
eval "$(pyenv init -)"
echo "::debug::Installing python $UPGRADE_PYTHON_VERSION"
pyenv install "$UPGRADE_PYTHON_VERSION"
echo "::debug::Rehashing shims"
pyenv rehash
- name: Debug env
if: "false" # Comment this out for add'l debug
run: env | sort
- name: Create version files
run: echo "${DESIRED_PYTHON_VERSION}" > .python-version
- name: Setup python
uses: actions/setup-python@v4
- name: Debug environment
if: "false" # Comment this out for add'l debug
run: |
export PYENV_ROOT="$HOME/.pyenv"
echo "::debug::python --version: $(python --version 2>&1 || true)"
echo "::debug::python3 --version: $(python3 --version 2>&1 || true)"
echo "::debug::pyenv should not be on the path:"
echo "::debug::which pyenv:$(which pyenv 2>&1 || true)"
echo "::debug::We manually supply the path:"
echo "::debug::pyenv versions: $("$PYENV_ROOT/bin/pyenv" versions 2>&1 || true)"
echo "::debug::~/.pyenv/shims: $(ls -1 "$("$PYENV_ROOT/bin/pyenv" root)/shims" 2>&1 || true)"
echo -e "::debug::PATH:\n$(echo "$PATH" | tr ":" "\n")"
- name: Run action-setup-tools
uses: ./
- name: Pyenv should not preempt actions/setup-python if SemVer is ok
shell: bash
run: |
# Check versions
output="$(python --version 2>&1 || true)"
echo "::debug::python --version: $output"
echo "::debug::python3 --version: $(python3 --version 2>&1 || true)"
echo "::debug::pyenv versions: $(pyenv versions 2>&1 || true)"
echo "::debug::.pyenv/shims: $(ls -1 "$HOME/.pyenv/shims" 2>&1 || true)"
echo -e "::debug::PATH:\n$(echo "$PATH" | tr ":" "\n")"
echo "$output" | grep -i "pyenv: version .* not installed" && \
{
echo "::error:: Expected python --version to work, hit pyenv instead."
echo "::debug::$(pyenv versions)"
echo "::debug::$(echo "$PATH" | tr ":" "\n")"
exit 1
}
version=$(echo "$output" | awk '{print $2}')
echo "::debug::Found version: $version"
echo "::debug::Desired version: $DESIRED_PYTHON_VERSION"
if [[ "$version" != "$DESIRED_PYTHON_VERSION" ]]; then
echo "::error::Expected python --version to return '$DESIRED_PYTHON_VERSION', got '$version'"
exit 1
fi
echo "Success!"
- name: Create upgraded version files
run: echo "$UPGRADE_PYTHON_VERSION" > .python-version
- name: Run action-setup-tools
uses: ./
- name: Pyenv upgrades if SemVer is NOT satisfied
shell: bash
run: |
# Check versions
output="$(python --version 2>&1 || true)"
echo "::debug::python --version: $output"
echo "::debug::python3 --version: $(python3 --version 2>&1 || true)"
echo "::debug::pyenv versions: $(pyenv versions 2>&1 || true)"
echo "::debug::.pyenv/shims: $(ls -1 "$HOME/.pyenv/shims" 2>&1 || true)"
echo -e "::debug::PATH:\n$(echo "$PATH" | tr ":" "\n")"
echo "$output" | grep -i "pyenv: version .* not installed" && \
{
echo "::error:: Expected python --version to work, hit pyenv instead."
echo "::debug::$(pyenv versions)"
echo "::debug::$(echo "$PATH" | tr ":" "\n")"
exit 1
}
version=$(echo "$output" | awk '{print $2}')
echo "::debug::Found version: $version"
echo "::debug::Desired version: $UPGRADE_PYTHON_VERSION"
if [[ "$version" != "$UPGRADE_PYTHON_VERSION" ]]; then
echo "::error::Expected python --version to return '$UPGRADE_PYTHON_VERSION', got '$version'"
exit 1
fi
echo "Success!"