Skip to content

Commit

Permalink
feat(build): add a build, run tests with coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Dec 25, 2019
1 parent 5bd18ee commit 6d8ade4
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 5 deletions.
Binary file added .coverage
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
@@ -1,4 +1,7 @@
.coverage/
.vscode/
dist/
htmlcov/

*.swp
*.pyc
Expand Down
11 changes: 11 additions & 0 deletions .gitlab-ci.yml
@@ -0,0 +1,11 @@
stages:
- pre
- test
- post

test-python:
extends:
- .test-python
stage: test
script:
- make test
71 changes: 71 additions & 0 deletions .gitlab/tools.yml
@@ -0,0 +1,71 @@
.shared-runner:
tags:
- platform:k8s
- runner:shared

.build-curl:
extends:
- .shared-runner
image: apextoaster/base:1.2

.build-climate:
extends:
- .shared-runner
image: apextoaster/code-climate:0.6
allow_failure: false
variables:
CI_BRANCH: "${CI_COMMIT_REF_NAME}"
GIT_BRANCH: "${CI_COMMIT_REF_NAME}"
GIT_COMMIT_SHA: "${CI_COMMIT_SHA}"

.build-codecov:
extends:
- .shared-runner
image: apextoaster/codecov:3.1
allow_failure: false

.build-docker:
extends:
- .shared-runner
image: apextoaster/docker:18.09
services:
- apextoaster/docker-dind:18.09
allow_failure: false

before_script:
- mkdir ${HOME}/.docker
- echo "${DOCKER_SECRET}" | base64 -d > ${HOME}/.docker/config.json
script:
- ${CI_PROJECT_DIR}/scripts/docker-build.sh --push
after_script:
- rm -rfv ${HOME}/.docker

variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://localhost:2375

.build-go:
extends:
- .shared-runner
image: golang:1.13
allow_failure: false

.build-node:
extends:
- .shared-runner
image: apextoaster/node:11.15
allow_failure: false

before_script:
- echo "${NPM_SECRET}" | base64 -d > ${HOME}/.npmrc

.build-python:
extends:
- .shared-runner
image: python:3.7

.build-sonar:
extends:
- .shared-runner
image: apextoaster/sonar-scanner:3.3
allow_failure: false
7 changes: 5 additions & 2 deletions Makefile
@@ -1,7 +1,10 @@
clean-package:
rm -rf dist

test:
python -m unittest discover -s tests/
coverage run -m unittest discover -s tests/

package: package-dist package-upload
package: clean-package package-dist package-upload

package-dist:
python ./setup.py sdist
Expand Down
1 change: 0 additions & 1 deletion prometheus_express/metric.py
Expand Up @@ -76,7 +76,6 @@ def __init__(self, name, desc, labels=[], registry=False):
if registry != False:
registry.register(self)

# TODO: fluent API for labeling metrics
def labels(self, *labelValues):
self.labelValues = labelValues
return self
Expand Down
4 changes: 2 additions & 2 deletions tests/test_utils.py
Expand Up @@ -49,12 +49,12 @@ def test_connected_withip(self):
class ScanI2CBusTest(unittest.TestCase):
def test_unlocked(self):
self.assertEqual(
pu.scan_i2c_bus(MockI2C()),
pu.scan_i2c_bus(MockI2C(), 10),
True,
)

def test_locked(self):
self.assertEqual(
pu.scan_i2c_bus(MockI2C(locked=True)),
pu.scan_i2c_bus(MockI2C(locked=True), 10),
False,
)

0 comments on commit 6d8ade4

Please sign in to comment.