|
| 1 | +name: Lint and tests |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - "!release" |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }} |
| 11 | + cancel-in-progress: false |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: write |
| 15 | + checks: write |
| 16 | + pull-requests: write |
| 17 | + |
| 18 | +jobs: |
| 19 | + lint: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + timeout-minutes: 10 |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v4 |
| 25 | + - name: Setup Python |
| 26 | + uses: actions/setup-python@v5 |
| 27 | + with: |
| 28 | + python-version: "3.10" |
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + python -m pip install --upgrade pip |
| 32 | + pip install . |
| 33 | + pip install .[dev] |
| 34 | + pip install .[test] |
| 35 | + - name: Build documentation |
| 36 | + run: mkdocs build |
| 37 | + - name: Run pycodestyle |
| 38 | + run: | |
| 39 | + pycodestyle --ignore=W504,E501 netbox_branching/ |
| 40 | + tests: |
| 41 | + runs-on: ubuntu-latest |
| 42 | + timeout-minutes: 10 |
| 43 | + strategy: |
| 44 | + matrix: |
| 45 | + python-version: [ "3.10", "3.11", "3.12" ] |
| 46 | + services: |
| 47 | + redis: |
| 48 | + image: redis |
| 49 | + ports: |
| 50 | + - 6379:6379 |
| 51 | + postgres: |
| 52 | + image: postgres |
| 53 | + env: |
| 54 | + POSTGRES_USER: netbox |
| 55 | + POSTGRES_PASSWORD: netbox |
| 56 | + options: >- |
| 57 | + --health-cmd pg_isready |
| 58 | + --health-interval 10s |
| 59 | + --health-timeout 5s |
| 60 | + --health-retries 5 |
| 61 | + ports: |
| 62 | + - 5432:5432 |
| 63 | + steps: |
| 64 | + - name: Checkout netbox-branching |
| 65 | + uses: actions/checkout@v4 |
| 66 | + with: |
| 67 | + path: netbox-branching |
| 68 | + - name: Setup Python ${{ matrix.python-version }} |
| 69 | + uses: actions/setup-python@v5 |
| 70 | + with: |
| 71 | + python-version: ${{ matrix.python-version }} |
| 72 | + - name: Checkout netbox |
| 73 | + uses: actions/checkout@v4 |
| 74 | + with: |
| 75 | + repository: "netbox-community/netbox" |
| 76 | + path: netbox |
| 77 | + - name: Install netbox-branching |
| 78 | + working-directory: netbox-branching |
| 79 | + run: | |
| 80 | + # Include tests directory for test |
| 81 | + sed -i 's/exclude-package-data/#exclude-package-data/g' pyproject.toml |
| 82 | + python -m pip install --upgrade pip |
| 83 | + pip install . |
| 84 | + pip install .[test] |
| 85 | + - name: Install dependencies & configure plugin |
| 86 | + working-directory: netbox |
| 87 | + run: | |
| 88 | + ln -s $(pwd)/../netbox-branching/testing/configuration.py netbox/netbox/configuration.py |
| 89 | + ln -s $(pwd)/../netbox-branching/testing/local_settings.py netbox/netbox/local_settings.py |
| 90 | + |
| 91 | + python -m pip install --upgrade pip |
| 92 | + pip install -r requirements.txt -U |
| 93 | + - name: Run tests |
| 94 | + working-directory: netbox |
| 95 | + run: | |
| 96 | + python netbox/manage.py test netbox_branching.tests --keepdb |
0 commit comments