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
17 changes: 17 additions & 0 deletions .github/RELEASE_NOTES.template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Frequenz Channels Release Notes

## Summary

<!-- Here goes a general summary of what this release is about -->

## Upgrading

<!-- Here goes notes on how to upgrade from previous versions, including if there are any depractions and what they should be replaced with -->

## New Features

<!-- Here goes the main new features and examples or instructions on how to use them -->

## Bug Fixes

<!-- Here goes notable bug fixes that are worth a special mention or explanation -->
27 changes: 27 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Configuration for the Labeler GitHub action, executed by
# .github/workflows/labeler.yml.
#
# The basic syntax is [label]: [path patterns].
#
# For more details on the configuration please see:
# https://github.com/marketplace/actions/labeler

"part:docs":
- "**/*.md"
- LICENSE

"part:tests":
- "tests/**"

"part:tooling":
- ".git*"
- ".git*/**"
- "**/*.toml"
- "**/*.ini"
- CODEOWNERS
- MANIFEST.in
- "*requirements*.txt"
- setup.py

"part:channels":
- "src/frequenz/channels/**"
123 changes: 109 additions & 14 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
name: frequenz-channels-python

on:
push:
branches: [ v0.x.x ]

pull_request:

workflow_dispatch:
on: [pull_request, push, workflow_dispatch]

jobs:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
os:
- ubuntu-20.04
python-version:
- "3.8"
- "3.9"
- "3.10"
runs-on: ${{ matrix.os }}

steps:
- name: Fetch sources
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg') }}
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-${{ matrix.python-version }}-pip-

- name: Install required Python packages
run: |
Expand All @@ -38,3 +40,96 @@ jobs:
- name: run nox
run: nox
timeout-minutes: 10

build-dist:
runs-on: ubuntu-20.04
steps:
- name: Fetch sources
uses: actions/checkout@v3
with:
submodules: true

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install build dependencies
run: |
python -m pip install -U pip
python -m pip install -U build

- name: Build the source and binary distribution
run: python -m build

- name: Upload dist files
uses: actions/upload-artifact@v3
with:
name: frequenz-channels-python-dist
path: dist/
if-no-files-found: error

create-github-release:
needs: ["test", "build-dist"]
# Create a release only on tags creation
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
permissions:
# We need write permissions on contents to create GitHub releases and on
# discussions to create the release announcement in the discussion forums
contents: write
discussions: write
runs-on: ubuntu-20.04
steps:
- name: Download dist files
uses: actions/download-artifact@v3
with:
name: frequenz-channels-python-dist
path: dist

- name: Download RELEASE_NOTES.md
run: |
set -ux
gh api \
-X GET \
-f ref=$REF \
-H "Accept: application/vnd.github.raw" \
"/repos/$REPOSITORY/contents/RELEASE_NOTES.md" \
> RELEASE_NOTES.md
env:
REF: ${{ github.ref }}
REPOSITORY: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub release
run: |
set -ux
extra_opts=
if echo "$REF_NAME" | grep -- -; then extra_opts=" --prerelease"; fi
gh release create \
-R "$REPOSITORY" \
--discussion-category announcements \
--notes-file RELEASE_NOTES.md \
--generate-notes \
$extra_opts \
$REF_NAME \
dist/*
env:
REF_NAME: ${{ github.ref_name }}
REPOSITORY: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-to-pypi:
needs: ["create-github-release"]
runs-on: ubuntu-20.04
steps:
- name: Download dist files
uses: actions/download-artifact@v3
with:
name: frequenz-channels-python-dist
path: dist

- name: Publish the Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
24 changes: 24 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Pull Request Labeler

# XXX: !!! SECURITY WARNING !!!
# pull_request_target has write access to the repo, and can read secrets. We
# need to audit any external actions executed in this workflow and make sure no
# checked out code is run (not even installing dependencies, as installing
# dependencies usually can execute pre/post-install scripts). We should also
# only use hashes to pick the action to execute (instead of tags or branches).
# For more details read:
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
on: [pull_request_target]

jobs:
Label:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Labeler
# Only use hashes, see the security comment above
uses: actions/labeler@e54e5b338fbd6e6cdb5d60f51c22335fc57c401e # 4.0.1
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
72 changes: 72 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Contributing to `frequenz-channels`
===================================


Build
=====

You can use `build` to simply build the source and binary distribution:

```sh
python -m pip install build
python -m build
```

Local development
=================

You can use editable installs to develop the project locally (it will install
all the dependencies too):

```sh
python -m pip install -e .
```

You can also use `nox` to run the tests and other checks:

```sh
python -m pip install nox
nox
```

Releasing
=========

These are the steps to create a new release:

1. Get the latest head you want to create a release from.

2. Update the `RELEASE_NOTES.md` file if it is not complete, up to date, and
clean from template comments (`<!-- ... ->`) and empty sections. Submit
a pull request if an update is needed, wait until it is merged, and update
the latest head you want to create a release from to get the new merged pull
request.

3. Create a new signed tag using the release notes and
a [semver](https://semver.org/) compatible version number with a `v` prefix,
for example:

```sh
git tag -s -F RELEASE_NOTES.md v0.0.1
```

4. Push the new tag.

5. A GitHub action will test the tag and if all goes well it will create
a [GitHub
Release](https://github.com/frequenz-floss/frequenz-channels/releases),
create a new
[announcement](https://github.com/frequenz-floss/frequenz-channels/discussions/categories/announcements)
about the release, and upload a new package to
[PyPI](https://pypi.org/project/frequenz-channels/) automatically.

6. Once this is done, reset the `RELEASE_NOTES.md` with the template:

```sh
cp .github/RELEASE_NOTES.template.md RELEASE_NOTES.md
```

Commit the new release notes and create a PR (this step should be automated
eventually too).

7. Celebrate!
7 changes: 7 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exclude .gitignore
exclude .darglint
exclude noxfile.py
exclude CODEOWNERS
recursive-exclude .github *
recursive-exclude tests *
recursive-exclude benchmarks *
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Frequenz channels

This repository contains channel implementations for python.

## Contributing

If you want to know how to build this project and contribute to it, please
check out the [Contributing
Guide](https://github.com/frequenz-floss/frequenz-channels/CONTRIBUTING.md).
11 changes: 11 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `frequenz-channels` Release Notes

## Summary

This is the first public open source release based on the internal SDK version v0.9.0. There are no breaking changes in this release, only changes to the project structure, metadata, and automation. Packages are also now uploaded to PyPI as [`frequenz-channels`](https://pypi.org/project/frequenz-channels/), so this project now can be installed normally via `pip`:

```sh
python -m pip install frequenz-channels
```

The GitHub issues were also improved, adding templates for [reporting issues](https://github.com/frequenz-floss/frequenz-channels/issues/new?assignees=&labels=priority%3A%E2%9D%93%2C+type%3Abug&template=bug.yml) and [requesting features](https://github.com/frequenz-floss/frequenz-channels/issues/new?assignees=&labels=part%3A%E2%9D%93%2C+priority%3A%E2%9D%93%2C+type%3Aenhancement&template=feature.yml). Users are also pointed to the [Discussion forums](https://github.com/frequenz-floss/frequenz-channels/issues/new/choose) when trying to open an issue if they have questions instead. Also many labels are assigned automatically on issue and pull request creation.
43 changes: 40 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,46 @@ requires = [
]
build-backend = "setuptools.build_meta"


[project]
name = "frequenz-channels"
description = "Channel implementations for Python"
readme = "README.md"
license = { text = "MIT" }
keywords = [ "frequenz", "channel" ]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Software Development :: Libraries",
]
requires-python = ">= 3.8, < 4"
dependencies = [
"watchfiles >= 0.15.0",
]
dynamic = [ "version" ]

[[project.authors]]
name ="Frequenz Energy-as-a-Service GmbH"
email = "[email protected]"

[project.urls]
Changelog = "https://github.com/frequenz-floss/frequenz-channels-pytyhon/releases"
Repository = "https://github.com/frequenz-floss/frequenz-channels-pytyhon"
Issues = "https://github.com/frequenz-floss/frequenz-channels-pytyhon/issues"
Support = "https://github.com/frequenz-floss/frequenz-channels-pytyhon/discussions/categories/support"

[tool.setuptools]
include-package-data = true

[tool.setuptools_scm]
version_scheme = "post-release"

[tool.pylint.similarities]
ignore-comments=['yes']
ignore-docstrings=['yes']
Expand All @@ -18,9 +58,6 @@ disable = ["too-few-public-methods", "wrong-import-order", "ungrouped-imports"]
[tool.pylint.'DESIGN']
max-attributes=12

[tool.setuptools_scm]
version_scheme = "post-release"

[tool.isort]
profile = "black"
line_length = 88
Expand Down
18 changes: 0 additions & 18 deletions setup.cfg

This file was deleted.

Loading