Skip to content

Commit 168aad4

Browse files
committed
New CleanupArtifacts job template.
1 parent 9004342 commit 168aad4

3 files changed

Lines changed: 168 additions & 41 deletions

File tree

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# ==================================================================================================================== #
2+
# Authors: #
3+
# Patrick Lehmann #
4+
# #
5+
# ==================================================================================================================== #
6+
# Copyright 2020-2026 The pyTooling Authors #
7+
# #
8+
# Licensed under the Apache License, Version 2.0 (the "License"); #
9+
# you may not use this file except in compliance with the License. #
10+
# You may obtain a copy of the License at #
11+
# #
12+
# http://www.apache.org/licenses/LICENSE-2.0 #
13+
# #
14+
# Unless required by applicable law or agreed to in writing, software #
15+
# distributed under the License is distributed on an "AS IS" BASIS, #
16+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
17+
# See the License for the specific language governing permissions and #
18+
# limitations under the License. #
19+
# #
20+
# SPDX-License-Identifier: Apache-2.0 #
21+
# ==================================================================================================================== #
22+
name: 🗑️ Cleanup
23+
24+
on:
25+
workflow_call:
26+
inputs:
27+
ubuntu_image_version:
28+
description: 'Ubuntu image version.'
29+
required: false
30+
default: '24.04'
31+
type: string
32+
json:
33+
description: 'JSON string of artifact names'
34+
required: false
35+
default: ''
36+
type: string
37+
artifacts:
38+
description: 'Artifacts to be removed by JSON name.'
39+
required: false
40+
default: ''
41+
type: string
42+
others:
43+
description: 'Other artifacts to be removed.'
44+
required: false
45+
default: ''
46+
type: string
47+
48+
jobs:
49+
CleanUp:
50+
name: 🗑️ Artifact Cleanup
51+
runs-on: "ubuntu-${{ inputs.ubuntu_image_version }}"
52+
steps:
53+
- name: Compute artifact names
54+
id: compute
55+
shell: python
56+
run: |
57+
from json import loads, dumps
58+
from os import getenv
59+
60+
artifactNames = loads("""${{ inputs.json }}""")
61+
62+
artifacts = [k for k in "${{ inputs.artifacts }}".split(" ") if k != ""]
63+
64+
artifactsToDelect = []
65+
prefix = ""
66+
suffix = ""
67+
for name in artifacts:
68+
if name in artifactNames:
69+
if name.startswith("prefix:"):
70+
name = name[7:]
71+
suffix="-*"
72+
elif name.startswith("suffix:"):
73+
name = name[7:]
74+
prefix="*-"
75+
76+
artifactsToDelect.append(f"{prefix}{artifactNames[name]}{suffix}")
77+
prefix = ""
78+
suffix = ""
79+
else:
80+
printf(f"Name '{name}' not found in JSON dictionary.")
81+
82+
print(f"{artifactsToDelect}")
83+
84+
# Write requirements path to special file
85+
github_output = Path(getenv("GITHUB_OUTPUT"))
86+
print(f"GITHUB_OUTPUT: {github_output}")
87+
with github_output.open("a+") as f:
88+
f.write(f"artifacts={dumps(artifactsToDelect)}\n")
89+
90+
- name: 🗑️ Delete artifacts
91+
uses: geekyeggo/delete-artifact@v5
92+
if: inputs.sqlite_coverage_artifacts_prefix != ''
93+
continue-on-error: true
94+
with:
95+
name: |
96+
${{ join(fromJSON(steps.compute.outputs.artifacts).*, '
97+
') }}
98+
99+
- name: 🗑️ Delete other Artifacts
100+
uses: geekyeggo/delete-artifact@v5
101+
if: ${{ inputs.others != '' }}
102+
with:
103+
name: ${{ inputs.others }}

.github/workflows/CompletePipeline.yml

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,17 @@ jobs:
384384
latex_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_latex }}
385385

386386
IntermediateCleanUp:
387-
uses: pyTooling/Actions/.github/workflows/IntermediateCleanUp.yml@dev
387+
uses: pyTooling/Actions/.github/workflows/CleanupArtifacts.yml@dev
388388
needs:
389389
- UnitTestingParams
390390
- PublishCoverageResults
391391
- PublishTestResults
392392
if: ( success() || failure() ) && inputs.cleanup == 'true'
393393
with:
394-
sqlite_coverage_artifacts_prefix: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_sqlite }}-
395-
xml_unittest_artifacts_prefix: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}-
394+
json: ${{ needs.UnitTestingParams.outputs.artifact_names }}
395+
artifacts: <|
396+
prefix:unittesting_xml
397+
prefix:codecoverage_sqlite
396398

397399
PDFDocumentation:
398400
uses: pyTooling/Actions/.github/workflows/LaTeXDocumentation.yml@dev
@@ -472,7 +474,7 @@ jobs:
472474
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
473475

474476
ArtifactCleanUp:
475-
uses: pyTooling/Actions/.github/workflows/ArtifactCleanUp.yml@dev
477+
uses: pyTooling/Actions/.github/workflows/CleanupArtifacts.yml@dev
476478
needs:
477479
- UnitTestingParams
478480
- UnitTesting
@@ -487,20 +489,22 @@ jobs:
487489
- IntermediateCleanUp
488490
if: inputs.cleanup == 'true'
489491
with:
490-
package: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }}
491-
remaining: |
492-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_html }}-*
493-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_xml }}-*
494-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }}-*
495-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }}-*
496-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}
497-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_html }}
498-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_sqlite }}
499-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_xml }}
500-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }}
501-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }}
502-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }}
503-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }}
504-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_latex }}
492+
json: ${{ needs.UnitTestingParams.outputs.artifact_names }}
493+
artifacts: <|
494+
package_all
495+
prefix:unittesting_html
496+
prefix:codecoverage_xml
497+
prefix:codecoverage_json
498+
prefix:codecoverage_html
499+
unittesting_xml
500+
unittesting_html
501+
codecoverage_sqlite
502+
codecoverage_xml
503+
codecoverage_json
504+
codecoverage_html
505+
statictyping_html
506+
documentation_html
507+
documentation_latex
508+
505509
# ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).apptesting_xml }}-*
506510
# ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_pdf }}

.github/workflows/_Checking_JobTemplates.yml

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ jobs:
269269
secrets: inherit
270270

271271
ArtifactCleanUp:
272-
uses: pyTooling/Actions/.github/workflows/ArtifactCleanUp.yml@dev
272+
uses: pyTooling/Actions/.github/workflows/CleanupArtifacts.yml@dev
273273
needs:
274274
- UnitTestingParams
275275
- PlatformTestingParams
@@ -284,24 +284,44 @@ jobs:
284284
- Install
285285
- IntermediateCleanUp
286286
with:
287-
package: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }}
288-
remaining: |
289-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}-*
290-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_html }}-*
291-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_xml }}-*
292-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }}-*
293-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }}-*
294-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}
295-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_html }}
296-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_sqlite }}
297-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_xml }}
298-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }}
299-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }}
300-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }}
301-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }}
302-
${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_latex }}
303-
${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).unittesting_xml }}-*
304-
${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).unittesting_html }}-*
305-
${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).codecoverage_xml }}-*
306-
${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).codecoverage_json }}-*
307-
${{ fromJson(needs.PlatformTestingParams.outputs.artifact_names).codecoverage_html }}-*
287+
json: ${{ needs.UnitTestingParams.outputs.artifact_names }}
288+
artifacts: <|
289+
package_all
290+
prefix:unittesting_xml
291+
prefix:unittesting_html
292+
prefix:codecoverage_xml
293+
prefix:codecoverage_json
294+
prefix:codecoverage_html
295+
unittesting_xml
296+
unittesting_html
297+
codecoverage_sqlite
298+
codecoverage_xml
299+
codecoverage_json
300+
codecoverage_html
301+
statictyping_html
302+
documentation_html
303+
documentation_latex
304+
305+
ArtifactCleanUp2:
306+
uses: pyTooling/Actions/.github/workflows/CleanupArtifacts.yml@dev
307+
needs:
308+
- UnitTestingParams
309+
- PlatformTestingParams
310+
- UnitTesting
311+
- StaticTypeCheck
312+
- PlatformTesting
313+
- Documentation
314+
- PDFDocumentation
315+
- PublishTestResults
316+
- PublishCoverageResults
317+
- PublishToGitHubPages
318+
- Install
319+
- IntermediateCleanUp
320+
with:
321+
json: ${{ needs.PlatformTestingParams.outputs.artifact_names }}
322+
artifacts: <|
323+
prefix:unittesting_xml
324+
prefix:unittesting_html
325+
prefix:codecoverage_xml
326+
prefix:codecoverage_json
327+
prefix:codecoverage_html

0 commit comments

Comments
 (0)