ci.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. ---
  2. name: CI
  3. on:
  4. push:
  5. paths-ignore:
  6. - '.github/ISSUE_TEMPLATE/**'
  7. - '.github/PULL_REQUEST_TEMPLATE.md'
  8. - 'contrib/**'
  9. - 'docs/**'
  10. - 'netbox/translations/**'
  11. pull_request:
  12. paths-ignore:
  13. - '.github/ISSUE_TEMPLATE/**'
  14. - '.github/PULL_REQUEST_TEMPLATE.md'
  15. - 'contrib/**'
  16. - 'docs/**'
  17. - 'netbox/translations/**'
  18. permissions:
  19. contents: read
  20. # Add concurrency group to control job running
  21. concurrency:
  22. group: ${{ github.event_name }}-${{ github.ref }}-${{ github.actor }}
  23. cancel-in-progress: true
  24. jobs:
  25. build:
  26. name: >-
  27. Tests (Python ${{ matrix.python-version }},
  28. Node ${{ matrix.node-version }}${{ matrix.coverage && ', coverage' || '' }})
  29. runs-on: ubuntu-latest
  30. env:
  31. NETBOX_CONFIGURATION: netbox.configuration_testing
  32. strategy:
  33. matrix:
  34. python-version: ['3.12', '3.13', '3.14']
  35. node-version: ['20.x']
  36. include:
  37. - coverage: false
  38. # Run coverage only once, using the Python 3.14 job.
  39. - python-version: '3.14'
  40. node-version: '20.x'
  41. coverage: true
  42. services:
  43. redis:
  44. image: redis
  45. ports:
  46. - 6379:6379
  47. postgres:
  48. image: postgres
  49. env:
  50. POSTGRES_USER: netbox
  51. POSTGRES_PASSWORD: netbox
  52. options: >-
  53. --health-cmd pg_isready
  54. --health-interval 10s
  55. --health-timeout 5s
  56. --health-retries 5
  57. ports:
  58. - 5432:5432
  59. steps:
  60. - name: Check out repo
  61. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  62. - name: Check Python linting & PEP8 compliance
  63. uses: astral-sh/ruff-action@0ce1b0bf8b818ef400413f810f8a11cdbda0034b # v4.0.0
  64. with:
  65. version: "0.15.10"
  66. args: "check --output-format=github"
  67. src: "netbox/"
  68. - name: Set up Python ${{ matrix.python-version }}
  69. uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
  70. with:
  71. python-version: ${{ matrix.python-version }}
  72. - name: Use Node.js ${{ matrix.node-version }}
  73. uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
  74. with:
  75. node-version: ${{ matrix.node-version }}
  76. - name: Install Yarn Package Manager
  77. run: npm install -g yarn
  78. - name: Setup Node.js with Yarn Caching
  79. uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
  80. with:
  81. node-version: ${{ matrix.node-version }}
  82. cache: yarn
  83. cache-dependency-path: netbox/project-static/yarn.lock
  84. - name: Install Frontend Dependencies
  85. run: yarn --cwd netbox/project-static
  86. - name: Install dependencies & set up configuration
  87. run: |
  88. python -m pip install --upgrade pip
  89. pip install -r requirements.txt
  90. pip install coverage tblib
  91. - name: Build documentation
  92. run: zensical build
  93. - name: Collect static files
  94. run: python netbox/manage.py collectstatic --no-input
  95. - name: Check for missing migrations
  96. run: python netbox/manage.py makemigrations --check
  97. - name: Check UI ESLint, TypeScript, and Prettier Compliance
  98. run: yarn --cwd netbox/project-static validate
  99. - name: Validate Static Asset Integrity
  100. run: scripts/verify-bundles.sh
  101. - name: Run tests
  102. if: ${{ ! matrix.coverage }}
  103. run: python netbox/manage.py test netbox/ --parallel
  104. - name: Run tests with coverage
  105. if: ${{ matrix.coverage }}
  106. run: coverage run netbox/manage.py test netbox/ --parallel
  107. - name: Combine coverage data
  108. if: ${{ matrix.coverage }}
  109. run: coverage combine
  110. - name: Show coverage report
  111. if: ${{ matrix.coverage }}
  112. run: coverage report