Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI files #2

Merged
merged 14 commits into from
Nov 12, 2023
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: 🐛 Bug Report
description: Create a report to help us improve Nornir Infrahub
title: 'bug: '
labels: ["type/bug"]
body:
- type: textarea
attributes:
label: Current Behavior
description: A clear description of what the bug is and how it manifests.
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: A clear description of what you expected to happen.
validations:
required: true
- type: textarea
attributes:
label: Steps to Reproduce
description: Please explain the steps required to duplicate this issue.
validations:
required: true
- type: textarea
attributes:
label: Additional Information
description: |
List any other information that is relevant to your request.
Stack traces, related issues, suggestions on how to implement, Stack Overflow links, forum links, etc.
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: 💡 Feature Request
description: Suggest a feature for Nornir Infrahub
title: 'feature: '
labels: ["type/feature"]
body:
- type: textarea
attributes:
label: Describe the Feature Request
description: A clear and concise description of what the feature does.
validations:
required: true
- type: textarea
attributes:
label: Describe the Use Case
description: A clear and concise use case for what problem this feature would solve.
validations:
required: true
- type: textarea
attributes:
label: Additional Information
description: |
List any other information that is relevant to your request.
Stack traces, related issues, suggestions on how to implement, Stack Overflow links, forum links, etc.
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: ✅ Task
description: Create a task for minor issues that isn't a feature or a bug
title: 'task: '
labels: ["type/task"]
body:
- type: textarea
attributes:
label: Task Description
description: A clear description of what it is you think should be done.
validations:
required: true
92 changes: 92 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
# Labels names are important as they are used by Release Drafter to decide
# regarding where to record them in changelog or if to skip them.
#
# The repository labels will be automatically configured using this file and
# the GitHub Action https://github.com/marketplace/actions/github-labeler.
# ----------------------------------
# TYPE (default)
# ----------------------------------
- name: "type/feature"
description: "New feature or request"
color: "a2eeef"

- name: "type/bug"
description: "Something isn't working as expected"
color: "d73a4a"

- name: "type/housekeeping"
description: "Maintenance task"
color: "fef2c0"

# ----------------------------------
# TYPE ALL
# ----------------------------------
- name: "type/question"
description: "Question or discussion"
color: "d876e3"

- name: "type/documentation"
description: "Improvements or additions to documentation"
color: "0075ca"

- name: "type/duplicate"
description: "This issue or pull request already exists"
color: "cfd3d7"

- name: "type/epic"
description: "Large body of work composed of multiple tasks and/or features"
color: "fbd39c"

- name: "type/task"
description: "Body of work related to an epic"
color: "0b8e92"

- name: "type/brainstorming"
description: "Topic for brainstorming, discussions"
color: "e19e0f"

- name: "type/user-centric"
description: "Issue that would improve the overall experience of our users"
color: "ff8c00"

- name: "type/newcomers"
description: "Good for newcomers"
color: "309c56"

# ----------------------------------
# EFFORT
# ----------------------------------
- name: "effort/high"
description: "This issue should be completed in more than a day"
color: "c80464"

- name: "effort/medium"
description: "This issue should be completed in a less than a day"
color: "676a43"

- name: "effort/low"
description: "This issue should be completed in a couple of hours"
color: "eafee4"

# ----------------------------------
# STATUS
# ----------------------------------
- name: "state/blocked"
description: "The issue is currently blocked and cannot be resolved."
color: "e34918"

- name: "state/draft"
description: "The redaction of the issue is still a work in progress"
color: "dcb518"

- name: "state/referenced"
description: "This issue is referenced in our internal tooling"
color: "c9510c"

# ----------------------------------
# CI
# ----------------------------------
- name: "ci/skip-changelog"
description: "Don't include this PR in the changelog"
color: "c30664"
31 changes: 31 additions & 0 deletions .github/release-note.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
# name-template: 'v$RESOLVED_VERSION'
# tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'type/feature'
- title: '🐛 Bug Fixes'
labels:
- 'type/bug'
- title: '🧰 Maintenance'
label: 'type/housekeeping'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
exclude-labels:
- 'ci/skip-changelog'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
# version-resolver:
# major:
# labels:
# - 'major'
# minor:
# labels:
# - 'minor'
# patch:
# labels:
# - 'patch'
# default: patch
template: |
## Changes

$CHANGES
71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
# yamllint disable rule:truthy rule:truthy rule:line-length
name: "CI"
on:
pull_request:
push:
branches:
- develop
- main
- stable

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: "ubuntu-latest"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v3"
- name: "Setup environment"
run: |
pipx install poetry
pip install invoke toml
- name: "Install Linters"
run: "poetry install --only=dev"
- name: "Linting"
run: "poetry run invoke lint"

python-tests:
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
needs: ["lint"]
runs-on: "ubuntu-latest"
timeout-minutes: 30
steps:
- name: "Check out repository code"
uses: "actions/checkout@v3"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: "Setup environment"
run: |
pipx install poetry
pip install invoke toml
- name: "Install Nornir Infrahub"
run: "poetry install"
- name: "Pytest Tests"
run: "poetry run pytest -v tests/"

# coverall-report:
# needs: ["python-tests"]
# if: |
# always() && !cancelled()
# runs-on: ubuntu-latest
# timeout-minutes: 10
# steps:
# - uses: coverallsapp/github-action@v2
# env:
# COVERALLS_SERVICE_NUMBER: ${{ github.sha }}
# with:
# carryforward: "nornir-unit"
# parallel-finished: true
29 changes: 29 additions & 0 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
# yamllint disable rule:truthy
name: github

on:
push:
branches:
- "develop"
- "stable"
paths:
- ".github/labels.yml"
- ".github/workflows/labels.yml"

jobs:
labeler:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Run Labeler
uses: crazy-max/ghaction-github-labeler@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
yaml-file: .github/labels.yml
# exclude: |
# help*
# *issue
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ development/docker-compose.override.yml

.dir-locals.el

dist/*
14 changes: 14 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
extends: default

ignore: |
/.venv
/examples

rules:
new-lines: disable
comments-indentation: disable
line-length:
max: 120
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: false
10 changes: 3 additions & 7 deletions examples/nornir_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ def main():
"address": "http://localhost:8000",
"token": "06438eb2-8019-4776-878c-0941b1f1d1ec",
# defines the Infrahub Node kind that will mapped to Nornir Hosts
"host_node": {
"kind": "InfraDevice"
},
"host_node": {"kind": "InfraDevice"},
# maps a Nornir Host property to an InfraNode attributes or relation
# name is the name of the Nornir Host property we want to map
# mapping is the attribute or relation of the Node from which we have to extract the value
Expand All @@ -30,10 +28,8 @@ def main():
],
# create Nornir groups from InfraNode attributesor relations
# groups is created as attribute__value `site__jfk1`
"group_mappings": [
"site.name"
],
"group_file": "dummy.yml"
"group_mappings": ["site.name"],
"group_file": "dummy.yml",
},
}
)
Expand Down
1 change: 1 addition & 0 deletions examples/nornir_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ def main():

return 0


if __name__ == "__main__":
raise SystemExit(main())
4 changes: 2 additions & 2 deletions nornir_infrahub/plugins/inventory/infrahub.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class InfrahubInventory:
group_file: Path to group file (defaults to ``group.yaml``)
"""

def __init__(
def __init__( # noqa: PLR0913
self,
host_node: Dict[str, Any],
address: str = "http://localhost:8000",
Expand Down Expand Up @@ -169,7 +169,7 @@ def __init__(
)
self.extra_nodes = get_related_nodes(host_node_schema, attrs)

def load(self) -> Inventory:
def load(self) -> Inventory: # noqa: PLR0912
yml = ruamel.yaml.YAML(typ="safe")

hosts = Hosts()
Expand Down
Loading