Skip to content

Commit

Permalink
Merge pull request #12 from bbc/jamesba-last2.7
Browse files Browse the repository at this point in the history
v1.1.2: Last version for py27
  • Loading branch information
jamesba authored Feb 10, 2020
2 parents 8a4d41f + 12f9014 commit f1f56bd
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 70 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# mediajson Changelog

# 1.1.2
- Final supported version for python 2.7
- Some simple fixes to CI, Makefile and tox tooling

## 1.1.1
- Only attempt to parse UUIDs when they comprise the entire string.

Expand Down
135 changes: 72 additions & 63 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,92 +32,101 @@ pipeline {
environment {
http_proxy = "http://www-cache.rd.bbc.co.uk:8080"
https_proxy = "http://www-cache.rd.bbc.co.uk:8080"
PATH = "$HOME/.pyenv/bin:$PATH"
}
stages {
stage ("Parallel Jobs") {
parallel {
stage ("Linting Check") {
stage("Clean Environment") {
steps {
sh 'git clean -dfx'
sh 'rm -rf /tmp/$(basename ${WORKSPACE})/'
}
}
stage("Ensure pyenv has python3.6.8") {
steps {
sh "pyenv install -s 3.6.8"
sh "pyenv local 3.6.8"
}
}
stage ("Linting Check") {
steps {
script {
env.lint_result = "FAILURE"
}
bbcGithubNotify(context: "lint/flake8", status: "PENDING")
// Run the linter, excluding build directories (this can also go in the .flake8 config file)
sh 'make lint'
script {
env.lint_result = "SUCCESS" // This will only run if the sh above succeeded
}
}
post {
always {
bbcGithubNotify(context: "lint/flake8", status: env.lint_result)
}
}
}
stage ("Python Unit Tests") {
stages {
stage ("Python 2.7 Unit Tests") {
steps {
script {
env.lint_result = "FAILURE"
env.py27_result = "FAILURE"
}
bbcGithubNotify(context: "lint/flake8", status: "PENDING")
// Run the linter, excluding build directories (this can also go in the .flake8 config file)
sh 'flake8 --exclude .git,.tox,dist,deb_dist,__pycache__'
bbcGithubNotify(context: "tests/py27", status: "PENDING")
// Use a workdirectory in /tmp to avoid shebang length limitation
sh 'tox -e py27 --recreate --workdir /tmp/$(basename ${WORKSPACE})/tox-py27'
script {
env.lint_result = "SUCCESS" // This will only run if the sh above succeeded
env.py27_result = "SUCCESS" // This will only run if the sh above succeeded
}
}
post {
always {
bbcGithubNotify(context: "lint/flake8", status: env.lint_result)
bbcGithubNotify(context: "tests/py27", status: env.py27_result)
}
}
}
stage ("Python Unit Tests") {
stages {
stage ("Python 2.7 Unit Tests") {
steps {
script {
env.py27_result = "FAILURE"
}
bbcGithubNotify(context: "tests/py27", status: "PENDING")
// Use a workdirectory in /tmp to avoid shebang length limitation
sh 'tox -e py27 --recreate --workdir /tmp/$(basename ${WORKSPACE})/tox-py27'
script {
env.py27_result = "SUCCESS" // This will only run if the sh above succeeded
}
}
post {
always {
bbcGithubNotify(context: "tests/py27", status: env.py27_result)
}
}
}
stage ("Python 3 Unit Tests") {
steps {
script {
env.py3_result = "FAILURE"
}
bbcGithubNotify(context: "tests/py3", status: "PENDING")
// Use a workdirectory in /tmp to avoid shebang length limitation
sh 'tox -e py3 --recreate --workdir /tmp/$(basename ${WORKSPACE})/tox-py3'
script {
env.py3_result = "SUCCESS" // This will only run if the sh above succeeded
}
}
post {
always {
bbcGithubNotify(context: "tests/py3", status: env.py3_result)
}
}
}
}
}
stage ("Debian Source Build") {
stage ("Python 3 Unit Tests") {
steps {
script {
env.debSourceBuild_result = "FAILURE"
env.py3_result = "FAILURE"
}
bbcGithubNotify(context: "deb/sourceBuild", status: "PENDING")

sh 'rm -rf deb_dist'
sh 'python ./setup.py sdist'
sh 'make dsc'
bbcPrepareDsc()
stash(name: "deb_dist", includes: "deb_dist/*")
bbcGithubNotify(context: "tests/py3", status: "PENDING")
// Use a workdirectory in /tmp to avoid shebang length limitation
sh 'tox -e py3 --recreate --workdir /tmp/$(basename ${WORKSPACE})/tox-py3'
script {
env.debSourceBuild_result = "SUCCESS" // This will only run if the steps above succeeded
env.py3_result = "SUCCESS" // This will only run if the sh above succeeded
}
}
post {
always {
bbcGithubNotify(context: "deb/sourceBuild", status: env.debSourceBuild_result)
bbcGithubNotify(context: "tests/py3", status: env.py3_result)
}
}
}
}
}
stage ("Debian Source Build") {
steps {
script {
env.debSourceBuild_result = "FAILURE"
}
bbcGithubNotify(context: "deb/sourceBuild", status: "PENDING")

sh 'rm -rf deb_dist'
sh 'python ./setup.py sdist'
sh 'make dsc'
bbcPrepareDsc()
stash(name: "deb_dist", includes: "deb_dist/*")
script {
env.debSourceBuild_result = "SUCCESS" // This will only run if the steps above succeeded
}
}
post {
always {
bbcGithubNotify(context: "deb/sourceBuild", status: env.debSourceBuild_result)
}
}
}
stage ("Build with pbuilder") {
steps {
bbcGithubNotify(context: "deb/packageBuild", status: "PENDING")
Expand Down Expand Up @@ -191,9 +200,9 @@ pipeline {
script {
for (def dist in bbcGetSupportedUbuntuVersions()) {
bbcDebUpload(sourceFiles: "_result/${dist}-amd64/*",
removePrefix: "_result/${dist}-amd64",
dist: "${dist}",
apt_repo: "ap/python")
removePrefix: "_result/${dist}-amd64",
dist: "${dist}",
apt_repo: "ap/python")
}
}
script {
Expand Down
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ RPM_PREFIX?=$(topdir)/build/rpm
RPMDIRS=BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
RPMBUILDDIRS=$(patsubst %, $(RPM_PREFIX)/%, $(RPMDIRS))

TOX_WORK_DIR?=$(topbuilddir)
TOXDIR=$(TOX_WORK_DIR)/$(MODNAME)/.tox/
TOXENV?=py36
TOX_ACTIVATE=$(TOXDIR)/$(TOXENV)/bin/activate

all:
@echo "$(PROJECT)-$(VERSION)"
@echo "make source - Create source package"
Expand All @@ -53,7 +58,7 @@ install:

clean:
$(PYTHON) $(topdir)/setup.py clean || true
rm -rf $(topbuilddir)/.tox
rm -rf $(TOXDIR)
rm -rf $(topbuilddir)/build/ MANIFEST
rm -rf $(topbuilddir)/dist
rm -rf $(topbuilddir)/deb_dist
Expand All @@ -62,7 +67,18 @@ clean:
find $(topdir) -name '*.py,cover' -delete

test:
tox
tox -c tox.ini

testenv: $(TOX_ACTIVATE)

$(TOX_ACTIVATE): tox.ini setup.py
tox -r -c tox.ini -e $(TOXENV) --notest

lint: $(TOX_ACTIVATE)
. $(TOX_ACTIVATE) && python -m flake8 $(MODNAME) tests

mypy: $(TOX_ACTIVATE)
. $(TOX_ACTIVATE) && python -m mypy -p $(MODNAME)

deb_dist: $(topbuilddir)/dist/$(MODNAME)-$(VERSION).tar.gz
$(PY2DSC) --with-python2=true --with-python3=true $(topbuilddir)/dist/$(MODNAME)-$(VERSION).tar.gz
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# Basic metadata
name = 'mediajson'
version = '1.1.1'
version = '1.1.2'
description = 'A JSON serialiser and parser for python that supports extensions convenient for our media grain formats'
url = 'https://github.com/bbc/rd-apmm-python-lib-mediajson'
author = u'James P. Weaver'
Expand Down
9 changes: 5 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
# and then run "tox" from this directory.

[tox]
envlist = py27, py3
envlist = py27, py36
toxworkdir = {env:TOX_WORK_DIR:{toxinidir}}/mediajson/.tox

[testenv]
commands = nose2 --with-coverage --coverage-report=annotate --coverage-report=term --coverage=mediajson {posargs}
commands = python -m unittest discover -s tests
deps =
nose2
mock
flake8
py36: mypy

0 comments on commit f1f56bd

Please sign in to comment.