Skip to content

Commit 05e5d1f

Browse files
committed
Improved pyproject.toml reading if settings don't exist.
1 parent 5b97eaf commit 05e5d1f

3 files changed

Lines changed: 80 additions & 19 deletions

File tree

.github/workflows/ExtractConfiguration.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114
coverageRC = "${{ inputs.coverage_config }}".strip()
115115
typingCoberturaFile = Path("report/typing/cobertura.xml")
116116
typingJUnitFile = Path("report/typing/StaticTypingSummary.xml")
117-
typingHTMLDirectory = Path("htmlmypy")
117+
typingHTMLDirectory = Path("report/typing/html")
118118
119119
# Read output paths from 'pyproject.toml' file
120120
if coverageRC == "pyproject.toml":
@@ -123,14 +123,34 @@ jobs:
123123
with pyProjectFile.open("rb") as file:
124124
pyProjectSettings = tomli_load(file)
125125
126-
unittestXMLFile = Path(pyProjectSettings["tool"]["pytest"]["junit_xml"])
127-
mergedUnittestXMLFile = Path(pyProjectSettings["tool"]["pyedaa-reports"]["junit_xml"])
128-
coverageHTMLDirectory = Path(pyProjectSettings["tool"]["coverage"]["html"]["directory"])
129-
coverageXMLFile = Path(pyProjectSettings["tool"]["coverage"]["xml"]["output"])
130-
coverageJSONFile= Path(pyProjectSettings["tool"]["coverage"]["json"]["output"])
131-
typingCoberturaFile = Path(pyProjectSettings["tool"]["mypy"]["cobertura_xml_report"]) / "cobertura.xml"
132-
typingJUnitFile = Path(pyProjectSettings["tool"]["mypy"]["junit_xml"])
133-
typingHTMLDirectory = Path(pyProjectSettings["tool"]["mypy"]["html_report"])
126+
toolSection = pyProjectSettings["tool"]
127+
if "pytest" in toolSection:
128+
section = toolSection["pytest"]
129+
if "junit_xml" in section:
130+
unittestXMLFile = Path(section["junit_xml"])
131+
132+
if "pyedaa-reports" in toolSection:
133+
section = toolSection["pyedaa-reports"]
134+
if "junit_xml" in section:
135+
mergedUnittestXMLFile = Path(section["junit_xml"])
136+
137+
if "coverage" in toolSection:
138+
section = toolSection["coverage"]
139+
if "html" in section:
140+
coverageHTMLDirectory = Path(section["html"]["directory"])
141+
if "xml" in section:
142+
coverageXMLFile = Path(section["xml"]["output"])
143+
if "json" in section:
144+
coverageJSONFile= Path(section["json"]["output"])
145+
146+
if "mypy" in toolSection:
147+
section = toolSection["mypy"]
148+
if "cobertura_xml_report" in section:
149+
typingCoberturaFile = Path(section["cobertura_xml_report"]) / "cobertura.xml"
150+
if "junit_xml" in section:
151+
typingJUnitFile = Path(section["junit_xml"])
152+
if "html_report" in section:
153+
typingHTMLDirectory = Path(section["html_report"])
134154
else:
135155
print(f"File '{pyProjectFile}' not found.")
136156
print(f"::error title=FileNotFoundError::File '{pyProjectFile}' not found.")

.github/workflows/Parameters.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ jobs:
164164
package_name = "${{ inputs.package_name }}".strip()
165165
name = "${{ inputs.name }}".strip()
166166
167-
if package_namespace == "": # or package_namespace == ".":
167+
if package_namespace == "":
168168
package_fullname = package_name
169169
package_directory = package_name
170170
elif package_namespace[-2:] == ".*":

.github/workflows/PrepareJob.yml

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,14 @@ jobs:
191191
printf "${ANSI_LIGHT_GREEN} [OK]\n"
192192
193193
default_branch="${defaultBranch}"
194-
printf " default_branch=%s\n" "${default_branch}"
194+
printf " Default branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${default_branch}"
195195
else
196196
printf "${ANSI_LIGHT_RED} [FAILED]\n"
197-
printf " %s\n" "${default_branch}"
197+
printf " ${ANSI_LIGHT_RED}%s${ANSI_NOCOLOR}\n" "${default_branch}"
198198
fi
199199
200200
printf "Commit checks:\n"
201+
printf " Commit: %s\n" "${{ github.sha }}"
201202
printf " Commit kind "
202203
if [[ -z "$(git rev-list -1 --merges ${{ github.sha }}~1..${{ github.sha }})" ]]; then
203204
is_regular_commit="true"
@@ -208,24 +209,37 @@ jobs:
208209
fi
209210
210211
printf "Branch checks:\n"
212+
printf " Branch: %s\n" "${branch}"
213+
printf " Commit on default branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR} " "${defaultBranch}"
211214
if [[ "${branch}" == "${defaultBranch}" ]]; then
212215
on_default_branch="true"
213-
printf " Commit on default branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${defaultBranch}"
216+
printf "${ANSI_LIGHT_GREEN}[YES]${ANSI_NOCOLOR}\n"
217+
else
218+
printf "${ANSI_LIGHT_RED}[NO]${ANSI_NOCOLOR}\n"
214219
fi
215220
221+
printf " Commit on main branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR} " "${{ inputs.main_branch }}"
216222
if [[ "${branch}" == "${{ inputs.main_branch }}" ]]; then
217223
on_main_branch="true"
218-
printf " Commit on main branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${{ inputs.main_branch }}"
224+
printf "${ANSI_LIGHT_GREEN}[YES]${ANSI_NOCOLOR}\n"
225+
else
226+
printf "${ANSI_LIGHT_RED}[NO]${ANSI_NOCOLOR}\n"
219227
fi
220228
229+
printf " Commit on release branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR} " "${{ inputs.release_branch }}"
221230
if [[ "${branch}" == "${{ inputs.release_branch }}" ]]; then
222231
on_release_branch="true"
223-
printf " Commit on release branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${{ inputs.release_branch }}"
232+
printf "${ANSI_LIGHT_GREEN}[YES]${ANSI_NOCOLOR}\n"
233+
else
234+
printf "${ANSI_LIGHT_RED}[NO]${ANSI_NOCOLOR}\n"
224235
fi
225236
237+
printf " Commit on development branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR} " "${{ inputs.development_branch }}"
226238
if [[ "${branch}" == "${{ inputs.development_branch }}" ]]; then
227239
on_dev_branch="true"
228-
printf " Commit on development branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${{ inputs.development_branch }}"
240+
printf "${ANSI_LIGHT_GREEN}[YES]${ANSI_NOCOLOR}\n"
241+
else
242+
printf "${ANSI_LIGHT_RED}[NO]${ANSI_NOCOLOR}\n"
229243
fi
230244
231245
if [[ "${is_merge_commit}" == "true" ]]; then
@@ -261,11 +275,14 @@ jobs:
261275
262276
NIGHTLY_TAG_PATTERN='^${{ inputs.nightly_tag_pattern }}$'
263277
RELEASE_TAG_PATTERN='^${{ inputs.release_tag_pattern }}$'
264-
printf " Check tag name against regexp '%s' ... " "${RELEASE_TAG_PATTERN}"
265-
if [[ "${tag}" =~ NIGHTLY_TAG_PATTERN ]]; then
278+
279+
printf "Tag checks:\n"
280+
printf " Tag: %s\n" "${tag}"
281+
printf " Check tag '%s' against regexp ... " "${tag}"
282+
if [[ "${tag}" =~ ${NIGHTLY_TAG_PATTERN} ]]; then
266283
printf "${ANSI_LIGHT_GREEN}[NIGHTLY]${ANSI_NOCOLOR}\n"
267284
is_nightly_tag="true"
268-
elif [[ "${tag}" =~ $RELEASE_TAG_PATTERN ]]; then
285+
elif [[ "${tag}" =~ ${RELEASE_TAG_PATTERN} ]]; then
269286
printf "${ANSI_LIGHT_GREEN}[RELEASE]${ANSI_NOCOLOR}\n"
270287
version="${tag}"
271288
is_release_tag="true"
@@ -277,6 +294,30 @@ jobs:
277294
printf "::error title=RexExpCheck::Tag name '%s' doesn't conform to regexp '%s' nor '%s'.\n" "${tag}" "${NIGHTLY_TAG_PATTERN}" "${RELEASE_TAG_PATTERN}"
278295
exit 1
279296
fi
297+
298+
if [[ "${is_nightly_tag}" == "true" ]]; then
299+
printf " Check if nightly tag is on main branch '%s' ... " "${{ inputs.main_branch }}"
300+
git branch --remotes --contains $(git rev-parse --verify "tags/${tag}~0") | grep "origin/${{ inputs.main_branch }}" > /dev/null
301+
if [[ $? -eq 0 ]]; then
302+
printf "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}\n"
303+
else
304+
printf "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}\n"
305+
printf " ${ANSI_LIGHT_RED}Tag '%s' isn't on branch '%s'.${ANSI_NOCOLOR}\n" "${tag}" "${{ inputs.main_branch }}"
306+
printf "::error title=TagCheck::Tag '%s' isn't on branch '%s'.\n" "${tag}" "${{ inputs.main_branch }}"
307+
exit 1
308+
fi
309+
elif [[ "${is_release_tag}" == "true" ]]; then
310+
printf " Check if release tag is on main branch '%s' ... " "${{ inputs.main_branch }}"
311+
git branch --remotes --contains $(git rev-parse --verify "tags/${tag}~0") | grep "origin/${{ inputs.main_branch }}" > /dev/null
312+
if [[ $? -eq 0 ]]; then
313+
printf "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}\n"
314+
else
315+
printf "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}\n"
316+
printf " ${ANSI_LIGHT_RED}Tag '%s' isn't on branch '%s'.${ANSI_NOCOLOR}\n" "${tag}" "${{ inputs.main_branch }}"
317+
printf "::error title=TagCheck::Tag '%s' isn't on branch '%s'.\n" "${tag}" "${{ inputs.main_branch }}"
318+
exit 1
319+
fi
320+
fi
280321
elif [[ "${ref:0:10}" == "refs/pull/" ]]; then
281322
printf "${ANSI_LIGHT_YELLOW}[PULL REQUEST]\n"
282323
ref_kind="pullrequest"

0 commit comments

Comments
 (0)