-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
193 lines (163 loc) · 5.63 KB
/
action.yaml
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
name: 'RepoDynamics PyTests'
description: 'Test Python packages'
author: 'Armin Ariamajd'
branding:
icon: file-text
color: blue
inputs:
config:
required: true
description: CI configuration as a JSON string.
metadata:
required: true
description: CI metadata as a JSON string.
package-source:
description: |
Source to install the package; options: 'GitHub', 'TestPyPI', 'PyPI'.
default: local
required: false
python-version:
description: Python version to use.
default: '3.x'
required: false
os:
description: Current operating system of the job.
default: ubuntu-latest
required: false
max-retries:
description: |
Maximum number of retries.
default: '15'
required: false
retry-delay:
description: |
Delay between retries in seconds.
default: '60'
required: false
runs:
using: "composite"
steps:
- name: 'Initialize'
shell: bash
run: |
# Initialize
printf "\n\n$(cat ${{github.action_path}}/logo.txt)\n\n\n"
echo -e "\033[1;30;48;2;0;162;255m Initialize "
# - if: ${{ inputs.package-source == 'GitHub' }}
- uses: actions/checkout@v3
with:
repository: ${{ fromJSON(inputs.config).checkout.repository }}
ref: ${{ fromJSON(inputs.config).checkout.ref }}
fetch-depth: 0
# - if: ${{ inputs.package-source != 'GitHub' }}
# uses: actions/checkout@v3
# with:
# repository: ${{ inputs.repository }}
# ref: ${{ inputs.ref }}
# sparse-checkout-cone-mode: false
# sparse-checkout: |
# ${{ inputs.path-local }}
# ${{ inputs.path-tests }}
# ${{ inputs.path-config }}
# requirements.txt
- name: 'Set up Python'
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
- name: 'Install package'
shell: bash
run: |
# Setup Environment
source $(echo "${{ github.action_path }}" | sed 's/\\/\//g')/retry.sh
echo "::group::Update pip"
python -m pip install --upgrade pip
echo "::endgroup::"
echo "::group::Install Package"
if [ "${{inputs.package-source}}" = "GitHub" ]; then
python -m pip install .
elif [ "${{ inputs.package-source }}" = "TestPyPI" ]; then
python -m pip install -r requirements.txt
COMMAND="python -m pip install \
${{ fromJson(inputs.metadata).package.name }}==${{ fromJSON(inputs.config).package.version }} \
--no-deps \
--index-url https://test.pypi.org/simple/"
retry_command "$COMMAND" "${{ inputs.max-retries }}" "${{ inputs.retry-delay }}"
elif [ "${{inputs.package-source}}" = "PyPI" ]; then
if [ -z "${{ fromJSON(inputs.config).package.version }}" ]; then
COMMAND="python -m pip install ${{ fromJson(inputs.metadata).package.name }}"
else
COMMAND="python -m pip install ${{ fromJson(inputs.metadata).package.name }}==${{ fromJSON(inputs.config).package.version }}"
fi
retry_command "$COMMAND" "${{ inputs.max-retries }}" "${{ inputs.retry-delay }}"
else
echo "Invalid package-source: '${{ inputs.package-source }}'."
exit 1
fi
echo "::endgroup::"
echo "::group::Install Test-Suite"
python -m pip install ${{ fromJson(inputs.metadata).path.dir.tests }}
echo "::endgroup::"
- name: 'Display info'
shell: bash
run: |
echo "::group::Python version"
python -c "import sys; print(sys.version)"
echo "::endgroup::"
echo "::group::pip list"
python -m pip list
echo "::endgroup::"
echo "::group::OS and hardware info"
uname -a
echo "::endgroup::"
echo "::group::Disk space usage"
df -h
echo "::endgroup::"
echo "::group::Available system resources"
ulimit -a
echo "::endgroup::"
echo "::group::Root directory"
ls -a
echo "::endgroup::"
echo "::group::File tree"
find .
echo "::endgroup::"
# - name: 'Run dependency tests'
# shell: bash
# run: pipreqs ./src --debug --print
- name: 'Load PyTest Cache'
uses: actions/cache@v3
with:
path: ${{ fromJson(inputs.metadata).path.dir.local.cache.pytest }}
key: >-
pytest
-${{ inputs.os }}
-${{ inputs.python-version }}
-${{ fromJSON(inputs.config).checkout.ref_before }}
- name: 'Load Coverage Cache'
uses: actions/cache@v3
with:
path: ${{ fromJson(inputs.metadata).path.dir.local.cache.coverage }}
key: >-
coverage
-${{ inputs.os }}
-${{ inputs.python-version }}
-${{ fromJSON(inputs.config).checkout.ref_before }}
- name: 'Run Test-Suite'
shell: bash
run: python -m ${{ fromJson(inputs.metadata).package.name }}_tests
- name: 'Upload reports'
if: always()
uses: actions/upload-artifact@v3
with:
name: Test-Suite Reports
path: ${{ fromJson(inputs.metadata).path.dir.local.report }}
- name: 'Upload coverage reports to codecov'
if: ${{ !cancelled() && inputs.package-source == 'GitHub' }}
# https://github.com/marketplace/actions/codecov
# https://github.com/codecov/codecov-action
uses: codecov/codecov-action@v3
with:
directory: ${{ fromJson(inputs.metadata).path.dir.local.report.coverage }}
fail_ci_if_error: false
verbose: true
env_vars: OS,PYTHON