Skip to content

Commit

Permalink
Merge pull request #242 from joewesch/update_tests
Browse files Browse the repository at this point in the history
Updating tests
  • Loading branch information
jvanderaa authored Sep 6, 2023
2 parents 32ecd24 + 0ddbbfd commit 691f4c9
Show file tree
Hide file tree
Showing 40 changed files with 2,009 additions and 2,992 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: "Integration Tests"
on: # yamllint disable
workflow_call:
inputs:
runs-on:
description: "The OS to run the job on"
required: false
default: "ubuntu-22.04"
type: string
python-version:
description: "The Python version to use"
required: true
type: string
nautobot-version:
description: "The Nautobot version to use"
required: true
type: string
ansible-version:
description: "The Ansible version to use"
required: true
type: string

jobs:
integration:
runs-on: "${{ inputs.runs-on }}"
env:
INVOKE_NAUTOBOT_ANSIBLE_PYTHON_VER: "${{ inputs.python-version }}"
INVOKE_NAUTOBOT_ANSIBLE_NAUTOBOT_VER: "${{ inputs.nautobot-version }}"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v3"
- name: "Set up Python"
uses: "actions/setup-python@v3"
with:
python-version: "${{ inputs.python-version }}"
- name: "Install invoke"
run: "pip install -U pip && pip install invoke"
- name: "Install poetry"
run: "curl -sSL https://install.python-poetry.org | python3 -"
- name: "Install ansible-core"
# This ensures that even if the poetry.lock file updates we still test the right version
run: "poetry add ansible-core@~${{ inputs.ansible-version }}"
- name: "Start containers"
run: "invoke start"
- name: "Tests"
run: "invoke integration"
145 changes: 0 additions & 145 deletions .github/workflows/jobs.yml

This file was deleted.

94 changes: 94 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
name: "Tests"
on: # yamllint disable
workflow_call:
inputs:
runs-on:
description: "The OS to run the job on"
required: false
default: "ubuntu-22.04"
type: string
full-integration:
description: "Run full integration tests"
required: false
default: false
type: boolean

jobs:
lint:
runs-on: "${{ inputs.runs-on }}"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v3"
- name: "Install invoke"
run: "pip install -U pip && pip install invoke"
- name: "Linting"
run: "invoke lint"
unit:
runs-on: "${{ inputs.runs-on }}"
strategy:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
env:
INVOKE_NAUTOBOT_ANSIBLE_PYTHON_VER: "${{ matrix.python-version }}"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v3"
- name: "Install invoke"
run: "pip install -U pip && pip install invoke"
- name: "Tests"
run: "invoke unit"
needs:
- "lint"
integration_partial:
# Only run a subset of integration tests on normal PRs
if: ${{ inputs.full-integration == false }}
uses: ./.github/workflows/integration_tests.yml
strategy:
fail-fast: false
matrix:
python-version:
- "3.9"
nautobot-version:
- "1.6"
ansible-version:
- "2.14"
- "2.15"
with:
python-version: "${{ matrix.python-version }}"
nautobot-version: "${{ matrix.nautobot-version }}"
ansible-version: "${{ matrix.ansible-version }}"
needs:
- "unit"
integration_full:
if: ${{ inputs.full-integration == true }}
uses: ./.github/workflows/integration_tests.yml
strategy:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
nautobot-version:
- "1.4"
- "1.5"
- "1.6"
ansible-version:
- "2.14"
- "2.15"
exclude:
- python-version: "3.11"
nautobot-version: "1.4"
- python-version: "3.11"
nautobot-version: "1.5"
with:
python-version: "${{ matrix.python-version }}"
nautobot-version: "${{ matrix.nautobot-version }}"
ansible-version: "${{ matrix.ansible-version }}"
needs:
- "unit"
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
---
name: "CI"
name: "Pull Requests (main)"
concurrency: # Cancel any existing runs of this workflow for this same PR
group: "${{ '{{ github.workflow }}' }}-${{ '{{ github.ref }}' }}"
cancel-in-progress: true
on: # yamllint disable
push:
pull_request:
branches:
- "develop"
- "main"
pull_request:
release:
types: [published]

jobs:
ci:
uses: ./.github/workflows/jobs.yml
tests:
uses: ./.github/workflows/tests.yml
with:
full-integration: true
15 changes: 15 additions & 0 deletions .github/workflows/trigger_pr_normal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: "Pull Requests (normal)"
concurrency: # Cancel any existing runs of this workflow for this same PR
group: "${{ '{{ github.workflow }}' }}-${{ '{{ github.ref }}' }}"
cancel-in-progress: true
on: # yamllint disable
pull_request:
branches-ignore:
- "main"

jobs:
tests:
uses: ./.github/workflows/tests.yml
with:
full-integration: false
55 changes: 55 additions & 0 deletions .github/workflows/trigger_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
name: "Release"
on: # yamllint disable
release:
types: [published]

jobs:
tests:
uses: ./.github/workflows/tests.yml
with:
full-integration: true
publish_github:
name: "Publish to GitHub"
runs-on: "${{ inputs.runs-on }}"
if: "startsWith(github.ref, 'refs/tags/v')"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v3"
- name: "Set up Python"
uses: "actions/setup-python@v3"
with:
python-version: "3.9"
- name: "Install Python Packages"
run: "pip install ansible-core"
- name: "Build the collection"
run: "ansible-galaxy collection build --output-path build"
- name: "Upload binaries to release"
uses: "svenstaro/upload-release-action@v2"
with:
repo_token: "${{ secrets.GH_NAUTOBOT_BOT_TOKEN }}"
file: "build/*"
tag: "${{ github.ref }}"
overwrite: true
file_glob: true
needs:
- "tests"
publish_galaxy:
name: "Publish to Ansible Galaxy"
runs-on: "${{ inputs.runs-on }}"
if: "startsWith(github.ref, 'refs/tags/v')"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v3"
- name: "Set up Python"
uses: "actions/setup-python@v3"
with:
python-version: "3.9"
- name: "Install Python Packages"
run: "pip install ansible-core"
- name: "Build the collection"
run: "ansible-galaxy collection build --output-path build"
- name: "Publish the collection"
run: "ansible-galaxy collection publish build/* --api-key=${{ secrets.GALAXY_API_TOKEN }}"
needs:
- "tests"
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ on: # yamllint disable
- cron: "20 3 * * 1"

jobs:
ci:
uses: ./.github/workflows/jobs.yml
tests:
uses: ./.github/workflows/tests.yml
with:
full-integration: true
Loading

0 comments on commit 691f4c9

Please sign in to comment.