Skip to content

Commit

Permalink
Add ability to skip overwriting / autogenerating specific files
Browse files Browse the repository at this point in the history
  • Loading branch information
Erotemic committed Sep 15, 2024
1 parent 2b763a4 commit 507aedc
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 11 deletions.
46 changes: 35 additions & 11 deletions xcookie/builders/github_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,19 @@ def combine_coverage(cls, *args, **kwargs):
@classmethod
def upload_artifact(cls, *args, **kwargs):
return cls.action({
# 'uses': 'actions/[email protected]'
'uses': 'actions/[email protected]'
# Rollback to 3.x due to
# https://github.com/actions/upload-artifact/issues/478
# todo: migrate
# https://github.com/actions/upload-artifact/blob/main/docs/MIGRATION.md#multiple-uploads-to-the-same-named-artifact
'uses': 'actions/[email protected]'
# 'uses': 'actions/[email protected]'
}, *args, **kwargs)

@classmethod
def download_artifact(cls, *args, **kwargs):
return cls.action({
# 'uses': 'actions/[email protected]',
'uses': 'actions/[email protected]',
'uses': 'actions/[email protected]',
# 'uses': 'actions/[email protected]',
}, *args, **kwargs)

@classmethod
Expand Down Expand Up @@ -244,7 +244,8 @@ def cibuildwheel(cls, *args, sensible=False, **kwargs):
return cls.action({
'name': 'Build binary wheels',
# 'uses': 'pypa/[email protected]',
'uses': 'pypa/[email protected]',
# 'uses': 'pypa/[email protected]',
'uses': 'pypa/[email protected]',
}, *args, **kwargs)


Expand Down Expand Up @@ -680,7 +681,7 @@ def build_binpy_wheels_job(self):
Actions.upload_artifact({
'name': 'Upload wheels artifact',
'with': {
'name': 'wheels',
'name': 'wheels-${{ matrix.os }}-${{ matrix.arch }}',
'path': f"./wheelhouse/{self.mod_name}*.whl"
}
})
Expand Down Expand Up @@ -790,7 +791,8 @@ def build_purewheel_job(self):
Actions.upload_artifact({
'name': 'Upload wheels artifact',
'with': {
'name': 'wheels',
# 'name': 'wheels',
'name': 'wheels-${{ matrix.os }}-${{ matrix.arch }}',
'path': build_parts['artifact'],
}
})
Expand Down Expand Up @@ -961,7 +963,14 @@ def test_wheels_job(self, needs=None):
action_steps += [
Actions.setup_qemu(sensible=True),
Actions.setup_python({'with': {'python-version': '${{ matrix.python-version }}'}}),
Actions.download_artifact({'name': 'Download wheels', 'with': {'name': 'wheels', 'path': 'wheelhouse'}}),
Actions.download_artifact({
'name': 'Download wheels',
'with': {
# 'name': 'wheels',
'pattern': 'wheels-*',
'merge-multiple': True,
'path': 'wheelhouse'
}}),
]

workspace_dname = 'testdir_${CI_PYTHON_VERSION}_${GITHUB_RUN_ID}_${RUNNER_OS}'
Expand Down Expand Up @@ -1163,7 +1172,12 @@ def build_deploy(self, mode='live', needs=None):

if 'nosrcdist' not in self.tags:
sdist_wheel_steps = [
Actions.download_artifact({'name': 'Download sdist', 'with': {'name': 'sdist_wheels', 'path': wheelhouse_dpath}})
Actions.download_artifact({
'name': 'Download sdist',
'with': {
'name': 'sdist_wheels',
'path': wheelhouse_dpath
}})
]
else:
sdist_wheel_steps = []
Expand All @@ -1175,7 +1189,14 @@ def build_deploy(self, mode='live', needs=None):
'needs': list(needs),
'steps': [
Actions.checkout(name='Checkout source'),
Actions.download_artifact({'name': 'Download wheels', 'with': {'name': 'wheels', 'path': wheelhouse_dpath}}),
Actions.download_artifact({
'name': 'Download wheels',
'with': {
# 'name': 'wheels',
'pattern': 'wheels-*',
'merge-multiple': True,
'path': wheelhouse_dpath
}}),
] + sdist_wheel_steps + [
{'name': 'Show files to upload', 'shell': 'bash', 'run': f'ls -la {wheelhouse_dpath}'},
# TODO: it might make sense to make this a script that is invoked
Expand Down Expand Up @@ -1287,7 +1308,10 @@ def build_github_release(self, needs=None):
'needs': list(needs),
'steps': [
Actions.checkout(name='Checkout source'),
Actions.download_artifact({'name': 'Download artifacts', 'with': {'name': 'deploy_artifacts', 'path': 'wheelhouse'}}),
Actions.download_artifact({'name': 'Download artifacts', 'with': {
'name': 'deploy_artifacts',
'path': 'wheelhouse'
}}),
{'name': 'Show files to release', 'shell': 'bash', 'run': 'ls -la wheelhouse'},
write_release_notes_action,
tag_action,
Expand Down
10 changes: 10 additions & 0 deletions xcookie/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ class XCookieConfig(scfg.DataConfig):

'linter': scfg.Value(True, help=ub.paragraph('if true enables lint checks in CI')),

'skip_overwrite': scfg.Value(None, help=ub.paragraph('list of targets to not regenerate by default')),

'render_doc_images': scfg.Value(False, help=ub.paragraph(
'''
if true, adds kwplot as a dependency to build docs and enable rendering images from doctests.
Expand Down Expand Up @@ -622,6 +624,14 @@ def _build_template_registry(self):
'input_fname': rc.resource_fpath('run_tests.purepy.py.in')},

]

# The user specified some files to not overwrite by default
skip_overwrite = set(self.config['skip_overwrite'])
if skip_overwrite:
for item in self.template_infos:
if item['fname'] in skip_overwrite:
item['overwrite'] = 0

if 0:
# Checker and help autopopulate
template_contents = []
Expand Down

0 comments on commit 507aedc

Please sign in to comment.