dave-shawley/ietfparse

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
version: 2.1

jobs:

  build:
    working_directory: ~/ietfparse
    docker:
      - image: cimg/python:3.10
    steps:
      - run: |
          mkdir -p tmp/
          curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
          chmod +x ./tmp/cc-test-reporter
      - persist_to_workspace:
          root: tmp
          paths:
            - cc-test-reporter

  python-3-test:
    working_directory: ~/ietfparse
    docker:
      - image: cimg/python:3.10
    steps:
      - checkout
      - attach_workspace:
          at: ~/ietfparse/tmp
      - run: |
          mkdir build
          pip install --user 'coverage[toml]' coveralls
          coverage run -m unittest discover
          coverage report
          coverage xml
          ./tmp/cc-test-reporter format-coverage -t coverage.py -o tmp/python3-coverage.json
          coveralls
          cp coverage.xml tmp/
      - persist_to_workspace:
          root: tmp
          paths:
            - python3-coverage.json
            - coverage.xml

  upload-coverage:
    working_directory: ~/ietfparse
    docker:
      - image: cimg/python:3.10
    steps:
      - attach_workspace:
          at: ~/ietfparse/tmp
      - run: |
          ./tmp/cc-test-reporter sum-coverage tmp/*-coverage.json -p 1 -o tmp/codeclimate-total.json
          ./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate-total.json

  update-sonarcloud:
    working_directory: ~/ietfparse
    docker:
      - image: cimg/openjdk:18.0
    steps:
      - checkout
      - attach_workspace:
          at: ~/ietfparse/tmp
      - run: |
          cp tmp/coverage.xml coverage.xml
      - sonarcloud/scan

  distribute-tag:
    working_directory: ~/ietfparse
    docker:
      - image: cimg/python:3.10
    steps:
      - checkout
      - run: |
          pip install --user --upgrade build readme_renderer twine wheel
          python -m build --sdist --wheel
          twine check dist/*
          twine upload --skip-existing dist/*
          curl -XPOST -d "token=$READTHEDOCS_TOKEN" https://readthedocs.org/api/v2/webhook/ietfparse/28564/

orbs:
  sonarcloud: sonarsource/sonarcloud@1.1.1

workflows:
  version: 2
  build-workflow:
    jobs:
      - build
      - python-3-test:
          requires:
            - build
      - upload-coverage:
          requires:
            - python-3-test
      - update-sonarcloud:
          requires:
            - python-3-test
      - distribute-tag:
          context: org-global
          filters:
            branches:
              ignore: /.*/
            tags:
              only: /.*/