Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition CI/CD to GitHub Workflows #2378

Merged
merged 37 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
98e427c
update readme and setup.py tags
wbarnha Aug 2, 2023
e2acd92
remove pinned versions from requirements-dev.txt for now
wbarnha Aug 2, 2023
77c345b
commit basic workflow for now
wbarnha Aug 2, 2023
bd1b0fe
disable setup-kafka requirement for now
wbarnha Aug 2, 2023
4a62b02
install libsnappy-dev
wbarnha Aug 2, 2023
4f03240
remove py3.7
wbarnha Aug 2, 2023
57c523c
pull java and fix some tests
wbarnha Aug 2, 2023
5ddacca
cleanup commands
wbarnha Aug 2, 2023
75a9ef7
remove <distribution>
wbarnha Aug 2, 2023
21a36f8
specify oracle distribution
wbarnha Aug 2, 2023
9759af4
just use temurin 11 for now
wbarnha Aug 2, 2023
fa4b11a
run ./build_integration.sh lol
wbarnha Aug 2, 2023
d05e798
add more releases to build_integration.sh
wbarnha Aug 2, 2023
60ad460
specify kafka version in env
wbarnha Aug 2, 2023
ddd2c0d
specify kafka versions
wbarnha Aug 2, 2023
2b600c7
just pull major and minor versions
wbarnha Aug 2, 2023
4d1077c
Revert "just pull major and minor versions"
wbarnha Aug 2, 2023
1f6ce72
split kafka and python tests
wbarnha Aug 2, 2023
4ec8f04
remove kafka note
wbarnha Aug 2, 2023
ea2e8a0
remove env from name again
wbarnha Aug 2, 2023
24ce096
replace py.test with pytest
wbarnha Aug 2, 2023
1a13bae
fix pypy syntax
wbarnha Aug 2, 2023
873bc2d
install pylint for everyone
wbarnha Aug 2, 2023
c895bba
disable travis_java_install
wbarnha Aug 2, 2023
f186ae1
try java 8
wbarnha Aug 2, 2023
674ab78
extend timeout from 35s to 60s since PyPy tests are slow
wbarnha Aug 2, 2023
5a0a662
Revert "extend timeout from 35s to 60s since PyPy tests are slow"
wbarnha Aug 2, 2023
6baa9d7
change syntax to pypy-3.9
wbarnha Aug 2, 2023
abf7706
remove CODE_OF_CONDUCT.md
wbarnha Aug 2, 2023
4d05fd9
mark PyPy as experimental in CI/CD until we know why it keeps failing
wbarnha Aug 2, 2023
4ef5dbc
remove automatic publish
wbarnha Aug 2, 2023
f43e002
revert changes to ALL_RELEASES
wbarnha Aug 2, 2023
b8e9e51
fix typo
wbarnha Aug 2, 2023
30bfa8c
Update dependabot.yml
wbarnha Aug 2, 2023
7fc76d1
Update README.rst
wbarnha Aug 2, 2023
63837d6
revert tags to setup.py
wbarnha Aug 2, 2023
9ef7d62
Update setup.py to have " "Programming Language :: Python :: 2…
wbarnha Aug 2, 2023
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
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
67 changes: 67 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: CodeQL
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not critical to include this, but it has served me well in other projects.

on:
push:
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: 19 10 * * 6
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [python]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
179 changes: 179 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
name: CI/CD

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
release:
types: [created]
branches:
- 'master'
workflow_dispatch:

env:
FORCE_COLOR: "1" # Make tools pretty.
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_NO_PYTHON_VERSION_WARNING: "1"
PYTHON_LATEST: "3.11"
KAFKA_LATEST: "2.6.0"

# For re-actors/checkout-python-sdist
sdist-artifact: python-package-distributions

jobs:

build-sdist:
name: 📦 Build the source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_LATEST }}
cache: pip
- run: python -m pip install build
name: Install core libraries for build and install
- name: Build artifacts
run: python -m build
- name: Upload built artifacts for testing
uses: actions/upload-artifact@v3
with:
name: ${{ env.sdist-artifact }}
# NOTE: Exact expected file names are specified here
# NOTE: as a safety measure — if anything weird ends
# NOTE: up being in this dir or not all dists will be
# NOTE: produced, this will fail the workflow.
path: dist/${{ env.sdist-name }}
retention-days: 15

test-python:
name: Tests on ${{ matrix.python-version }}
needs:
- build-sdist
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
experimental: [ false ]
include:
- python-version: "pypy3.9"
experimental: true
# - python-version: "~3.12.0-0"
# experimental: true
steps:
- name: Checkout the source code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
requirements-dev.txt
- name: Check Java installation
run: source travis_java_install.sh
- name: Pull Kafka releases
run: ./build_integration.sh
env:
PLATFORM: ${{ matrix.platform }}
KAFKA_VERSION: ${{ env.KAFKA_LATEST }}
# TODO: Cache releases to expedite testing
- name: Install dependencies
run: |
sudo apt install -y libsnappy-dev libzstd-dev
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
pip install .
pip install -r requirements-dev.txt
- name: Test with tox
run: tox
env:
PLATFORM: ${{ matrix.platform }}
KAFKA_VERSION: ${{ env.KAFKA_LATEST }}

test-kafka:
name: Tests for Kafka ${{ matrix.kafka-version }}
needs:
- build-sdist
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
kafka-version:
- "0.8.2.2"
- "0.9.0.1"
- "0.10.2.2"
- "0.11.0.2"
- "0.11.0.3"
- "1.1.1"
- "2.4.0"
- "2.5.0"
- "2.6.0"
Comment on lines +121 to +129
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It'd be nice to keep all of these versions in a file somewhere for convenience, so we don't need to edit supported Kafka versions in multiple places.

steps:
- name: Checkout the source code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_LATEST }}
cache: pip
cache-dependency-path: |
requirements-dev.txt
- name: Pull Kafka releases
run: ./build_integration.sh
env:
# This is fast enough as long as you pull only one release at a time,
# no need to worry about caching
PLATFORM: ${{ matrix.platform }}
KAFKA_VERSION: ${{ matrix.kafka-version }}
- name: Install dependencies
run: |
sudo apt install -y libsnappy-dev libzstd-dev
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
pip install .
pip install -r requirements-dev.txt
- name: Test with tox
run: tox
env:
PLATFORM: ${{ matrix.platform }}
KAFKA_VERSION: ${{ matrix.kafka-version }}

check: # This job does nothing and is only used for the branch protection
name: ✅ Ensure the required checks passing
if: always()
needs:
- build-sdist
- test-python
- test-kafka
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ test37: build-integration
test27: build-integration
KAFKA_VERSION=$(KAFKA_VERSION) SCALA_VERSION=$(SCALA_VERSION) tox -e py27 -- $(FLAGS)

# Test using py.test directly if you want to use local python. Useful for other
# Test using pytest directly if you want to use local python. Useful for other
# platforms that require manual installation for C libraries, ie. Windows.
test-local: build-integration
KAFKA_VERSION=$(KAFKA_VERSION) SCALA_VERSION=$(SCALA_VERSION) py.test \
KAFKA_VERSION=$(KAFKA_VERSION) SCALA_VERSION=$(SCALA_VERSION) pytest \
--pylint --pylint-rcfile=pylint.rc --pylint-error-types=EF $(FLAGS) kafka test

cov-local: build-integration
KAFKA_VERSION=$(KAFKA_VERSION) SCALA_VERSION=$(SCALA_VERSION) py.test \
KAFKA_VERSION=$(KAFKA_VERSION) SCALA_VERSION=$(SCALA_VERSION) pytest \
--pylint --pylint-rcfile=pylint.rc --pylint-error-types=EF --cov=kafka \
--cov-config=.covrc --cov-report html $(FLAGS) kafka test
@echo "open file://`pwd`/htmlcov/index.html"
Expand Down
10 changes: 8 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ Kafka Python client
:target: https://pypi.python.org/pypi/kafka-python
.. image:: https://coveralls.io/repos/dpkp/kafka-python/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/dpkp/kafka-python?branch=master
.. image:: https://travis-ci.org/dpkp/kafka-python.svg?branch=master
:target: https://travis-ci.org/dpkp/kafka-python
.. image:: https://img.shields.io/badge/license-Apache%202-blue.svg
:target: https://github.com/dpkp/kafka-python/blob/master/LICENSE
.. image:: https://img.shields.io/pypi/dw/kafka-python.svg
:target: https://pypistats.org/packages/kafka-python
.. image:: https://img.shields.io/pypi/v/kafka-python.svg
:target: https://pypi.org/project/kafka-python
.. image:: https://img.shields.io/pypi/implementation/kafka-python
:target: https://github.com/dpkp/kafka-python/blob/master/setup.py



Python client for the Apache Kafka distributed stream processing system.
kafka-python is designed to function much like the official java client, with a
Expand Down
34 changes: 17 additions & 17 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
coveralls==2.1.2
crc32c==2.1
docker-py==1.10.6
flake8==3.8.3
lz4==3.1.0
mock==4.0.2
py==1.9.0
pylint==2.6.0
pytest==6.0.2
pytest-cov==2.10.1
pytest-mock==3.3.1
pytest-pylint==0.17.0
python-snappy==0.5.4
Sphinx==3.2.1
sphinx-rtd-theme==0.5.0
tox==3.20.0
xxhash==2.0.0
coveralls
crc32c
docker-py
flake8
lz4
mock
py
pylint
pytest
pytest-cov
pytest-mock
pytest-pylint
python-snappy
Sphinx
sphinx-rtd-theme
tox
xxhash
Comment on lines -1 to +17
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In my personal opinion, we don't necessarily need to pin versions until we get all of our workflows in order. We can revisit version pinning at a later point, many of these pinned versions are outdated.

9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def run(cls):
license="Apache License 2.0",
description="Pure Python client for Apache Kafka",
long_description=README,
keywords="apache kafka",
keywords=[
"apache kafka",
"kafka",
],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
Expand All @@ -64,6 +67,10 @@ def run(cls):
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
]
Expand Down
2 changes: 1 addition & 1 deletion test/test_assignors.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ def test_conflicting_previous_assignments(mocker):
'execution_number,n_topics,n_consumers', [(i, randint(10, 20), randint(20, 40)) for i in range(100)]
)
def test_reassignment_with_random_subscriptions_and_changes(mocker, execution_number, n_topics, n_consumers):
all_topics = set(['t{}'.format(i) for i in range(1, n_topics + 1)])
all_topics = sorted(['t{}'.format(i) for i in range(1, n_topics + 1)])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sorted is a required call for Python 3.11+, otherwise the test fails.

partitions = dict([(t, set(range(1, i + 1))) for i, t in enumerate(all_topics)])
cluster = create_cluster(mocker, topics=all_topics, topic_partitions_lambda=lambda t: partitions[t])

Expand Down
Loading