-
Notifications
You must be signed in to change notification settings - Fork 2
194 lines (172 loc) · 5.87 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
name: CI Workflow
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- 'releases/*'
jobs:
sanity-tests:
name: Sanity Tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m venv .venv
.venv/bin/pip install -r requirements.txt
- name: Run sanity tests
id: sanity
env:
PYTHONPATH: ${{ github.workspace }} # Add workspace to PYTHONPATH
run: |
result=$(.venv/bin/pytest -v --tb=short resources/tests/sanity_tests.py)
echo "result<<EOF" >> $GITHUB_ENV
echo "$result" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
return-tests:
name: Return Tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m venv .venv
.venv/bin/pip install -r requirements.txt
- name: Run remaining return tests
id: return
env:
PYTHONPATH: ${{ github.workspace }} # Add workspace to PYTHONPATH
run: |
result=$(.venv/bin/pytest -v --tb=short resources/tests/return_tests.py)
echo "result<<EOF" >> $GITHUB_ENV
echo "$result" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
variable-naming-tests:
name: Variable Case Tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m venv .venv
.venv/bin/pip install -r requirements.txt
- name: Run variable naming convention tests
id: variable_naming
env:
PYTHONPATH: ${{ github.workspace }} # Add workspace to PYTHONPATH
run: |
result=$(.venv/bin/pytest -v --tb=short resources/tests/variable_cases.py)
echo "result<<EOF" >> $GITHUB_ENV
echo "$result" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
generate-pydoc:
runs-on: ubuntu-latest
name: Generate PyDoc Documentation
if: github.event_name != 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository # Exclude from PRs and forks
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m venv .venv
.venv/bin/pip install -r requirements.txt
- name: Create PyDoc documentation
run: |
mkdir -p docs
find src -name "*.py" | while read filepath; do
relative_path=$(dirname "$filepath" | sed 's|src/||')
mkdir -p "docs/$relative_path"
.venv/bin/python -m pydoc -w "$filepath"
filename=$(basename "$filepath" .py).html
mv "$filename" "docs/$relative_path/"
done
- name: Commit Docs
env:
GITHUB_TOKEN: ${{ secrets.DOCS_REPO_ACCESS_TOKEN }}
run: |
git config --global user.email "matthewspratlin@gmail.com"
git config --global user.name "Matthew Spratlin"
git clone https://MKS2345:${{ secrets.DOCS_REPO_ACCESS_TOKEN }}@github.com/MKS2345/BEST_LowG_Docs.git external-repo
cp -r docs/* external-repo/docs/
cd external-repo
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "Generate PyDoc Documentation - ${{ github.event.head_commit.message }}"
git push
else
echo "No changes to documentation, skipping commit."
fi
- name: Clean up local docs folder
run: rm -rf docs
qodana:
name: Qodana
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
if: github.event_name != 'pull_request' # Exclude from pull requests
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
# Run Python inside the Qodana Docker container
- name: Qodana Scan
uses: JetBrains/qodana-action@v2024.1
with:
pr-mode: false
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN_1408482145 }}
QODANA_ENDPOINT: 'https://qodana.cloud'
summary:
name: Summary Report
runs-on: ubuntu-latest
needs: [sanity-tests, variable-naming-tests, return-tests, generate-pydoc] # Exclude Qodana
steps:
- name: Sanity Tests Summary
id: sanity
run: echo "Sanity Tests Passed!" # You can replace this with actual test output
continue-on-error: true
shell: bash
- name: Variable Naming Tests Summary
id: variable_naming
run: echo "Variable Naming Tests Passed!" # You can replace this with actual test output
continue-on-error: true
shell: bash
- name: Return Tests Summary
id: return_tests
run: echo "Return Tests Passed!" # You can replace this with actual test output
continue-on-error: true
shell: bash
- name: PyDoc Generation Summary
id: pydoc
run: |
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
echo "PyDoc Generation not supported in forks."
else
echo "PyDoc Generation Succeeded!" # Replace with actual PyDoc generation status
fi
continue-on-error: true
shell: bash