Skip to content

Commit

Permalink
Merge pull request #10 from soda480/0.3.1
Browse files Browse the repository at this point in the history
0.3.1
  • Loading branch information
soda480 authored Jul 10, 2022
2 parents 0612f67 + 36473e2 commit 0afb7c3
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 39 deletions.
68 changes: 45 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,56 @@
name: build
on:
schedule:
- cron: "0 8 * * *"
push:
branches:
- '**'
pull_request:
branches:
- main

jobs:
build:
build-images:
strategy:
matrix:
version: ['3.7', '3.8', '3.9', '3.10']
name: Build Python Docker images
runs-on: ubuntu-20.04
container: python:3.9-slim

steps:
- uses: actions/checkout@v2

- name: Install pybuilder
run: pip install pybuilder

- name: Execute build
run: pyb

- name: Install Codecov requirements
run: |
apt-get update
apt-get install -y bash curl
sed -e 's,filename="pybuilder-radon/,filename="src/main/python/pybuilder_radon/,g' target/reports/pybuilder-radon_coverage.xml > coverage.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.xml
- uses: actions/checkout@v3
- name: build pybradon ${{ matrix.version }} image
run:
docker image build --build-arg PYTHON_VERSION=${{ matrix.version }} -t pybradon:${{ matrix.version }} .
- name: save pybradon ${{ matrix.version }} image
if: ${{ matrix.version == '3.9' }}
run: |
mkdir -p images
docker save --output images/pybradon-${{ matrix.version }}.tar pybradon:${{ matrix.version }}
- name: upload pybradon ${{ matrix.version }} image artifact
if: ${{ matrix.version == '3.9' }}
uses: actions/upload-artifact@v2
with:
name: image
path: images/pybradon-${{ matrix.version }}.tar
coverage:
name: Publish Code Coverage Report
needs: build-images
runs-on: ubuntu-20.04
steps:
- name: download image artifact
uses: actions/download-artifact@v2
with:
name: image
path: images/
- name: load image
run:
docker load --input images/pybradon-3.9.tar
- name: prepare report
run: |
ID=$(docker create pybradon:3.9)
docker cp $ID:/code/target/reports/pybuilder-radon_coverage.xml pybradon_coverage.xml
sed -i -e 's,filename="pybradon/,filename="src/main/python/pybradon/,g' pybradon_coverage.xml
- name: upload report
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: pybradon_coverage.xml
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM python:3.9-slim
ARG PYTHON_VERSION=3.9
FROM python:${PYTHON_VERSION}-slim
ENV PYTHONDONTWRITEBYTECODE 1
WORKDIR /code
COPY . /code/
RUN pip install pybuilder
RUN pyb
RUN pip install --upgrade pip && pip install pybuilder
RUN pyb -X
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# pybuilder-radon #
# pybuilder-radon
[![GitHub Workflow Status](https://github.com/soda480/pybuilder-radon/workflows/build/badge.svg)](https://github.com/soda480/pybuilder-radon/actions)
[![Code Coverage](https://codecov.io/gh/soda480/pybuilder-radon/branch/main/graph/badge.svg)](https://codecov.io/gh/soda480/pybuilder-radon)
[![Code Grade](https://api.codiga.io/project/19887/status/svg)](https://app.codiga.io/public/project/19887/pybuilder-radon/dashboard)
[![PyPI version](https://badge.fury.io/py/pybuilder-radon.svg)](https://badge.fury.io/py/pybuilder-radon)
[![python](https://img.shields.io/badge/python-3.9-teal)](https://www.python.org/downloads/)
[![python](https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9%20%7C%203.10-teal)](https://www.python.org/downloads/)

A pybuilder plugin that checks the cyclomatic complexity of your project using `radon`. For more information about radon refer to the [radon pypi page](https://pypi.org/project/radon/).

Expand All @@ -17,7 +17,7 @@ use_plugin('pypi:pybuilder_radon')
use_plugin('pypi:pybuilder_radon', '~=0.1.2')
```

### cyclomatic complexity ###
### cyclomatic complexity

Cyclomatic complexity is a software metric used to indicate the complexity of a program. It is a quantitative measure of the number of linearly independent paths through a program's source code. Cyclomatic complexity can be used to measure code complexity. The higher the complexity score the more complex the code, which typically translates to the code being more difficult to understand, maintain and to test. The number of the Cyclomatic complexity depends on how many different execution paths or control flow of your code can execute depending on various inputs. The metrics for Cyclomatic Complexity are:

Expand All @@ -30,7 +30,7 @@ more than 50 | very complex | unable to test, high risk

Refer to [cyclomatic complexity](https://www.c-sharpcorner.com/article/code-metrics-cyclomatic-complexity/) for more information.

### Pybuilder radon properties ###
### Pybuilder radon properties

The pybuilder task `pyb radon` will use radon to to analyze your project and display the average cyclomatic complexity, verbose mode will display complexity of all classes, functions and methods analyzed. The following plugin properties are available to further configure the plugin's execution.

Expand All @@ -46,7 +46,7 @@ project.set_property('radon_break_build_average_complexity_threshold', 4)
project.set_property('radon_break_build_complexity_threshold', 10)
```

### Development ###
### Development

Clone the repository and ensure the latest version of Docker is installed on your development server.

Expand All @@ -64,7 +64,7 @@ docker container run \
-it \
-v $PWD:/code \
pybradon:latest \
/bin/bash
bash
```

Execute the build:
Expand Down
15 changes: 10 additions & 5 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@
use_plugin('python.flake8')
use_plugin('python.coverage')
use_plugin('python.distutils')

use_plugin('pypi:pybuilder_bandit')
use_plugin('pypi:pybuilder_anybadge')

name = 'pybuilder-radon'
authors = [Author('Emilio Reyes', '[email protected]')]
summary = 'Pybuilder plugin for radon cyclomatic complexity'
url = 'https://github.com/soda480/pybuilder-radon'
version = '0.3.0'
version = '0.3.1'
default_task = [
'clean',
'publish'
'analyze',
'publish',
'bandit',
'anybadge'
]
license = 'Apache License, Version 2.0'
description = summary
Expand All @@ -36,7 +40,7 @@ def set_properties(project):
project.set_property('flake8_include_scripts', True)
project.set_property('flake8_include_test_sources', True)
project.set_property('flake8_ignore', 'F401, E501')
project.build_depends_on_requirements('requirements-build.txt')
project.build_depends_on('mock')
project.depends_on_requirements('requirements.txt')
project.set_property('distutils_readme_description', True)
project.set_property('distutils_description_overwrite', True)
Expand All @@ -50,11 +54,12 @@ def set_properties(project):
'License :: OSI Approved :: Apache Software License',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Topic :: Software Development :: Build Tools'])
project.set_property('anybadge_exclude', 'vulnerabilities, coverage')
# only for functional testing plugin
# project.set_property('radon_break_build_average_complexity_threshold', 2.74)
# project.set_property('radon_break_build_complexity_threshold', 4)
5 changes: 5 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
versions=( '3.7' '3.8' '3.9' '3.10' )
for version in "${versions[@]}";
do
docker image build --build-arg PYTHON_VERSION=$version -t pybradon:$version .
done
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["pybuilder>=0.12.0"]
build-backend = "pybuilder.pep517"
2 changes: 0 additions & 2 deletions requirements-build.txt

This file was deleted.

0 comments on commit 0afb7c3

Please sign in to comment.