Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ updates:
directory: "/"
schedule:
interval: "weekly"
cooldown:
default-days: 4
3 changes: 3 additions & 0 deletions .github/workflows/build-devel-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name: Scheduled build for devel docs
# Run at 05:22 daily
- cron: '22 5 * * *'

permissions:
contents: read

jobs:
build-package-docs:
name: 📝 Build
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build-latest-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name: Scheduled build for latest docs
# Run at 05:41 on Monday
- cron: '41 5 * * 1'

permissions:
contents: read

jobs:
build-package-docs:
name: 📝 Build
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build-package-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ name: Build and deploy docs
- production
- test

permissions:
contents: read

jobs:
build-package-docs:
name: 📝 Build
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ name: Ansible Docsite CI
- ready_for_review # used in PRs created from GitHub Actions workflows
workflow_dispatch:

permissions:
contents: read

jobs:
nox:
uses: ./.github/workflows/reusable-nox.yml
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# SPDX-License-Identifier: GPL-3.0-or-later

"on":
pull_request_target:
# This workflow does not execute untrusted code from pull requests and all
# inputs are properly sanitized,
pull_request_target: # zizmor: ignore[dangerous-triggers]
types:
- opened # default
- synchronize # default
Expand All @@ -29,6 +31,9 @@

name: "Triage Issues and PRs"

permissions:
contents: read

jobs:
label_prs:
runs-on: ubuntu-latest
Expand All @@ -48,6 +53,8 @@ jobs:
private-key: ${{ secrets.BOT_APP_KEY }}
- name: Checkout parent repository
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Install Python 3.12
uses: actions/setup-python@v6
with:
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/pip-compile-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ name: "Refresh dev dependencies"
required: false
type: string

permissions:
contents: read

jobs:
refresh:
strategy:
Expand Down Expand Up @@ -63,4 +66,9 @@ jobs:
python-versions: "${{ matrix.python-versions }}"
reset-branch: "${{ inputs.reset-branch || false }}"
labels: "${{ inputs.labels || 'no_backport,tooling' }}"
secrets: inherit
# Pass using inherit, as this seems to be the only possible way to access
# secrets defined in an enviornment when using nested workflows.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That workflow should declare an explicit secrets: section. Then, passing secrets will work. Just like inputs:.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but the secrets are part of the github-bot environment, and I don't think environment can be set in the calling workflow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, so https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows#using-inputs-and-secrets-in-a-reusable-workflow implies that the environment should be set in the reusable workflow but doesn't explicitly talk about how that interacts with the secrets key (beyond the inability to pass them explicitly).

secrets: inherit # zizmor: ignore[secrets-inherit]
# secrets:
# BOT_APP_ID: "${{ secrets.BOT_APP_ID }}"
# BOT_APP_KEY: "${{ secrets.BOT_APP_KEY }}"
10 changes: 9 additions & 1 deletion .github/workflows/pip-compile-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ name: "Refresh docs build dependencies"
required: false
type: string

permissions:
contents: read

jobs:
refresh:
name: "Refresh docs build dependencies"
Expand All @@ -33,4 +36,9 @@ jobs:
reset-branch: "${{ inputs.reset-branch || false }}"
labels: "${{ inputs.labels || 'doc builds,no_backport' }}"
python-versions: "3.12"
secrets: inherit
# Pass using inherit, as this seems to be the only possible way to access
# secrets defined in an enviornment when using nested workflows.
secrets: inherit # zizmor: ignore[secrets-inherit]
# secrets:
# BOT_APP_ID: "${{ secrets.BOT_APP_ID }}"
# BOT_APP_KEY: "${{ secrets.BOT_APP_KEY }}"
4 changes: 4 additions & 0 deletions .github/workflows/release-porting-guide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:
description: >-
Exact release version. For example, 12.1.0
required: true
permissions:
contents: read

jobs:
upload-porting-guide:
Expand Down Expand Up @@ -40,13 +42,15 @@ jobs:
uses: actions/checkout@v5
with:
token: ${{ steps.create_token.outputs.token }}
persist-credentials: true # Needed to push to the repo

- name: Check out ansible-build-data
uses: actions/checkout@v5
with:
repository: ansible-community/ansible-build-data
ref: ${{ inputs.ansible-build-data-branch }}
path: ansible-build-data
persist-credentials: false

- name: Copy the RST file to the correct path
run: >-
Expand Down
29 changes: 18 additions & 11 deletions .github/workflows/reusable-build-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ name: Build docs
DOCS_BOT_TOKEN:
required: true

env:
PACKAGE_VERSION: ${{ inputs.ansible-package-version }}

jobs:
build-package-docs:
runs-on: ubuntu-latest
Expand All @@ -50,26 +47,34 @@ jobs:
}}
ref: ${{ inputs.repository-branch }}
path: build-directory
persist-credentials: false

- name: Setup nox
uses: wntrblm/nox@2025.10.16

- name: Output Python info
run: python --version --version && which python

- name: Set the VERSION variable
run: echo VERSION="${PACKAGE_VERSION}" >> "${GITHUB_ENV}"
- name: Graft ansible-core
run: nox -s clone-core
working-directory: build-directory

- name: Build the Ansible community package docs
run: >-
nox -e make -- webdocs ${{
env:
PACKAGE_VERSION: "${{ inputs.ansible-package-version }}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oraNod, do we need to also export VERSION like it was before in the Set the VERSION variable step? Is $VERSION used in the Makefile?

Suggested change
PACKAGE_VERSION: "${{ inputs.ansible-package-version }}"
PACKAGE_VERSION: "${{ inputs.ansible-package-version }}"
VERSION: "${{ inputs.ansible-package-version }}"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @gotmax23 ANSIBLE_VERSION gets passed to the Makefile but not VERSION.

I think VERSION is a relic from the Jenkins job that is used in a couple of places including the step to add a symlink on the web server: ln -s \$VERSION _build/latest. Maybe we needed it when we first started with the workflow but it should be fine to drop it as part of this PR.

I'm pretty sure I built this branch before I approved but will do it again now. Thanks, as always, for the thoughtful questions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just did a run with this branch from the devel branch and see this in the logs: nox > make -C docs/docsite PYTHON=/home/runner/work/ansible-documentation/ansible-documentation/build-directory/.nox/make/bin/python webdocs ANSIBLE_VERSION= 'EXTRA_TAGS=-t redirects'

Everything in the tarball looks good too. I think we can safely remove the Set the VERSION variable step.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see

$ rg '^VERSION.*=' docs/docsite/Makefile
VERSION := $(shell $(PYTHON) ./version_helper.py --raw || echo error)

. Assuming I remember how Makefile syntax works, I think this will set VERSION to a default value unless it is already set. VERSION was previously set in the environment, but now it's not, so I think that the value generated by that script would be used instead. I'm not sure what impact that has.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I thought that line was more related to how the core versions get set in docs. But it's true that VERSION no longer gets set in the environment.

If there's any impact it would be to the version list drop down, which I can see is still at 11 here: https://docs.ansible.com/projects/ansible/devel/index.html

Perhaps we stomped on how VERSION was getting set when we made this a reusable workflow and it's been broken? I'll go back and look. I've compared the generated HTML built from this branch with what we're building on devel and they seem to match. So I really don't think we're going to break something new by dropping VERSION.

I'm also not sure it's worth fixing whatever VERSION was doing for the package docs. We've got the Read The Docs flyout menu on docs.ansible.com now. Part of the migration effort was to adopt RTD native tooling instead of the custom version switcher. That might be a good step towards decoupling package and core docs, which is also the root of some of the complexity in the Makefile.

run: |
# Clear PACKAGE_VERSION if it's set to devel
if [ "${PACKAGE_VERSION}" = "devel" ]; then
PACKAGE_VERSION=""
fi
nox -e make -- webdocs ANSIBLE_VERSION="${PACKAGE_VERSION}" ${{
inputs.generate-redirects && 'EXTRA_TAGS="-t redirects"' || ''
}} ANSIBLE_VERSION="${{
env.PACKAGE_VERSION != 'devel' && env.PACKAGE_VERSION || ''
}}"
}}
working-directory: build-directory

- name: Create a tarball with the build contents
env:
PACKAGE_VERSION: "${{ inputs.ansible-package-version }}"
run: >-
tar -czvf
ansible-package-docs-html-"${PACKAGE_VERSION}"-"$(date '+%Y-%m-%d')"-${{
Expand Down Expand Up @@ -105,8 +110,10 @@ jobs:
run: echo "TX_ID=$(date +%s)" >> "${GITHUB_ENV}"

- name: Notify the DaWGs in Matrix
# FAIL_MESSAGE is trusted input so okay to inject here.
# zizmor: ignore[template-injection]
run: |
curl -X PUT "${{ env.ROOM_URL }}/${TX_ID}" \
curl -X PUT "${ROOM_URL}/${TX_ID}" \
-H "Authorization: Bearer ${{ secrets.DOCS_BOT_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{"msgtype": "m.text", "body": "${{ env.FAIL_MESSAGE }}"}'
13 changes: 9 additions & 4 deletions .github/workflows/reusable-deploy-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Log the workflow inputs if deployed
env:
deployment_environment: "${{ inputs.deployment-environment }}"
package_version: "${{ inputs.ansible-package-version }}"
owner: "${{ inputs.repository-owner }}"
branch: "${{ inputs.repository-branch }}"
run: |
{
echo "## Deployment details :shipit:";
echo "Publish to: ${{ inputs.deployment-environment }}";
echo "Package version: ${{ inputs.ansible-package-version }}";
echo "Owner: ${{ inputs.repository-owner }}";
echo "Branch: ${{ inputs.repository-branch }}";
echo "Publish to: ${deployment_environment}";
echo "Package version: ${package_version}";
echo "Owner: ${owner}";
echo "Branch: ${branch}";
} >> "${GITHUB_STEP_SUMMARY}"

deploy-package-docs:
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/reusable-nox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ jobs:
- session: "pip-compile"
extra-args: "--check"
python-versions: "3.12"
- session: "zizmor"
python-versions: "3.12"
Comment on lines +37 to +38
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could potentially remove this in favor of the workflow added in #3141 and just keep the zizmor in the noxfile for contributors to run locally.

Although, I'm concerned that:

  1. The zizmor workflow in Add Zizmor Scanning on push/pull request #3141 doesn't make CI red even though there are failures.
  2. If we have to manage the zizmor version pinned in the zizmor workflow and the version used by the nox job, they may get out of sync, which could be confusing for developers, as they'll get different results when running locally vs. CI.
  3. I'm not sure how much the integration with Github Code Scanning is helpful to our community. Case in point, @x1101 spent time contributing the workflow (thank you!), but they can't even see the failures it reported. I personally think it's better to integrate zizmor with our existing nox setup but am happy to be convinced otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The zizmor workflow not failing CI seems to be by design of the GHA author, keeping that data in the security section for action separate from success/failure of the CI itself.

As for not being able to find the reported issues, that was a "I needed to learn how to use the tools together". I was running the scans on one branch, and the scan was showing data from another, and I just missed how I could adjust that to see the results (all of that was happening in my own fork).

With all that being said, since a majority of the workflows for the project are setup using nox to make them portable between dev/CI environments, I can't think of any good objections to integrating it there. I initially went the GHA route because it appears to be the suggested method by the tool authors, with the intention of piping that data automatically into existing GH systems (which does work as intended, but doesn't sound like its exactly the use case we're targeting).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gotmax23 that workflow should be complementary as the nox session won't integrate with GH through SARIF. Just add another job separately.

@x1101 I believe that once merged, the issues would show up in PRs inline. But it's a good idea to have both invocation mechanisms in place. The reusable workflow is for the GH Code Scanning integration while nox is for local use. However, it's a good idea to still run that nox session in CI to ensure that it works in dev env.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gotmax23 FYI the code scanning results don't normally show up until the workflow reporting them is in devel. That might be the reason.

name: "Run nox ${{ matrix.session }} session"
steps:
- name: Check out repo
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Setup nox
uses: wntrblm/nox@2025.10.16
with:
Expand All @@ -46,7 +50,8 @@ jobs:
run: |
nox -e clone-core
- name: "Run nox -e ${{ matrix.session }}"
# Using GHA expression interpolation is fine here,
# as we control all the inputs.
# zizmor: ignore[template-injection]
run: |
# Using GHA expression interpolation is fine here,
# as we control all the inputs.
nox -e "${{ matrix.session }}" -- ${{ matrix.extra-args }}
28 changes: 20 additions & 8 deletions .github/workflows/reusable-pip-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,21 @@ name: "Refresh pinned dependencies"
python-versions:
type: string
required: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
required: true
required: true
secrets:
BOT_APP_ID:
description: An ID for the GitHub App to authenticate as.
required: true
BOT_APP_KEY:
description: A private key for the GitHub App authentication.
required: true


permissions:
contents: read

jobs:
refresh:
runs-on: ubuntu-latest
environment: github-bot
steps:
- name: Generate temp GITHUB_TOKEN
id: create_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_APP_KEY }}
- name: Check out repo
uses: actions/checkout@v5
with:
fetch-depth: 0
ref: "${{ inputs.base-branch }}"
token: "${{ steps.create_token.outputs.token }}"
persist-credentials: false
- name: Fetch required contents of ansible-core
run: |
python docs/bin/clone-core.py
Expand Down Expand Up @@ -82,9 +80,23 @@ jobs:
env:
# Ensure the latest pip version is used
VIRTUALENV_DOWNLOAD: '1'
#
# nox-args is defined statically in the calling workflows and passing it
# as a shell variable presents quoting issues, so ignore zizmor error
# for now.
# zizmor: ignore[template-injection]
run: |
nox ${{ inputs.nox-args }}
- name: Generate temp GITHUB_TOKEN
id: create_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_APP_KEY }}
# We could rely on the checkout action to persist the token in the
# repository config, but this way, we can prevent the previous steps
# from having unnecessary access.
- name: "Set up token authentication"
run: gh auth setup-git --force --hostname github.com
- name: Push new dependency versions and create a PR
env:
GITHUB_TOKEN: ${{ steps.create_token.outputs.token }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ name: Sync tags with ansible-core releases
schedule:
- cron: "0 * * * *" # Hourly

permissions:
contents: read # read-only because we use bot token to push

jobs:
tag:
runs-on: "ubuntu-latest"
Expand All @@ -30,12 +33,14 @@ jobs:
path: ansible-documentation
fetch-depth: 0
token: "${{ steps.create_token.outputs.token }}"
persist-credentials: true
- name: Check out core
uses: actions/checkout@v5
with:
repository: ansible/ansible
path: ansible
fetch-depth: 0
persist-credentials: false
- name: Setup nox
uses: wntrblm/nox@2025.10.16
with:
Expand Down
7 changes: 7 additions & 0 deletions .github/zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rules:
unpinned-uses:
config:
policies:
"wntrblm/nox": ref-pin
"re-actors/alls-green": ref-pin
"actions/*": ref-pin
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ The `nox` configuration also contains session to run automated docs checkers.
If you want to view the generated HTML in your browser, you should build the documentation locally.
See [Building the documentation locally](https://docs.ansible.com/ansible/latest/community/documentation_contributions.html#building-the-documentation-locally) for more information.

* Lint, type check, and format Python scripts in this repository.
* Lint, type check, and format Python scripts in this repository and lint the Github Actions workflows for syntax and security issues:

``` bash
nox -s lint
Expand Down
13 changes: 13 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,26 @@ def actionlint(session: nox.Session) -> None:
)


@nox.session
def zizmor(session: nox.Session) -> None:
"""
Run zizmor, a Github Actions security checker
"""
args: list[str] = list(session.posargs)
if not any(a.startswith("--persona") for a in args):
args.append("--persona=regular")
install(session, req="zizmor")
session.run("zizmor", *args, ".github/workflows")


@nox.session
def lint(session: nox.Session):
session.notify("typing")
session.notify("static")
session.notify("formatters")
session.notify("spelling")
session.notify("actionlint")
session.notify("zizmor")


requirements_files = list(
Expand Down
1 change: 1 addition & 0 deletions tests/zizmor.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zizmor
4 changes: 4 additions & 0 deletions tests/zizmor.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file was autogenerated by uv via the following command:
# uv pip compile --universal --output-file tests/zizmor.txt tests/zizmor.in
zizmor==1.16.0
# via -r tests/zizmor.in