diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..aae74bb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,90 @@ +name: ci + +on: [push] + +env: + PYTHON_VERSION: '3.9' + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Run pre-commit + uses: pre-commit/action@v3.0.1 + + mypy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up PDM + uses: pdm-project/setup-pdm@v4 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Install dependencies + run: | + sudo apt-get install -y librrd-dev + pdm sync -G mypy + - name: Run mypy + run: | + pdm run mypy meshinfo tests + + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: + - "3.9" + - "3.10" + - "3.11" + + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: meshmap + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - uses: actions/checkout@v4 + - name: Set up PDM + uses: pdm-project/setup-pdm@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + sudo apt-get install -y librrd-dev + pdm sync -G testing + - name: Run pytest + run: | + pdm run pytest --cov=meshinfo + env: + MESHMAP_COLLECTOR_DATA_DIR: "." + POSTGRES_HOST: localhost + POSTGRES_PASSWORD: meshmap + + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up PDM + uses: pdm-project/setup-pdm@v4 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Install dependencies + run: | + sudo apt-get install -y librrd-dev + pdm sync -G docs + - name: Run Sphinx + run: pdm run sphinx-build -W --keep-going -b html docs docs/_build/html diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 05f34cc..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: Mesh Info Tests - -on: [push] - -jobs: - pre-commit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pre-commit - - name: Run pre-commit - run: pre-commit run --all-files - - tests: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: - - "3.9" - - "3.10" - - "3.11" - - services: - postgres: - image: postgres - env: - POSTGRES_PASSWORD: meshmap - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - - steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Cache pip - uses: actions/cache@v3 - with: - path: | - ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y librrd-dev - python -m pip install --upgrade pip wheel - pip install -r requirements.txt -e .[tests] - - name: Run flake8 - run: flake8 meshinfo tests - - name: Run mypy - run: mypy meshinfo tests - - name: Run pytest - run: pytest --cov=meshinfo - env: - MESHMAP_COLLECTOR_DATA_DIR: "." - POSTGRES_HOST: localhost - POSTGRES_PASSWORD: meshmap - - docs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y librrd-dev - python -m pip install --upgrade pip wheel - pip install -r requirements.txt -e .[docs] - - name: Run Sphinx - run: sphinx-build -W --keep-going -b html docs docs/_build/html diff --git a/.gitignore b/.gitignore index 8a009c8..82f9275 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,3 @@ -# Created by https://www.toptal.com/developers/gitignore/api/python -# Edit at https://www.toptal.com/developers/gitignore?templates=python - -### Python ### # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -18,11 +14,12 @@ dist/ downloads/ eggs/ .eggs/ +lib/ +lib64/ parts/ sdist/ var/ wheels/ -pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg @@ -52,7 +49,7 @@ coverage.xml *.py,cover .hypothesis/ .pytest_cache/ -pytestdebug.log +cover/ # Translations *.mo @@ -73,9 +70,9 @@ instance/ # Sphinx documentation docs/_build/ -doc/_build/ # PyBuilder +.pybuilder/ target/ # Jupyter Notebook @@ -86,7 +83,9 @@ profile_default/ ipython_config.py # pyenv -.python-version +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. @@ -96,9 +95,23 @@ ipython_config.py #Pipfile.lock # poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control #poetry.lock -# PEP 582; used by e.g. github.com/David-OConnor/pyflow +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/latest/usage/project/#working-with-version-control +.pdm.toml +.pdm-python +.pdm-build/ + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm __pypackages__/ # Celery stuff @@ -110,14 +123,12 @@ celerybeat.pid # Environments .env -.env/ -.venv/ +.venv env/ venv/ ENV/ env.bak/ venv.bak/ -pythonenv* # Spyder project settings .spyderproject @@ -140,14 +151,12 @@ dmypy.json # pytype static type analyzer .pytype/ -# operating system-related files -# file properties cache/storage on macOS -*.DS_Store -# thumbnail cache on Windows -Thumbs.db - -# profiling data -.prof - +# Cython debug symbols +cython_debug/ -# End of https://www.toptal.com/developers/gitignore/api/python +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 3ac7ece..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,93 +0,0 @@ -default: - image: python:3.9 - -variables: - PIP_CACHE_DIR: ${CI_PROJECT_DIR}/.cache/pip - PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit - POSTGRES_DB: tests - POSTGRES_USER: meshmap - POSTGRES_HOST_AUTH_METHOD: trust - -stages: - - prep - - test - -pre-commit: - # Run pre-commit first to warm up the cache - stage: prep - script: - - python -m pip install -U pip - - pip install pre-commit - - pre-commit run --all-files - cache: - key: pre-commit - paths: - - .cache/pip - - .cache/pre-commit - -# Template to prepare Poetry (for use with `extends`) -.prep: - before_script: - - apt-get update - - apt-get install -y librrd-dev - - python -m pip install -U pip - - pip install -r requirements.txt -r dev-requirements.txt - - pip install -e . - -flake8: - stage: test - extends: .prep - script: - - flake8 meshinfo tests --format=junit-xml --output=flake8-report.xml - artifacts: - reports: - junit: flake8-report.xml - cache: - paths: - - .cache/pip - policy: pull - -mypy: - stage: test - extends: .prep - script: - - mypy meshinfo --junit-xml=mypy-report.xml - artifacts: - reports: - junit: mypy-report.xml - cache: - paths: - - .cache/pip - policy: pull - -# Template for pytest to simplify testing different versions of Python -.pytest: - stage: test - extends: .prep - services: - - postgres:12 - script: - - pytest --cov=meshinfo --junit-xml=pytest-report.xml - coverage: '/^TOTAL.+?(\d+\%)$/' - artifacts: - reports: - junit: pytest-report.xml - -pytest 3.9: - extends: .pytest - image: python:3.9 - cache: - key: poetry39 - paths: - - .cache/pip - -pytest 3.10: - extends: .pytest - image: python:3.10 - cache: - key: poetry310 - paths: - - .cache/pip - -include: - - template: Security/Dependency-Scanning.gitlab-ci.yml diff --git a/.pdm-python b/.pdm-python deleted file mode 100644 index 209e5d1..0000000 --- a/.pdm-python +++ /dev/null @@ -1 +0,0 @@ -/home/smsearcy/Projects/mesh-info/.venv/bin/python