sukiyaki/octodns-netbox

View on GitHub
.github/workflows/ci.yml

Summary

Maintainability
Test Coverage
# This is a basic workflow to help you get started with Actions

name: dev workflow

# Controls when the action will run.
on:
  # Triggers the workflow on every pull request events
  pull_request:
    types:
    - opened
    - synchronize
    - reopened

  push:
    branches:
    - main

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  test:
    # The type of runner that the job will run on
    name: Build and Test
    strategy:
      matrix:
        python-versions: ['3.8', '3.9', '3.10', '3.11']
        os: [ubuntu-latest]
    runs-on: ${{ matrix.os }}

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0

    - uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-versions }}

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install tox tox-gh-actions

    - name: Test with tox
      run: tox

    - name: 📥 Upload coverage.xml to Artifact
      uses: actions/upload-artifact@v4
      with:
        path: ${{ github.workspace }}/coverage.xml
        name: ${{ github.run_number }}-coverage-${{ matrix.os }}-${{ matrix.python-versions }}

  publish_coverage_codeclimate:
    name: 🚀 Publish code coverage to Code Climate
    needs: test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0

    - name: 👀 Download all artifacts within the workflow run
      id: download
      uses: actions/download-artifact@v4

    - name: 🔍 Display structure of downloaded files
      run: ls -Rla ${{steps.download.outputs.download-path}}

    - name: 🚀 Publish code coverage to Code Climate
      uses: paambaati/codeclimate-action@v8.0.0
      env:
        CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
      with:
        debug: true
        coverageLocations: |
          ${{steps.download.outputs.download-path}}/${{ github.run_number }}-coverage-*/coverage.xml:coverage.py

    - name: 🗑 Delete artifacts within the workflow run
      uses: geekyeggo/delete-artifact@v5
      if: always()
      with:
        name: ${{ github.run_number }}-coverage-*

  publish_dev_build:
    # if test failed, we should not publish
    name: Publish (Test PyPI)
    needs: test
    if: github.ref == 'refs/heads/main' && github.event_name == 'push'
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0

    - uses: actions/setup-python@v5
      with:
        python-version: '3.11'

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install poetry
        poetry self add "poetry-dynamic-versioning[plugin]"

    - name: Build wheels and source tarball
      run: |
        poetry build

    - name: Publish distribution 📦 to Test PyPI
      uses: pypa/gh-action-pypi-publish@release/v1
      with:
        user: __token__
        password: ${{ secrets.TEST_PYPI_API_TOKEN}}
        repository_url: https://test.pypi.org/legacy/
        skip_existing: true