Skip to content

Commit 18903de

Browse files
committed
Consolidate devel task into unit with --ansible-core-branch flag.
Removes the standalone `invoke devel` task and adds an `--ansible-core-branch` option to `invoke unit` instead. Moves the ansible-core branch install in the Dockerfile after `poetry install` so the lock file version does not overwrite it. Updates the scheduled devel workflow to use the new flag.
1 parent 4b29996 commit 18903de

3 files changed

Lines changed: 14 additions & 44 deletions

File tree

.github/workflows/trigger_scheduled_devel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
- name: "Install invoke"
3434
run: "pip install -U pip && pip install invoke packaging"
3535
- name: "Run tests against ansible-core ${{ env.ANSIBLE_CORE_BRANCH }}"
36-
run: "invoke devel --branch ${{ env.ANSIBLE_CORE_BRANCH }} --skip lint"
36+
run: "invoke unit --ansible-core-branch ${{ env.ANSIBLE_CORE_BRANCH }} --skip lint"

Dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ COPY pyproject.toml poetry.lock ./
3737
# Install only package Dependencies
3838
RUN poetry install --only main
3939

40-
# Optionally install ansible-core from a specific branch (e.g. "devel" or "milestone")
41-
ARG ANSIBLE_CORE_BRANCH
42-
RUN if [ -n "${ANSIBLE_CORE_BRANCH}" ]; then \
43-
pip install --upgrade pip setuptools && \
44-
pip install --force-reinstall --no-deps \
45-
"https://github.com/ansible/ansible/archive/${ANSIBLE_CORE_BRANCH}.tar.gz"; \
46-
fi
47-
4840
#########
4941
# Linting
5042
#
@@ -57,6 +49,15 @@ ENV SKIP_LINT_TESTS=${SKIP_LINT_TESTS}
5749
# Install dev dependencies
5850
RUN poetry install
5951

52+
# Optionally install ansible-core from a specific branch (e.g. "devel" or "milestone")
53+
# This must come AFTER poetry install so the lock file version doesn't overwrite it.
54+
ARG ANSIBLE_CORE_BRANCH
55+
RUN if [ -n "${ANSIBLE_CORE_BRANCH}" ]; then \
56+
pip install --upgrade pip setuptools && \
57+
pip install --force-reinstall --no-deps \
58+
"https://github.com/ansible/ansible/archive/${ANSIBLE_CORE_BRANCH}.tar.gz"; \
59+
fi
60+
6061
# Copy in the application source and everything not explicitly banned by .dockerignore
6162
COPY . .
6263

tasks.py

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,16 @@ def lint(context):
242242
help={
243243
"verbose": "Run the tests with verbose output; can be provided multiple times for more verbosity (e.g. -v, -vv, -vvv)",
244244
"skip": "Skip specific tests (choices: lint, sanity, unit); can be provided multiple times (e.g. --skip lint --skip sanity)",
245+
"ansible_core_branch": "Test against a specific ansible-core git branch (e.g. 'devel', 'milestone')",
245246
},
246247
iterable=["skip"],
247248
incrementable=["verbose"],
248249
)
249-
def unit(context, verbose=0, skip=None):
250+
def unit(context, verbose=0, skip=None, ansible_core_branch=None):
250251
"""Run unit tests."""
251252
env = {"PYTHON_VER": context.nautobot_ansible.python_ver}
253+
if ansible_core_branch is not None:
254+
env["ANSIBLE_CORE_BRANCH"] = ansible_core_branch
252255
if verbose:
253256
env["ANSIBLE_SANITY_ARGS"] = f"-{'v' * verbose}"
254257
env["ANSIBLE_UNIT_ARGS"] = f"-{'v' * verbose}"
@@ -324,40 +327,6 @@ def integration(context, verbose=0, tags=None, update_inventories=False, skip=No
324327
destroy(context)
325328

326329

327-
@task(
328-
help={
329-
"branch": "The ansible-core git branch to test against (default: devel)",
330-
"python_ver": "Python version to use (default: 3.12)",
331-
"verbose": "Run the tests with verbose output; can be provided multiple times for more verbosity",
332-
"skip": "Skip specific tests (choices: lint, sanity, unit); can be provided multiple times",
333-
},
334-
iterable=["skip"],
335-
incrementable=["verbose"],
336-
)
337-
def devel(context, branch="devel", python_ver="3.12", verbose=0, skip=None):
338-
"""Run sanity and unit tests against an ansible-core development branch."""
339-
env = {
340-
"PYTHON_VER": python_ver,
341-
"ANSIBLE_CORE_BRANCH": branch,
342-
}
343-
if verbose:
344-
env["ANSIBLE_SANITY_ARGS"] = f"-{'v' * verbose}"
345-
env["ANSIBLE_UNIT_ARGS"] = f"-{'v' * verbose}"
346-
if skip is not None:
347-
if "lint" in skip:
348-
env["SKIP_LINT_TESTS"] = "true"
349-
if "sanity" in skip:
350-
env["SKIP_SANITY_TESTS"] = "true"
351-
if "unit" in skip:
352-
env["SKIP_UNIT_TESTS"] = "true"
353-
print(f"Running tests against ansible-core branch: {branch}")
354-
context.run(
355-
f"docker compose --project-name {context.nautobot_ansible.project_name} up --build --force-recreate --exit-code-from unit unit",
356-
env=env,
357-
)
358-
context.run(f"docker compose --project-name {context.nautobot_ansible.project_name} down")
359-
360-
361330
@task(
362331
help={
363332
"force": "Force the build command to create a new collection, overwriting any existing files.",

0 commit comments

Comments
 (0)