Skip to content

Commit 3ae16a1

Browse files
authored
Merge branch 'main' into macos
2 parents 808c293 + b4d1d97 commit 3ae16a1

24 files changed

+89
-66
lines changed

.config/requirements-docs.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
mkdocs-ansible[lock]>=0.2.0
1+
mkdocs-ansible>=24.2.1
22
pipdeptree>=2.4.0
3-
linkchecker==10.2.1
3+
linkchecker>=10.4.0

.github/CODEOWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @ansible-community/molecule @ansible-community/devtools
1+
* @ansible/devtools

.github/release-drafter.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# see https://github.com/ansible/devtools
2-
_extends: ansible/devtools
1+
# see https://github.com/ansible/team-devtools
2+
_extends: ansible/team-devtools

.github/workflows/ack.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
---
2-
# See https://github.com/ansible/devtools/blob/main/.github/workflows/ack.yml
1+
# See https://github.com/ansible/team-devtools/blob/main/.github/workflows/ack.yml
32
name: ack
3+
4+
concurrency:
5+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
6+
cancel-in-progress: true
7+
48
on:
59
pull_request_target:
610
types: [opened, labeled, unlabeled, synchronize]
711

812
jobs:
913
ack:
10-
uses: ansible/devtools/.github/workflows/ack.yml@main
14+
uses: ansible/team-devtools/.github/workflows/ack.yml@main
15+
secrets: inherit

.github/workflows/push.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
---
2-
# See https://github.com/ansible/devtools/blob/main/.github/workflows/push.yml
1+
# See https://github.com/ansible/team-devtools/blob/main/.github/workflows/push.yml
32
name: push
43
on:
54
push:
@@ -10,4 +9,4 @@ on:
109

1110
jobs:
1211
ack:
13-
uses: ansible/devtools/.github/workflows/push.yml@main
12+
uses: ansible/team-devtools/.github/workflows/push.yml@main

.github/workflows/release.yml

+7-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
---
2-
# cspell:ignore mislav
31
name: release
42

53
on:
@@ -8,36 +6,29 @@ on:
86

97
jobs:
108
pypi:
11-
name: Publish to PyPI registry
9+
name: release ${{ github.event.ref }}
1210
environment: release
1311
runs-on: ubuntu-22.04
12+
permissions:
13+
id-token: write
1414

1515
env:
1616
FORCE_COLOR: 1
1717
PY_COLORS: 1
18-
TOXENV: pkg
18+
TOX_PARALLEL_NO_SPINNER: 1
1919

2020
steps:
21-
- name: Switch to using Python 3.10 by default
21+
- name: Switch to using Python 3.12 by default
2222
uses: actions/setup-python@v5
2323
with:
24-
python-version: 3.10
25-
24+
python-version: "3.12"
2625
- name: Install tox
2726
run: python3 -m pip install --user "tox>=4.0.0"
28-
2927
- name: Check out src from Git
3028
uses: actions/checkout@v4
3129
with:
3230
fetch-depth: 0 # needed by setuptools-scm
33-
submodules: true
34-
3531
- name: Build dists
36-
run: python -m tox
37-
32+
run: python -m tox -e pkg
3833
- name: Publish to pypi.org
39-
if: >- # "create" workflows run separately from "push" & "pull_request"
40-
github.event_name == 'release'
4134
uses: pypa/gh-action-pypi-publish@release/v1
42-
with:
43-
password: ${{ secrets.pypi_password }}

.github/workflows/tox.yml

+22-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
---
22
name: tox
33

4+
concurrency:
5+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
6+
cancel-in-progress: true
7+
48
on:
59
push: # only publishes pushes to the main branch to TestPyPI
610
branches: # any integration branch but not tag
711
- "main"
812
pull_request:
9-
branches:
10-
- "main"
11-
12-
concurrency:
13-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
14-
cancel-in-progress: true
15-
16-
env:
17-
FORCE_COLOR: 1 # tox, pytest, ansible-lint
18-
PY_COLORS: 1
13+
workflow_call:
1914

2015
jobs:
2116
pre:
@@ -54,6 +49,7 @@ jobs:
5449

5550
env:
5651
PYTEST_REQPASS: 450
52+
environment: test
5753
steps:
5854
- uses: actions/checkout@v4
5955
with:
@@ -119,14 +115,20 @@ jobs:
119115
# produce a single .coverage file at repo root
120116
run: tox -e coverage
121117

118+
- name: Archive logs
119+
uses: actions/upload-artifact@v4
120+
with:
121+
name: logs-${{ matrix.name }}.zip
122+
path: .tox/**/log/
123+
122124
- name: Upload coverage data
123125
if: ${{ startsWith(matrix.passed_name, 'py') }}
124-
uses: codecov/codecov-action@v3
126+
uses: codecov/codecov-action@v4
125127
with:
126-
name: ${{ matrix.passed_name }}
127-
fail_ci_if_error: false # see https://github.com/codecov/codecov-action/issues/598
128+
name: ${{ matrix.name }}
128129
token: ${{ secrets.CODECOV_TOKEN }}
129-
verbose: true # optional (default = false)
130+
verbose: true
131+
fail_ci_if_error: true
130132

131133
- name: Report failure if git reports dirty status
132134
run: |
@@ -142,10 +144,14 @@ jobs:
142144

143145
needs:
144146
- build
145-
146147
runs-on: ubuntu-latest
147-
148148
steps:
149+
- name: Merge logs into a single archive
150+
uses: actions/upload-artifact/merge@v4
151+
with:
152+
name: logs.zip
153+
pattern: logs-*.zip
154+
delete-merged: true
149155
- name: Decide whether the needed jobs succeeded or failed
150156
uses: re-actors/alls-green@release/v1
151157
with:

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repos:
2323
hooks:
2424
- id: codespell
2525
- repo: https://github.com/psf/black
26-
rev: 23.12.1
26+
rev: 24.2.0
2727
hooks:
2828
- id: black
2929
language_version: python3
@@ -40,14 +40,14 @@ repos:
4040
language_version: python3
4141

4242
- repo: https://github.com/adrienverge/yamllint.git
43-
rev: v1.33.0
43+
rev: v1.35.1
4444
hooks:
4545
- id: yamllint
4646
files: \.(yaml|yml)$
4747
types: [file, yaml]
4848
entry: yamllint --strict
4949
- repo: https://github.com/astral-sh/ruff-pre-commit
50-
rev: "v0.1.13"
50+
rev: "v0.2.2"
5151
hooks:
5252
- id: ruff
5353
args: [--fix, --exit-non-zero-on-fix]
@@ -94,6 +94,6 @@ repos:
9494
- pytest-testinfra
9595
- wcmatch
9696
- repo: https://github.com/ansible/ansible-lint
97-
rev: v6.22.1
97+
rev: v24.2.0
9898
hooks:
9999
- id: ansible-lint

codecov.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
codecov:
2-
require_ci_to_pass: true
31
comment: false
42
coverage:
53
status:
6-
patch: false
7-
project:
8-
default:
9-
threshold: 0.5%
4+
patch: true # we want github annotations

conftest.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""PyTest Config File."""
22

3-
43
import os
54

65
import pytest

mkdocs.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ site_name: Ansible Molecule
33
site_url: https://ansible.readthedocs.io/projects/molecule/
44
repo_url: https://github.com/ansible/molecule
55
edit_uri: blob/main/docs/
6-
copyright: Copyright © 2023 Red Hat, Inc.
6+
copyright: Copyright © 2024 Red Hat, Inc.
77
docs_dir: docs
88
strict: true
99

@@ -32,6 +32,7 @@ theme:
3232
- search.highlight
3333
- search.share
3434
- search.suggest
35+
- toc.follow
3536
- toc.integrate
3637
extra:
3738
generator: false
@@ -80,9 +81,10 @@ nav:
8081

8182
plugins:
8283
- autorefs
83-
- search
84+
- material/search:
85+
separator: '[\s\-,:!=\[\]()"`/]+|\.(?!\d)|&[lg]t;|(?!\b)(?=[A-Z][a-z])'
8486
- material/social
85-
87+
- material/tags
8688
- mkdocstrings:
8789
enable_inventory: true
8890
default_handler: python

src/molecule/app.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Molecule Application Module."""
2+
23
from ansible_compat.runtime import Runtime
34

45

src/molecule/console.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Console and terminal utilities."""
2+
23
import os
34
import sys
45
from typing import Any
@@ -71,6 +72,12 @@ def should_do_markup() -> bool:
7172
return sys.stdout.isatty()
7273

7374

75+
# Define ANSIBLE_FORCE_COLOR if markup is enabled and another value is not
76+
# already given. This assures that Ansible subprocesses are still colored,
77+
# even if they do not run with a real TTY.
78+
if should_do_markup():
79+
os.environ["ANSIBLE_FORCE_COLOR"] = os.environ.get("ANSIBLE_FORCE_COLOR", "1")
80+
7481
console_options: dict[str, Any] = {"emoji": False, "theme": theme, "soft_wrap": True}
7582

7683
console = Console(
@@ -82,9 +89,3 @@ def should_do_markup() -> bool:
8289
console_options_stderr = console_options.copy()
8390
console_options_stderr["stderr"] = True
8491
console_stderr: Console = Console(**console_options_stderr)
85-
86-
# Define ANSIBLE_FORCE_COLOR if markup is enabled and another value is not
87-
# already given. This assures that Ansible subprocesses are still colored,
88-
# even if they do not run with a real TTY.
89-
if should_do_markup():
90-
os.environ["ANSIBLE_FORCE_COLOR"] = os.environ.get("ANSIBLE_FORCE_COLOR", "1")

src/molecule/constants.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Constants used by molecule."""
22

3-
43
RC_SUCCESS = 0
54
RC_TIMEOUT = 3
65
RC_SETUP_ERROR = 4 # Broken setup, like missing Ansible

src/molecule/data/init-scenario.yml

+4
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@
3131
- templates/scenario/*.j2
3232
loop_control:
3333
label: "{{ dest_file | relpath }}"
34+
when:
35+
- ((driver_name in ['containers', 'docker', 'podman']) and
36+
(item | regex_search('create|destroy') is none) or
37+
(driver_name not in ['containers', 'docker', 'podman']))
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
---
2+
driver:
3+
name: {{ driver_name }}
24
platforms:
35
- name: instance
6+
{% if driver_name in ['containers', 'docker', 'podman'] %}
7+
image: quay.io/centos/centos:stream8
8+
pre_build_image: true
9+
{% else %}
410
# you might want to add your own variables here based on what provisioning
511
# you are doing like:
612
# image: quay.io/centos/centos:stream8
13+
{% endif %}

src/molecule/dependency/ansible_galaxy/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Base definition for Ansible Galaxy dependencies."""
2+
23
from molecule import util
34
from molecule.dependency.ansible_galaxy.collections import Collections
45
from molecule.dependency.ansible_galaxy.roles import Roles

src/molecule/dependency/ansible_galaxy/collections.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Ansible Galaxy dependencies for lists of collections."""
2+
23
import logging
34
import os
45

src/molecule/dependency/ansible_galaxy/roles.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Ansible Galaxy dependencies for lists of roles."""
2+
23
import logging
34
import os
45

src/molecule/driver/delegated.py

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class Delegated(Driver):
137137
ansible_connection: local
138138
```
139139
"""
140+
140141
title = "Default driver, user is expected to manage provisioning of test resources."
141142

142143
def __init__(self, config=None) -> None:

src/molecule/provisioner/ansible.py

+8
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,14 @@ def _link_or_update_vars(self):
904904
if not os.path.exists(source):
905905
msg = f"The source path '{source}' does not exist."
906906
util.sysexit_with_message(msg)
907+
if os.path.exists(target):
908+
if os.path.realpath(target) == os.path.realpath(source):
909+
msg = f"Required symlink {target} to {source} exist, skip creation"
910+
LOG.debug(msg)
911+
continue
912+
msg = f"Required symlink {target} exist with another source"
913+
LOG.debug(msg)
914+
os.remove(target)
907915
msg = f"Inventory {source} linked to {target}"
908916
LOG.debug(msg)
909917
os.symlink(source, target)

src/molecule/text.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Text utils."""
2+
23
import re
34

45

src/molecule/util.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -391,5 +391,6 @@ def bool2args(data: bool) -> list[str]:
391391

392392
def print_as_yaml(data: Any) -> None:
393393
"""Render python object as yaml on console."""
394-
result = Syntax(safe_dump(data), "yaml")
394+
# https://github.com/Textualize/rich/discussions/990#discussioncomment-342217
395+
result = Syntax(code=safe_dump(data), lexer="yaml", background_color="default")
395396
console.print(result)

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ passenv = *
8787
usedevelop = true
8888
commands =
8989
linkchecker -f linkcheckerrc docs
90-
mkdocs build --strict
90+
mkdocs build -c --strict {posargs:}
9191
extras =
9292
docs
9393

0 commit comments

Comments
 (0)