Skip to content

Commit

Permalink
support pyproject.toml (#92)
Browse files Browse the repository at this point in the history
* support pyproject.toml

* consolidate configuration files
* ran black

* update pipeline
  • Loading branch information
aaronsky committed Jun 17, 2023
1 parent 1164a9b commit f70631a
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 79 deletions.
34 changes: 19 additions & 15 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
.docker-plugin: &docker-plugin
plugins:
- docker#v3.5.0:
image: "python:3.8"
image: 'python:3.8'

steps:
.python-setup: &python-setup |-
python3 -m venv venv
source venv/bin/activate
pip install .[dev]

- label: ":python-black: Lint Black"
commands:
- pip install -r requirements.txt
- black --check .
steps:
- label: ':python-black: Lint Black'
commands:
- *python-setup
- python3 -m black --check .
<<: *docker-plugin

- label: ":mypy: Mypy"
commands:
- pip install -r requirements.txt
- mypy .
- label: ':mypy: Mypy'
commands:
- *python-setup
- python3 -m mypy .
<<: *docker-plugin

- label: ":pytest: Unit Tests"
commands:
- pip install -r requirements.txt
- pytest
<<: *docker-plugin
- label: ':pytest: Unit Tests'
commands:
- *python-setup
- python3 -m pytest
<<: *docker-plugin
File renamed without changes.
10 changes: 0 additions & 10 deletions mypy.ini

This file was deleted.

8 changes: 4 additions & 4 deletions pybuildkite/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def delete_pipeline(self, organization, pipeline):
"""
url = self.path.format(organization) + pipeline
return self.client.delete(url)

def update_pipeline(
self,
organization,
Expand Down Expand Up @@ -184,7 +184,7 @@ def update_pipeline(
}
url = self.path.format(organization) + pipeline
return self.client.patch(url, body=body)

def archive_pipeline(self, organization, pipeline):
"""
Archive a pipeline
Expand All @@ -194,7 +194,7 @@ def archive_pipeline(self, organization, pipeline):
"""
url = self.path.format(organization) + pipeline + "/archive"
return self.client.post(url)

def unarchive_pipeline(self, organization, pipeline):
"""
Unarchive a pipeline
Expand All @@ -204,7 +204,7 @@ def unarchive_pipeline(self, organization, pipeline):
"""
url = self.path.format(organization) + pipeline + "/unarchive"
return self.client.post(url)


class PipelineException(Exception):
pass
51 changes: 51 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[project]
name = "pybuildkite"
version = "1.2.3"
description = "Python wrapper for the Buildkite API"
readme = "README.md"
license = { file = "LICENSE" }
authors = [
{ name = "Peter Yasi" },
]
keywords = [
"Buildkite",
"Continuous Integration",
"API",
"CI",
"wrapper",
"python",
]

dependencies = ["requests==2.31.0"]

[project.optional-dependencies]
dev = [
"black==22.6.0",
"coveralls==3.3.1",
"mypy==1.3.0",
"pytest==7.3.2",
"pytest-cov",
]

[project.urls]
Homepage = "https://github.com/pyasi/pybuildkite"
Repository = "https://github.com/pyasi/pybuildkite.git"
Download = "https://github.com/pyasi/pybuildkite/archive/master.zip"

[tool.mypy]
ignore_missing_imports = true
disallow_any_unimported = true
check_untyped_defs = true
warn_redundant_casts = true
warn_return_any = true
warn_unused_ignores = true
warn_unused_configs = true
show_error_codes = true
pretty = true

[tool.pytest.ini_options]
addopts = """
--verbose \
--cov=pybuildkite \
--cov-report=xml"""
python_files = ["tests/*.py"]
3 changes: 0 additions & 3 deletions pytest.ini

This file was deleted.

10 changes: 0 additions & 10 deletions requirements.txt

This file was deleted.

21 changes: 0 additions & 21 deletions setup.py

This file was deleted.

10 changes: 2 additions & 8 deletions tests/test_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ def test_multi_branch(fake_client):
builds.rebuild_build("org_slug", "pipeline_id", "build_number")

builds.list_all_for_pipeline(
organization="org",
pipeline="pipe",
branch=["main", "master"]
organization="org", pipeline="pipe", branch=["main", "master"]
)

args = fake_client.get.call_args[0][1]
Expand All @@ -236,11 +234,7 @@ def test_single_branch(fake_client):
builds = Builds(fake_client, "https://api.buildkite.com/v2/")
builds.rebuild_build("org_slug", "pipeline_id", "build_number")

builds.list_all_for_pipeline(
organization="org",
pipeline="pipe",
branch="main"
)
builds.list_all_for_pipeline(organization="org", pipeline="pipe", branch="main")

args = fake_client.get.call_args[0][1]
assert args["branch"] == "branch=main"
14 changes: 6 additions & 8 deletions tests/test_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,21 +317,19 @@ def test_update_pipeline_configuration_and_steps(fake_client):
configuration="",
steps={},
)



def test_archive_pipeline(fake_client):
pipeline = Pipelines(fake_client, "https://api.buildkite.com/v2/")
pipeline.archive_pipeline(
"test_org", "test_pipeline"
)
pipeline.archive_pipeline("test_org", "test_pipeline")
fake_client.post.assert_called_with(
pipeline.path.format("test_org") + "test_pipeline" + "/archive"
pipeline.path.format("test_org") + "test_pipeline" + "/archive"
)


def test_unarchive_pipeline(fake_client):
pipeline = Pipelines(fake_client, "https://api.buildkite.com/v2/")
pipeline.unarchive_pipeline(
"test_org", "test_pipeline"
)
pipeline.unarchive_pipeline("test_org", "test_pipeline")
fake_client.post.assert_called_with(
pipeline.path.format("test_org") + "test_pipeline" + "/unarchive"
)

0 comments on commit f70631a

Please sign in to comment.