Skip to content

Commit

Permalink
Merge pull request #56
Browse files Browse the repository at this point in the history
  • Loading branch information
james-callahan committed Mar 11, 2022
2 parents becdb6d + 7670674 commit 124865f
Show file tree
Hide file tree
Showing 28 changed files with 3,274 additions and 2,055 deletions.
5 changes: 4 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[run]
branch = True
parallel = True
include = ./*.py
omit = ./test_*.py
omit =
./test/*
./integration_test/*
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service_name: drone
parallel: true
143 changes: 111 additions & 32 deletions .drone.jsonnet
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
local images = {
curl: 'alpine/curl@sha256:c64976d53728ca1b4918a49257845af27e343c4a79090788f83afe9f3e800965',
// https://github.com/drGrove/drone-kaniko/tree/v0.7.0
kaniko: 'drgrove/drone-kaniko@sha256:e3045421c3683e6baf5628b22ea0ee1cd7ae217f4de0e1bc53a0a1a20335b108',
postgres: 'postgres:12',
python: 'python:3.9-slim-buster',
};

local pr_trigger = {
event: [
'pull_request',
],
};

local master_trigger = {
event: [
'push',
],
ref: {
include: [
'refs/heads/master',
],
},
};

local tag_trigger = {
event: [
'tag',
],
};

local pipeline(
name,
kind='pipeline',
Expand Down Expand Up @@ -79,8 +103,8 @@ local postgresql = step(
detach=true,
);

local test(python_version) = step(
'test',
local unittest(python_version) = step(
'unit test',
'python:' + python_version + '-slim-buster',
environment={
PGHOST: 'postgresql',
Expand All @@ -102,16 +126,88 @@ local test(python_version) = step(
]
);

local integration_test(python_version) = step(
'integration test',
'python:' + python_version + '-slim-buster',
environment={
PGHOST: 'postgresql',
COVERALLS_REPO_TOKEN: {
from_secret: 'COVERALLS_REPO_TOKEN',
},
CLEANUP: '0',
},
commands=[
'apt update && apt install -y make cmake gnupg git postgresql-client',
'pip3 install pipenv',
'make setup-dev',
'cp config.ini.example config.ini',
'make create-ca',
'make integration-test.dev coverage coveralls',
],
depends_on=[
clone.name,
]
);

local unittest_pl(pl_type, python_version, trigger={}) = pipeline(
pl_type + ' Unit Test: ' + python_version,
steps=[
clone,
postgresql,
test(python_version),
unittest(python_version),
],
trigger=trigger,
);

local integration_test_pl(pl_type, python_version, trigger={}) = pipeline(
pl_type + ' Integration Test: ' + python_version,
steps=[
clone,
postgresql,
integration_test(python_version),
],
trigger=trigger,
);

local notify_coveralls_complete = step(
'Coverage Complete',
images.curl,
environment={
COVERALLS_REPO_TOKEN: {
from_secret: 'COVERALLS_REPO_TOKEN',
},
},
commands=[
'curl -k https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN -d "payload[build_num]=$DRONE_BUILD_NUMBER&payload[status]=done"',
],
depends_on=[
clone.name,
],
);

local coveralls_complete_pl(pl_type, trigger={}) = pipeline(
pl_type + ': Coverage',
steps=[
clone,
notify_coveralls_complete,
],
trigger=trigger,
depends_on=[
unittest_pl('PR', '3.10', trigger=pr_trigger).name,
unittest_pl('Master', '3.10', trigger=master_trigger).name,
unittest_pl('Tag', '3.10', trigger=tag_trigger).name,
unittest_pl('PR', '3.9', trigger=pr_trigger).name,
unittest_pl('Master', '3.9', trigger=master_trigger).name,
unittest_pl('Tag', '3.9', trigger=tag_trigger).name,
integration_test_pl('PR', '3.10', trigger=pr_trigger).name,
integration_test_pl('Master', '3.10', trigger=master_trigger).name,
integration_test_pl('Tag', '3.10', trigger=tag_trigger).name,
integration_test_pl('PR', '3.9', trigger=pr_trigger).name,
integration_test_pl('Master', '3.9', trigger=master_trigger).name,
integration_test_pl('Tag', '3.9', trigger=tag_trigger).name,
]
);

local get_image_tag = step(
'Get Tag',
images.python,
Expand Down Expand Up @@ -154,39 +250,22 @@ local image_build_pl(pl_type, trigger={}, push=false) = pipeline(
trigger=trigger
);

local pr_trigger = {
event: [
'pull_request',
],
};

local master_trigger = {
event: [
'push',
],
ref: {
include: [
'refs/heads/master',
],
},
};

local tag_trigger = {
event: [
'tag',
],
};

[
unittest_pl('PR', '3.10', trigger=pr_trigger),
unittest_pl('Master', '3.10', trigger=master_trigger),
unittest_pl('Tag', '3.10', trigger=tag_trigger),
unittest_pl('PR', '3.9', trigger=pr_trigger),
unittest_pl('Master', '3.9', trigger=master_trigger),
unittest_pl('Tag', '3.9', trigger=tag_trigger),
unittest_pl('PR', '3.8', trigger=pr_trigger),
unittest_pl('Master', '3.8', trigger=master_trigger),
unittest_pl('Tag', '3.8', trigger=tag_trigger),
unittest_pl('PR', '3.7', trigger=pr_trigger),
unittest_pl('Master', '3.7', trigger=master_trigger),
unittest_pl('Tag', '3.7', trigger=tag_trigger),
integration_test_pl('PR', '3.10', trigger=pr_trigger),
integration_test_pl('Master', '3.10', trigger=master_trigger),
integration_test_pl('Tag', '3.10', trigger=tag_trigger),
integration_test_pl('PR', '3.9', trigger=pr_trigger),
integration_test_pl('Master', '3.9', trigger=master_trigger),
integration_test_pl('Tag', '3.9', trigger=tag_trigger),
coveralls_complete_pl('PR', trigger=pr_trigger),
coveralls_complete_pl('Master', trigger=master_trigger),
coveralls_complete_pl('Tag', trigger=tag_trigger),
image_build_pl('PR', trigger=pr_trigger, push=false),
image_build_pl('Master', trigger=master_trigger, push=false),
image_build_pl('Tag', trigger=tag_trigger, push=true),
Expand Down
Loading

0 comments on commit 124865f

Please sign in to comment.