Skip to content

Commit

Permalink
Merge pull request #44 from bbc/dev
Browse files Browse the repository at this point in the history
Merge dev -> master
  • Loading branch information
jamesba authored Mar 6, 2020
2 parents 3319e60 + 4468030 commit 94c315a
Show file tree
Hide file tree
Showing 23 changed files with 517 additions and 2,598 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# mediatimestamp Changelog

## 2.0.0
- Dropped all support for python 2.7
- Swapped the mutable and immutable defaults
- Removed the inclusion of the constants at the top level
- Removed all mutable timestamps

## 1.7.3
- Normalise time ranges where start > end to equal TimeRange.never().
- Normalise inclusivity for unbounded time ranges to equal TimeRange.eternity().

## 1.7.2
- Require Python version 3.6 rather than 3.
- This is the final version of this library to support Python 2.7

## 1.7.1
- Correct inclusivity names in `timerange_between` method.
Expand Down
209 changes: 116 additions & 93 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,91 +47,88 @@ pipeline {
sh "pyenv local 3.6.8"
}
}
stage ("Parallel Jobs") {
parallel {
stage ("Linting Check") {
steps {
script {
env.lint_result = "FAILURE"
}
bbcGithubNotify(context: "lint/flake8", status: "PENDING")
sh 'flake8'
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 ("Clean") {
steps {
sh 'git clean -dfx'
sh 'make clean'
}
}
stage ("Linting Check") {
steps {
script {
env.lint_result = "FAILURE"
}
stage ("Build Docs") {
steps {
sh 'TOXDIR=/tmp/$(basename ${WORKSPACE})/tox-docs make docs'
}
}
stage ("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)
}
}
}
}
bbcGithubNotify(context: "lint/flake8", status: "PENDING")
sh 'make lint'
script {
env.lint_result = "SUCCESS" // This will only run if the sh above succeeded
}
stage ("Debian Source Build") {
steps {
script {
env.debSourceBuild_result = "FAILURE"
}
bbcGithubNotify(context: "deb/sourceBuild", status: "PENDING")
}
post {
always {
bbcGithubNotify(context: "lint/flake8", status: env.lint_result)
}
}
}
stage ("Type Check") {
steps {
script {
env.mypy_result = "FAILURE"
}
bbcGithubNotify(context: "type/mypy", status: "PENDING")
sh 'make mypy'
script {
env.mypy_result = "SUCCESS" // This will only run if the sh above succeeded
}
}
post {
always {
bbcGithubNotify(context: "type/mypy", status: env.mypy_result)
}
}
}
stage ("Build Docs") {
steps {
sh 'make docs'
}
}
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 'make test'
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") {
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)
}
}
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)
}
}
}
Expand Down Expand Up @@ -159,14 +156,14 @@ pipeline {
expression { return params.FORCE_DEBUPLOAD }
expression { return params.FORCE_DOCSUPLOAD }
expression {
bbcShouldUploadArtifacts(branches: ["master"])
bbcShouldUploadArtifacts(branches: ["master", "dev"])
}
}
}
parallel {
stages {
stage ("Upload Docs") {
when {
anyOf {
anyOf {
expression { return params.FORCE_DOCSUPLOAD }
expression {
bbcShouldUploadArtifacts(branches: ["master"])
Expand All @@ -192,9 +189,8 @@ pipeline {
}
bbcGithubNotify(context: "pypi/upload", status: "PENDING")
sh 'rm -rf dist/*'
bbcMakeGlobalWheel("py27")
bbcMakeGlobalWheel("py3")
bbcTwineUpload(toxenv: "py3", pypi: true)
bbcMakeGlobalWheel("py36")
bbcTwineUpload(toxenv: "py36", pypi: true)
script {
env.pypiUpload_result = "SUCCESS" // This will only run if the steps above succeeded
}
Expand All @@ -205,6 +201,33 @@ pipeline {
}
}
}
stage ("Upload to Artifactory") {
when {
anyOf {
expression { return params.FORCE_PYUPLOAD }
expression {
bbcShouldUploadArtifacts(branches: ["dev"])
}
}
}
steps {
script {
env.artifactoryUpload_result = "FAILURE"
}
bbcGithubNotify(context: "artifactory/upload", status: "PENDING")
sh 'rm -rf dist/*'
bbcMakeGlobalWheel("py36")
bbcTwineUpload(toxenv: "py36", pypi: false)
script {
env.artifactoryUpload_result = "SUCCESS" // This will only run if the steps above succeeded
}
}
post {
always {
bbcGithubNotify(context: "artifactory/upload", status: env.artifactoryUpload_result)
}
}
}
stage ("Upload deb") {
when {
anyOf {
Expand Down Expand Up @@ -238,11 +261,11 @@ pipeline {
}
}
}
}
}
post {
always {
bbcSlackNotify(channel: "#apmm-cloudfit")
post {
always {
bbcSlackNotify(channel: "#apmm-cloudfit")
}
}
}
}
}
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) BBC 2017
Copyright (c) BBC 2017-2020

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this Specification except in compliance with the License.
Expand Down
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ include stdeb.cfg
include ICLA.md
include ICLA.pdf
include LICENSE.md
include NOTICE.md
include NOTICE.md
include mediatimestamp/py.typed
unclude mediatimestamp/hypothesis/py.typed
39 changes: 20 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
PYTHON=`which python`
PYTHON2=`which python2`
PYTHON3=`which python3`
PYTHON=`which python3`
PY2DSC=`which py2dsc`

PY2DSC_PARAMS?=--with-python2=true --with-python3=true
PY2DSC_PARAMS?=--with-python2=false --with-python3=true

topdir := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
topbuilddir := $(realpath .)
Expand All @@ -15,7 +13,7 @@ MODNAME=$(PROJECT)

# The rules for names and versions in python, rpm, and deb are different
# and not entirely compatible. As such py2dsc will automatically convert
# your package name into a suitable deb name and version number, and this
# your package name into a suitable deb name and version number, and this
# code replicates that.
DEBNAME=$(shell echo $(MODNAME) | tr '[:upper:]_' '[:lower:]-')
DEBVERSION=$(shell echo $(VERSION) | sed 's/\.dev/~dev/')
Expand All @@ -30,6 +28,8 @@ RPMDIRS=BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
RPMBUILDDIRS=$(patsubst %, $(RPM_PREFIX)/%, $(RPMDIRS))

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

all:
@echo "$(PROJECT)-$(VERSION)"
Expand Down Expand Up @@ -67,13 +67,10 @@ clean:
find $(topdir) -name '*.py,cover' -delete
rm -rf $(topbuilddir)/docs

testenv: $(TOXDIR)/py27/bin/activate $(TOXDIR)/py3/bin/activate
testenv: $(TOX_ACTIVATE)

$(TOXDIR)/py3/bin/activate: tox.ini
tox -e py3 --recreate --workdir $(TOXDIR)

$(TOXDIR)/py27/bin/activate: tox.ini
tox -e py27 --recreate --workdir $(TOXDIR)
$(TOX_ACTIVATE): tox.ini setup.py
tox -e $(TOXENV) --recreate --notest --workdir $(TOXDIR)

test:
tox --workdir $(TOXDIR)
Expand All @@ -96,7 +93,7 @@ deb: source deb_dist $(DEBIANOVERRIDES)
$(RPM_PREFIX)/$(MODNAME).spec: rpm_spec

rpm_spec: $(topdir)/setup.py
$(PYTHON3) $(topdir)/setup.py bdist_rpm $(RPM_PARAMS) --spec-only --dist-dir=$(RPM_PREFIX) --python=python3.4
$(PYTHON3) $(topdir)/setup.py bdist_rpm $(RPM_PARAMS) --spec-only --dist-dir=$(RPM_PREFIX) --python=python3.6
# END OF RPM SPEC RULES

$(RPMBUILDDIRS):
Expand All @@ -117,20 +114,24 @@ rpm: $(RPM_PREFIX)/SPECS/$(MODNAME).spec $(RPM_PREFIX)/SOURCES/$(MODNAME)-$(VERS
cp $(RPM_PREFIX)/RPMS/*/*.rpm $(topbuilddir)/dist

wheel:
$(PYTHON2) $(topdir)/setup.py bdist_wheel
$(PYTHON3) $(topdir)/setup.py bdist_wheel
$(PYTHON) $(topdir)/setup.py bdist_wheel

egg:
$(PYTHON2) $(topdir)/setup.py bdist_egg
$(PYTHON3) $(topdir)/setup.py bdist_egg
$(PYTHON) $(topdir)/setup.py bdist_egg

docs: $(topbuilddir)/docs/$(MODNAME).html

$(topbuilddir)/docs/$(MODNAME):
mkdir -p $(topbuilddir)/docs
ln -s $(topdir)/$(MODNAME) $(topbuilddir)/docs/

$(topbuilddir)/docs/$(MODNAME).html: $(topbuilddir)/docs/$(MODNAME) $(TOXDIR)/py3/bin/activate
. $(TOXDIR)/py3/bin/activate && cd $(topbuilddir)/docs/ && pydoc -w ./
$(topbuilddir)/docs/$(MODNAME).html: $(topbuilddir)/docs/$(MODNAME) $(TOX_ACTIVATE)
. $(TOX_ACTIVATE) && cd $(topbuilddir)/docs/ && pydoc -w ./

lint: $(TOX_ACTIVATE)
. $(TOX_ACTIVATE) && flake8 $(MODNAME) tests

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

.PHONY: test testenv clean install source deb dsc rpm wheel egg all rpm_dirs rpm_spec docs
.PHONY: test testenv clean install source deb dsc rpm wheel egg all rpm_dirs rpm_spec docs lint mypy
Loading

0 comments on commit 94c315a

Please sign in to comment.