Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/release-python.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Upload Python Package

on: # yamllint disable-line rule:truthy
push:
branches:
- release/*
jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip build twine
- name: Build and publish
working-directory: ./python
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blaisep can you remove this file from main and resubmit it in a PR?

We currently don't have anything to publish to PyPI. Once that is setup the PR to enable python releases can be made.

run: |
python -m build
twine upload dist/*
48 changes: 48 additions & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: test-python

on: # yamllint disable-line rule:truthy
push:
branches:
- main
- renovate/**
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools
pip install tox tox-gh-actions codecov
- name: Test with tox
working-directory: ./python
run: |
tox
codecov
- name: Build checking
working-directory: ./python
if: "matrix.python-version == '3.11'"
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m pip install --upgrade build twine
python -m build
twine check dist/*
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
- [Python] added ci-environment implementation in Python

## [9.2.0] - 2023-04-28
### Added
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ If a CI server is detected, a `CiEnvironment` struct is returned:
"url": "...",
"buildNumber": "...", // optional
"git": { // optional
"remote": "...",
"remote": "...",
"revision": "...",
"branch": "...", // optional
"tag": "..." // optional
Expand Down Expand Up @@ -97,6 +97,13 @@ func main() {
}
```

```python
import os
from ci_environment import detect_ci_environment

ci_environment = detect_ci_environment(os.environ)
```

## Supported CI servers

* [Azure Pipelines](https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?tabs=yaml&view=azure-devops#build-variables)
Expand Down
55 changes: 55 additions & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
*.rej
*.py[cod]
/.env
*.orig
**/__pycache__

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
build
_build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
nosetests.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject
.pytest_cache
.ropeproject

# Sublime
/*.sublime-*

#PyCharm
/.idea

# virtualenv
/.Python
/lib
/include
/share
/local
48 changes: 48 additions & 0 deletions python/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
---
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args:
- "python/src/ci_environment"
- "python/tests"
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-toml
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.9.0
hooks:
- id: pretty-format-toml
args: [--autofix]
- repo: https://github.com/asottile/pyupgrade
rev: v3.7.0
hooks:
- id: pyupgrade
args: ["--py38-plus"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
hooks:
- id: mypy
additional_dependencies: [types-setuptools, types-certifi]
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "1.3.1"
hooks:
- id: tox-ini-fmt
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.32.0
hooks:
- id: yamllint
args: [--format, parsable, --strict]
3 changes: 3 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CiEnvironment

Python implementation of https://github.com/cucumber/ci-environment
67 changes: 67 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools", "wheel"]

[project]
authors = [
{name = "Cucumber Limited", email = "[email protected]"}
]
classifiers = [
"Development Status :: 4 - Beta",
"Framework :: Gherkin",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS :: MacOS X",
"Topic :: Utilities",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11"
]
dependencies = [
"importlib_resources",
"python-dotenv"
]
description = "This library detects the CI environment based on environment variables defined by CI servers."
readme = {file = "README.md", content-type = "text/markdown"}
license = {text = "MIT"}
maintainers = [
{name = "Konstantin Goloveshko", email = "[email protected]"}
]
name = "gherkin-ci-environment"
requires-python = ">=3.8"
urls = {Repository = "https://github.com/cucumber/ci-environment"}
version = "0.1.0"

[project.entry-points]

[project.scripts]

[tool.black]
line-length = 120
target-version = ["py38", "py39", "py310", "py311"]
verbose = true

[tool.isort]
line_length = 120
multi_line_output = 3
profile = "black"

[tool.mypy]
files = "src/ci_environment/**/*.py"
install_types = true
non_interactive = true
plugins = [
"pydantic.mypy"
]
show_error_codes = true
warn_return_any = true
warn_unused_configs = true

[[tool.mypy.overrides]]
ignore_missing_imports = true
module = [
]
5 changes: 5 additions & 0 deletions python/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pytest]
testpaths = tests
filterwarnings =
error
ignore::DeprecationWarning
15 changes: 15 additions & 0 deletions python/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[options]
include_package_data = True
packages = find:
package_dir =
=src

[options.packages.find]
where = src
[options.package_data]
ci_environment =
CiEnvironments.json

[options.extras_require]
test =
tox
Loading