Skip to main content
ConcourseTools logo

version pre-release python coverage pre-commit

A Python package for easily implementing Concourse resource types.

About

Concourse CI is an "open-source continuous thing-doer" designed to enable general automation with intuitive and re-usable components. Resources represent all external inputs and outputs to and from the pipeline, and many of these have been implemented in open source. In order to best leverage the Python ecosystem of open-source packages, Concourse Tools abstracts away the implementation details of Concourse resource types to allow users to focus on writing the code they want to run.

Installation

Install from GitHub, or from PyPI:

$ pip install concoursetools

Usage

Start by familiarising yourself with the Concourse resource "rules" in the documentation. To recreate that example, start by creating a new concourse.py file in your repository. The first step is to create a Version subclass:

from dataclasses import dataclass
from concoursetools import TypedVersion


@dataclass()
class GitVersion(TypedVersion):
    ref: str

Next, create a subclass of ConcourseResource:

from concoursetools import ConcourseResource


class GitResource(ConcourseResource[GitVersion]):

    def __init__(self, uri: str, branch: str, private_key: str) -> None:
        super().__init__(GitVersion)
        self.uri = uri
        self.branch = branch
        self.private_key = private_key

Here, the parameters in the __init__ method will be taken from the source configuration for the resource. Now, implement the three methods required to define the behaviour of the resource:

from pathlib import Path
from typing import Any
from concoursetools import BuildMetadata


class GitResource(ConcourseResource[GitVersion]):
    ...

    def fetch_new_versions(self, previous_version: GitVersion | None) -> list[GitVersion]:
        ...

    def download_version(self, version: GitVersion, destination_dir: pathlib.Path,
                         build_metadata: BuildMetadata, **kwargs: Any) -> tuple[GitVersion, dict[str, str]]:
        ...

    def publish_new_version(self, sources_dir: pathlib.Path, build_metadata: BuildMetadata,
                            **kwargs: Any) -> tuple[GitVersion, dict[str, str]]:
        ...

The keyword arguments in download_version and publish_new_version correspond to params in the get step, and get_params in the put step respectively.

Once you are happy with the resource, generate the Dockerfile using the Concourse Tools CLI:

$ python3 -m concoursetools dockerfile .

Finally, upload the Docker image to a registry, and use it in your pipelines!

For more information - and for more in-depth examples - see the documentation.

Bugs and Contributions

Concourse Tools is in beta, and still under somewhat-active development. Contributions, fixes, suggestions and bug reports are all welcome: Please familiarise yourself with our contribution guidelines.

Metadata

Release files for concoursetools 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for concoursetools 0.8.1
File Size Uploaded
concoursetools-0.8.1.tar.gz 63.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for concoursetools 0.8.1
File Interpreter ABI Platform
concoursetools-0.8.1-py3-none-any.whl Python 3 none any Details

Total release size: 114.6 kB

Release files / concoursetools-0.8.1.tar.gz

Download URL concoursetools-0.8.1.tar.gz
Size 63.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c4fd328325db61ff5a006ba0cbc4b545a01e52a9972b12542b86a77d193987a6
BLAKE2b-256 checksum
How to use checksums
47cabd699745797f3b3bcfaab43ab98542279a9ec886069389a7182108a18880
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / concoursetools-0.8.1-py3-none-any.whl

Download URL concoursetools-0.8.1-py3-none-any.whl
Size 51.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5768da9895b65121c6102e4a6523e5d0506d2d0b52147e988ec018093288712d
BLAKE2b-256 checksum
How to use checksums
594e08c68640003baa484bd2d91c4e9f7986705e720417f22e2f319435fb4c90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.8.1 This release

2 release files

0.8.0

2 release files

0.7.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page