xcookie.builders.github_actions module

class xcookie.builders.github_actions.GitHubActionsRenderer(applier, plan: CIPlan | None = None)[source]

Bases: object

Render GitHub Actions workflows from a provider-neutral CI plan.

render_default() → str[source]

Render the default GitHub workflow.

The historical default workflow is the test workflow. Keep that policy here so module-level wrappers are thin aliases around the renderer.

render_tests() → str[source]
render_release() → str[source]
xcookie.builders.github_actions._action_ref(name: str) → str[source]

Return the pinned GitHub Action ref for an owner/repo name.

xcookie.builders.github_actions._version_assign_command(applier, varname: str = 'VERSION') → str[source]

Return a shell command that assigns the project version.

xcookie.builders.github_actions._setup_python_inputs(configured_version: str, *, rendered_version: str | None = None) → dict[str, str][source]

Build setup-python inputs, including prerelease resolution flags.

class xcookie.builders.github_actions.Actions[source]

Bases: object

Help build Github Action JSON objects

Example

>>> from xcookie.builders.github_actions import Actions
>>> import types
>>> for attr_name in dir(Actions):
>>>     if not attr_name.startswith('_'):
>>>         attr = getattr(Actions, attr_name)
>>>         if isinstance(attr, types.MethodType):
>>>             print(attr_name)
>>>             action = attr()

Example

>>> action = Actions.codecov_action(Yaml.coerce(
    '''
    name: Codecov Upload
    with:
      file: ./coverage.xml
      token: ${{ secrets.CODECOV_TOKEN }}
    '''))
>>> print(type(action))
>>> print(f'action = {ub.urepr(action, nl=1)}')
action_versions = {'checkout': 'actions/checkout@v6.0.2', 'setup-python': 'actions/setup-python@v6.2.0'}
classmethod _available_action_methods()[source]
classmethod _check_for_updates()[source]
classmethod action(*args, **kwargs) → Mapping[str, str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]][source]

The generic action.

TODO: support commented YAML maps

classmethod checkout(*args, **kwargs) → Mapping[str, str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]][source]
classmethod setup_python(*args, **kwargs) → Mapping[str, str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]][source]
classmethod codecov_action(*args, **kwargs) → Mapping[str, str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]][source]

References

https://github.com/codecov/codecov-action

classmethod combine_coverage(*args, **kwargs) → Mapping[str, str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]][source]
classmethod upload_artifact(*args, **kwargs) → Mapping[str, str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]][source]
classmethod download_artifact(*args, **kwargs) → Mapping[str, str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]][source]
classmethod msvc_dev_cmd(*args, osvar=None, bits=None, test_condition=None, **kwargs) → Mapping[str, str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]][source]
classmethod setup_qemu(*args, sensible=False, **kwargs) → Mapping[str, str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]][source]
classmethod setup_xcode(*args, sensible=False, **kwargs) → Mapping[str, str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]][source]
classmethod setup_ipfs(*args, **kwargs) → Mapping[str, str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]][source]
classmethod cibuildwheel(*args, sensible=False, **kwargs)[source]
xcookie.builders.github_actions._render_workflow_text(name, on_lines, jobs, footer='', concurrency_lines=None)[source]
xcookie.builders.github_actions._normalize_cibuildwheel_skip_selector(selector: str) → str[source]
xcookie.builders.github_actions._normalize_cibuildwheel_skip_string(skip: str) → str[source]
xcookie.builders.github_actions._matrix_needs_qemu(matrix: Mapping[str, str | int | float | bool | None | Sequence[str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]] | Mapping[str, str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]]]) → bool[source]
xcookie.builders.github_actions.build_ci_artifact_job(self, artifact: CIArtifact, *, release: bool = False) → MutableMapping[str, str | int | float | bool | None | MutableSequence[JSON_Mutable] | MutableMapping[str, JSON_Mutable]][source]

Render one project-owned artifact build job.

xcookie.builders.github_actions._collect_test_jobs(self, plan: CIPlan | None = None) → tuple[str, Mapping][source]
xcookie.builders.github_actions._collect_release_jobs(self, plan: CIPlan | None = None)[source]
xcookie.builders.github_actions.build_github_actions(self)[source]
xcookie.builders.github_actions.build_github_actions_tests(self)[source]
xcookie.builders.github_actions.build_github_actions_release(self)[source]
xcookie.builders.github_actions.lint_job(self, plan: CIPlan | None = None)[source]
xcookie.builders.github_actions.build_and_test_sdist_job(self, plan: CIPlan | None = None)[source]
xcookie.builders.github_actions._vcpkg_build_support(self, os_list)[source]

Build the shared vcpkg pieces used by binary wheel build jobs.

Repos tagged with vcpkg (or opencv_link, which implies vcpkg) compile native dependencies with vcpkg inside cibuildwheel on Windows.

Returns:

(pre_steps, post_steps, cibw_env) where the steps bracket the cibuildwheel invocation and cibw_env is merged into its env mapping. Every piece is empty when the repo does not use vcpkg.

Return type:

Tuple[list, list, dict]

xcookie.builders.github_actions.build_binpy_wheels_job(self)[source]

Builds the action for binary python packages that creates the wheels.

Returns:

yaml structure

Return type:

Dict

cat ~/code/xcookie/xcookie/rc/test_binaries.yml.in | yq .jobs.build_and_test_wheels

Notes

Supported Action platforms:

https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json

xcookie.builders.github_actions.build_purewheel_job(self) → dict[str, str | int | float | bool | None | Sequence[str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]] | Mapping[str, str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]]][source]
xcookie.builders.github_actions.build_sdist_job(self)[source]
xcookie.builders.github_actions.build_binpy_wheels_release_job(self)[source]
xcookie.builders.github_actions.test_wheels_job(self, needs=None, plan: CIPlan | None = None)[source]
xcookie.builders.github_actions.build_deploy(self, mode='live', needs=None, release_artifacts: Sequence[CIArtifact] = ()) → dict[str, str | int | float | bool | None | Sequence[str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]] | Mapping[str, str | int | float | bool | None | Sequence[JSON] | Mapping[str, JSON]]][source]

CommandLine

xdoctest -m /home/joncrall/code/xcookie/xcookie/builders/github_actions.py build_deploy
xdoctest -m xcookie.builders.github_actions build_deploy

Example

>>> from xcookie.builders.github_actions import *  # NOQA
>>> from xcookie.main import XCookieConfig
>>> from xcookie.main import TemplateApplier
>>> config = XCookieConfig(tags=['purepy'], remote_group='Org', repo_name='Repo')
>>> self = TemplateApplier(config)
>>> self._presetup()
>>> text = Yaml.dumps(build_deploy(self))
>>> print(text)
xcookie.builders.github_actions.build_github_release(self, needs=None, release_artifacts: Sequence[CIArtifact] = ())[source]

References

https://github.com/marketplace/actions/create-a-release-in-a-github-action https://github.com/softprops/action-gh-release https://github.com/softprops/action-gh-release/issues/20#issuecomment-572245945