Skip to content

Commit

Permalink
Merge pull request #182 from nautobot/u/snaselj-ci-checks
Browse files Browse the repository at this point in the history
  • Loading branch information
whitej6 authored Oct 17, 2023
2 parents b16f5ba + a428375 commit 0b1c5ad
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 3 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ jobs:
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Linting: flake8"
run: "poetry run invoke flake8"
poetry:
runs-on: "ubuntu-22.04"
env:
INVOKE_NAUTOBOT_FIREWALL_MODELS_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Checking: poetry lock file"
run: "poetry run invoke lock --check"
yamllint:
runs-on: "ubuntu-22.04"
env:
Expand All @@ -76,6 +87,7 @@ jobs:
- "bandit"
- "pydocstyle"
- "flake8"
- "poetry"
- "yamllint"
- "black"
runs-on: "ubuntu-22.04"
Expand Down Expand Up @@ -113,9 +125,53 @@ jobs:
run: "cp development/creds.example.env development/creds.env"
- name: "Linting: pylint"
run: "poetry run invoke pylint"
check-migrations:
needs:
- "bandit"
- "pydocstyle"
- "flake8"
- "poetry"
- "yamllint"
- "black"
runs-on: "ubuntu-22.04"
strategy:
fail-fast: true
matrix:
python-version: ["3.11"]
nautobot-version: ["2.0.0"]
env:
INVOKE_NAUTOBOT_FIREWALL_MODELS_PYTHON_VER: "${{ matrix.python-version }}"
INVOKE_NAUTOBOT_FIREWALL_MODELS_NAUTOBOT_VER: "${{ matrix.nautobot-version }}"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Set up Docker Buildx"
id: "buildx"
uses: "docker/setup-buildx-action@v3"
- name: "Build"
uses: "docker/build-push-action@v5"
with:
builder: "${{ steps.buildx.outputs.name }}"
context: "./"
push: false
load: true
tags: "${{ env.PLUGIN_NAME }}/nautobot:${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
file: "./development/Dockerfile"
cache-from: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
cache-to: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
build-args: |
NAUTOBOT_VER=${{ matrix.nautobot-version }}
PYTHON_VER=${{ matrix.python-version }}
- name: "Copy credentials"
run: "cp development/creds.example.env development/creds.env"
- name: "Checking: migrations"
run: "poetry run invoke check-migrations"
unittest:
needs:
- "pylint"
- "check-migrations"
strategy:
fail-fast: true
matrix:
Expand Down
17 changes: 14 additions & 3 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,17 @@ def generate_packages(context):
run_command(context, command)


@task
def lock(context):
@task(
help={
"check": (
"If enabled, check for outdated dependencies in the poetry.lock file, "
"instead of generating a new one. (default: disabled)"
)
}
)
def lock(context, check=False):
"""Generate poetry.lock inside the Nautobot container."""
run_command(context, "poetry lock --no-update")
run_command(context, f"poetry {'check' if check else 'lock --no-update'}")


# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -678,6 +685,10 @@ def tests(context, failfast=False, keepdb=False, lint_only=False):
pydocstyle(context)
print("Running yamllint...")
yamllint(context)
print("Running poetry check...")
lock(context, check=True)
print("Running migrations check...")
check_migrations(context)
print("Running pylint...")
pylint(context)
print("Running mkdocs...")
Expand Down

0 comments on commit 0b1c5ad

Please sign in to comment.