Add Allied Telesis platform #203
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set on GitHub -> Settings -> Secrets and variables -> Actions -> Secrets: | |
# - PYPI_USERNAME: PyPI username | |
# - PYPI_PASSWORD: PyPI password | |
# Set on GitHub -> Settings -> Actions -> General -> Workflow permissions: | |
# - Read and write permissions | |
# Set on GitHub -> Settings -> Environments: | |
# - add users who can review/approve on environment "release" | |
# Set NETBOX_VERSION below to a specific Netbox version. | |
# Set PYTHON_VERSION below to a specific Python version. | |
# Set UBUNTU_VERSION below to a specific Ubuntu version. | |
name: "CI" | |
env: | |
NETBOX_VERSION: v3.5.8 | |
PYTHON_VERSION: v3.10 | |
concurrency: | |
# Cancel any existing runs of this workflow for this same PR | |
group: "${{ github.workflow }}-${{ github.ref }}" | |
cancel-in-progress: true | |
on: # yamllint disable-line rule:truthy | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
precommit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Setup Python3" | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "${{ env.PYTHON_VERSION }}" | |
- name: "Check out NetDoc repository code" | |
uses: actions/checkout@v4 | |
- name: "Install and run pre-commit" | |
uses: pre-commit/[email protected] | |
pylint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Setup Python3" | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "${{ env.PYTHON_VERSION }}" | |
- name: "Check out Netbox repository code" | |
uses: actions/checkout@v4 | |
with: | |
repository: "netbox-community/netbox" | |
ref: "${{ env.NETBOX_VERSION }}" | |
path: "netbox" | |
fetch-depth: "0" | |
- name: "Check out NetDoc repository code" | |
uses: actions/checkout@v4 | |
with: | |
path: "netdoc" | |
fetch-depth: "0" | |
- name: "Install requirements" | |
run: "pip install -r netbox/requirements.txt" | |
- name: "Install NetDoc dependencies" | |
run: "pip install netdoc && pip uninstall -y netdoc" | |
- name: "Install PyLint" | |
run: "pip install pylint==2.17.7" | |
- name: "Run Pylint" | |
run: "cd netdoc && pylint --rcfile=.pylintrc netdoc" | |
test: | |
runs-on: ubuntu-latest | |
needs: | |
- precommit | |
- pylint | |
steps: | |
- name: "Updating APT cache" | |
run: "sudo apt-get update" | |
- name: "Installing PostgreSQL" | |
run: "sudo apt-get install -y postgresql redis" | |
- name: "Starting Redis" | |
run: "sudo systemctl start redis-server" | |
- name: "Starting PostgreSQL" | |
run: "sudo systemctl start postgresql" | |
- name: "Adding PostgreSQL database" | |
run: "sudo su - postgres -c 'psql -c \"create database netbox\"'" | |
- name: "Adding PostgreSQL username" | |
run: sudo su - postgres -c "psql -c \"create user netbox with password '0123456789abcdef'\"" | |
- name: "Setting PostgreSQL database privileges" | |
run: "sudo su - postgres -c 'psql -c \"grant all privileges on database netbox to netbox\"'" | |
- name: "Setting PostgreSQL administrative privileges" | |
run: "sudo su - postgres -c 'psql -c \"alter user netbox createdb\"'" | |
- name: "Setup Python3" | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "${{ env.PYTHON_VERSION }}" | |
- name: "Check out NetDoc repository code" | |
uses: actions/checkout@v4 | |
with: | |
path: "netdoc" | |
fetch-depth: "0" | |
- name: "Check out Netbox repository code" | |
uses: actions/checkout@v4 | |
with: | |
repository: "netbox-community/netbox" | |
ref: "${{ env.NETBOX_VERSION }}" | |
path: "netbox" | |
- name: "Check out NTC-Templates repository code" | |
uses: actions/checkout@v4 | |
with: | |
repository: "networktocode/ntc-templates" | |
path: "ntc-templates" | |
fetch-depth: "0" | |
- name: "Cloning Netbox example configuration" | |
run: "cp -a netbox/netbox/netbox/configuration_example.py netbox/netbox/netbox/configuration.py" | |
- name: "Setting PostgreSQL username on Netbox configuration" | |
run: "sed -i \"s/.*PostgreSQL username.*/ 'USER': 'netbox',/\" netbox/netbox/netbox/configuration.py" | |
- name: "Setting PostgreSQL password on Netbox configuration" | |
run: "sed -i \"s/.*PostgreSQL password.*/ 'PASSWORD': '0123456789abcdef',/\" netbox/netbox/netbox/configuration.py" | |
- name: "Setting Django secret key" | |
run: "sed -i \"s/.*SECRET_KEY.*/SECRET_KEY = '01234567890123456789012345678901234567890123456789'/\" netbox/netbox/netbox/configuration.py" | |
- name: "Enabling NetDoc plugin on Netbox configuration" | |
run: "sed -i \"s/PLUGINS =.*/PLUGINS = ['netdoc']/\" netbox/netbox/netbox/configuration.py" | |
- name: "Configuring NetDoc plugin on Netbox" | |
run: "echo \"PLUGINS_CONFIG = {'netdoc': {'NTC_TEMPLATES_DIR': '${PWD}/ntc-templates/ntc_templates/templates'}}\" >> netbox/netbox/netbox/configuration.py" | |
- name: "Setting NetDoc requirements" | |
run: echo "-e $PWD/netdoc" >> netbox/local_requirements.txt | |
- name: "Upgrade Netbox" | |
run: "netbox/upgrade.sh" | |
- name: "Migrating NetDoc database" | |
run: "netbox/venv/bin/python3 netbox/netbox/manage.py migrate netdoc" | |
- name: "Testing scenarios" | |
run: "netbox/venv/bin/python3 netbox/netbox/manage.py test netdoc --keepdb" |