Skip to content

Commit

Permalink
Merge pull request #69 from lkubb/unify-workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
lkubb authored Oct 7, 2024
2 parents 0f5ac4b + 72a443d commit 6a7c0e8
Show file tree
Hide file tree
Showing 23 changed files with 143 additions and 557 deletions.
1 change: 1 addition & 0 deletions changelog/+minmaxsalt.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensured minimum and maximum supported Salt versions always at least follow their default values (supported versions at the time of the template release) when updating the template.
1 change: 1 addition & 0 deletions changelog/+workflows.removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dropped `workflows` question and `basic` and `org` workflow variants. All projects use the `enhanced` workflows from now on.
16 changes: 4 additions & 12 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ max_salt_version:
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- if (max_salt_version | float) < (salt_version | float) -%}
Maximum version needs to be at least {{ salt_version }}
{%- endif -%}
no_saltext_namespace:
type: bool
Expand All @@ -226,18 +229,7 @@ test_containers:
help: Add support for test containers in functional/integration tests
default: false

workflows:
type: str
help: Choose which workflow style to create
default: '{{ "org" if "github.com/salt-extensions/" in source_url else "enhanced" }}'
choices:
basic (== official creation tool): basic
enhanced (~ organization, but local): enhanced
organization (rely on centralized artifacts from salt-extensions org): org
when: '{{ "github.com" in source_url }}'

os_support:
when: '{{ workflows == "enhanced" }}'
type: str
multiselect: true
help: Supported OS. Influences where tests run.
Expand Down Expand Up @@ -265,7 +257,7 @@ deploy_docs:
never: never
when tagging a release: release
all events on `main` (rolling): rolling
when: '{{ "github.com" in source_url and workflows != "basic" }}'
when: '{{ "github.com" in source_url }}'

docs_url:
type: str
Expand Down
10 changes: 3 additions & 7 deletions docs/ref/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,22 @@ Contains GitHub-related configurations and workflows. This directory is only pre
:::{path} .github/workflows
:::
### `.github/workflows`
Houses GitHub Actions {question}`workflows`.
Houses GitHub Actions [workflows](workflows-target).

:::{path} .github/workflows/ci.yml
:::
#### `.github/workflows/ci.yml`
A meta-workflow that triggers other workflows based on inputs.

:::{important}
Only present when {question}`workflows` == `enhanced`.
:::

:::{path} .github/workflows/pr.yml
:::
#### `.github/workflows/pr.yml`
Handles workflows for Pull Requests and pushes to the `main` branch. Depending on {question}`workflows`, it either calls centralized workflows in [salt-extensions/central-artifacts](https://github.com/salt-extensions/central-artifacts/tree/main/.github/workflows) or local workflows in {path}`ci.yml <.github/workflows/ci.yml>`.
Handles workflows for Pull Requests and pushes to the `main` branch. Delegates to workflows in {path}`ci.yml <.github/workflows/ci.yml>`.

:::{path} .github/workflows/tag.yml
:::
#### `.github/workflows/tag.yml`
Triggered by [tag pushes](publishing-target) for tags beginning with `v`. Similar to {path}`pr.yml <.github/workflows/pr.yml>`, it either calls centralized workflows or local ones in {path}`ci.yml <.github/workflows/ci.yml>`.
Triggered by [tag pushes](publishing-target) for tags beginning with `v`. Similar to {path}`pr.yml <.github/workflows/pr.yml>`, it delegates to workflows in {path}`ci.yml <.github/workflows/ci.yml>`.

:::{path} changelog
:::
Expand Down
34 changes: 2 additions & 32 deletions docs/ref/questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,7 @@ The minimum Python version to support. Also affects pre-commit autoformatting ho
:::{question} max_salt_version
:::
## `max_salt_version`
The maximum Salt version to support.

:::{hint}
This is only relevant when non-centralized {question}`workflows` are used, as it affects the Salt versions tests are run against.
:::
The maximum Salt version to support. Influences the Salt versions tests are run against.

:::{question} no_saltext_namespace
:::
Expand All @@ -131,39 +127,13 @@ Include test fixtures for Salt-SSH tests (`salt_ssh_cli` etc.). Defaults to true
## `test_containers`
Add support for running containers in the test suite (for functional and integration tests).

:::{question} workflows
:::
## `workflows`
Select a GitHub Actions workflow style:

**org**
: Rely on reusable (centralized) workflows from the `salt-extensions` GitHub organization.

**enhanced**
: Equivalent workflows to `org`, but stored in the extension repository. Ensures you can modify the workflows.

**basic**
: Provided for compatibility with the deprecated create-salt-extension tool (not recommended for new projects).

:::{important}
If you are not hosting within the `salt-extensions` GitHub organization, you need to [setup required secrets](required-secrets-target) yourself.
:::

:::{note}
Not asked if {question}`source_url` is not on GitHub.
:::

:::{question} os_support
:::
## `os_support`
Select supported operating systems. Usually, you should leave the default of `Linux`, `macOS` and `Windows`, but some extensions only make sense on specific systems.

This question influences on which systems the tests are run.

:::{note}
Only asked if `enhanced` {question}`workflows` were selected.
:::

:::{question} deploy_docs
:::
## `deploy_docs`
Expand All @@ -189,7 +159,7 @@ The current workflows do not support versioned documentation.
:::

:::{note}
Not asked if {question}`source_url` is not on GitHub or the `basic` {question}`workflows` have been selected.
Not asked if {question}`source_url` is not on GitHub.
:::

:::{question} docs_url
Expand Down
3 changes: 1 addition & 2 deletions docs/topics/documenting/publishing.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
(docs-publish-target)=
# Publishing documentation

If your {question}`source_url` is on GitHub and you selected either `org` or
`enhanced` {question}`workflows`, you can automatically deploy your documentation to your repository's GitHub Pages site. This deployment is controlled by the {question}`deploy_docs` setting.
If your {question}`source_url` is on GitHub, you can automatically deploy your documentation to your repository's GitHub Pages site. This deployment is controlled by the {question}`deploy_docs` setting.

(docs-publish-setup-target)=
## Setup
Expand Down
9 changes: 2 additions & 7 deletions docs/topics/workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@

Your Salt extension repository includes several workflows out of the box if your {question}`source_url` is on GitHub.

:::{note}
The workflows used within the `salt-extensions` organization (`org`) are equivalent
to the `enhanced` ones.
:::

## Provided functions

The workflows currently:

* Ensure `pre-commit` checks pass
* Run the test suite
* Run the test suite and upload code coverage reports
* Build the documentation
* Optionally deploy built documentation to GitHub Pages
* Optionally build and release your project to PyPI
Expand Down Expand Up @@ -51,5 +46,5 @@ The built HTML documentation, also available for preview when triggered by a Pul

## Workflows call stack
1. {path}`.github/workflows/pr.yml` or {path}`.github/workflows/tag.yml` is triggered
2. {path}`.github/workflows/ci.yml` (or its equivalent centralized workflow) is called as the main entry point to CI
2. {path}`.github/workflows/ci.yml` is called as the main entry point to CI
3. Depending on the event and inputs, select additional workflows perform the necessary tasks.
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{%- raw -%}
---
name: Pull Request or Push
{%- set base = "." %}
{%- set suffix = "" %}
{%- if workflows == "org" %}
{%- set base = "salt-extensions/central-artifacts" %}
{%- set suffix = "@main" %}
{%- endif %}
{%- raw %}

on:
push:
Expand All @@ -20,11 +14,13 @@ jobs:
call_central_workflow:
name: CI
{%- endraw %}
uses: {{ base }}/.github/workflows/ci.yml{{ suffix }}
uses: ./.github/workflows/ci.yml
with:
deploy-docs: {{ (deploy_docs == "rolling") | lower }}
{%- raw %}
permissions:
contents: write
id-token: write
pages: write
pull-requests: read
{%- endraw %}
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{%- raw -%}
---
name: Tagged Releases
{%- set base = "." %}
{%- set suffix = "" %}
{%- if workflows == "org" %}
{%- set base = "salt-extensions/central-artifacts" %}
{%- set suffix = "@main" %}
{%- endif %}
{%- raw %}

on:
push:
Expand All @@ -33,7 +27,7 @@ jobs:
call_central_workflow:
needs: get_tag_version
{%- endraw %}
uses: {{ base }}/.github/workflows/ci.yml{{ suffix }}
uses: ./.github/workflows/ci.yml
with:
deploy-docs: {{ (deploy_docs in ["rolling", "release"]) | lower }}
{%- raw %}
Expand Down
Loading

0 comments on commit 6a7c0e8

Please sign in to comment.