Skip to content

Commit b07c136

Browse files
committed
Inroduce CI
Signed-off-by: George Melikov <mail@gmelikov.ru>
1 parent 278d02a commit b07c136

File tree

2 files changed

+163
-0
lines changed

2 files changed

+163
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Publish Python 🐍 distribution 📦 to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
build:
10+
name: Build distribution 📦
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
persist-credentials: false
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
- name: Install pypa/build
22+
run: >-
23+
python3 -m
24+
pip install
25+
build
26+
--user
27+
- name: Build a binary wheel and a source tarball
28+
run: python3 -m build
29+
- name: Store the distribution packages
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: python-package-distributions
33+
path: dist/
34+
35+
publish-to-pypi:
36+
name: >-
37+
Publish Python 🐍 distribution 📦 to PyPI
38+
needs:
39+
- build
40+
runs-on: ubuntu-latest
41+
environment:
42+
name: pypi
43+
url: https://pypi.org/p/httpetcd
44+
permissions:
45+
id-token: write # IMPORTANT: mandatory for trusted publishing
46+
47+
steps:
48+
- name: Download all the dists
49+
uses: actions/download-artifact@v4
50+
with:
51+
name: python-package-distributions
52+
path: dist/
53+
- name: Publish distribution 📦 to PyPI
54+
uses: pypa/gh-action-pypi-publish@release/v1
55+
56+
github-release:
57+
name: >-
58+
Sign the Python 🐍 distribution 📦 with Sigstore
59+
and upload them to GitHub Release
60+
needs:
61+
- publish-to-pypi
62+
runs-on: ubuntu-latest
63+
64+
permissions:
65+
contents: write # IMPORTANT: mandatory for making GitHub Releases
66+
id-token: write # IMPORTANT: mandatory for sigstore
67+
68+
steps:
69+
- name: Download all the dists
70+
uses: actions/download-artifact@v4
71+
with:
72+
name: python-package-distributions
73+
path: dist/
74+
- name: Sign the dists with Sigstore
75+
uses: sigstore/gh-action-sigstore-python@v3.0.0
76+
with:
77+
inputs: >-
78+
./dist/*.tar.gz
79+
./dist/*.whl
80+
- name: Create GitHub Release
81+
env:
82+
GITHUB_TOKEN: ${{ github.token }}
83+
run: >-
84+
gh release create
85+
"$GITHUB_REF_NAME"
86+
--repo "$GITHUB_REPOSITORY"
87+
--notes ""
88+
- name: Upload artifact signatures to GitHub Release
89+
env:
90+
GITHUB_TOKEN: ${{ github.token }}
91+
# Upload to GitHub Release using the `gh` CLI.
92+
# `dist/` contains the built packages, and the
93+
# sigstore-produced signatures and certificates.
94+
run: >-
95+
gh release upload
96+
"$GITHUB_REF_NAME" dist/**
97+
--repo "$GITHUB_REPOSITORY"

.github/workflows/tests.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
Lint:
9+
runs-on: ubuntu-24.04
10+
strategy:
11+
fail-fast: true
12+
matrix:
13+
python-version: ["3.12"]
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install tox
20+
run: pip install tox
21+
- name: pep8
22+
run: |
23+
tox -e pep8
24+
tests:
25+
runs-on: ubuntu-24.04
26+
strategy:
27+
fail-fast: true
28+
matrix:
29+
python-version: ["3.8", "3.10", "3.12", "3.13"]
30+
services:
31+
etcd:
32+
image: quay.io/coreos/etcd:v3.5.8
33+
ports:
34+
- 2379:2379
35+
- 2380:2380
36+
env:
37+
ETCD_ADVERTISE_CLIENT_URLS: http://127.0.0.1:2379
38+
ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379
39+
ETCD_INITIAL_ADVERTISE_PEER_URLS: http://127.0.0.1:2380
40+
ETCD_LISTEN_PEER_URLS: http://0.0.0.0:2380
41+
ETCD_NAME: etcd-test-instance
42+
ETCD_ENDPOINT: http://127.0.0.1:2379
43+
steps:
44+
- uses: actions/checkout@v3
45+
- uses: actions/setup-python@v5
46+
with:
47+
python-version: ${{ matrix.python-version }}
48+
- name: Install required packages
49+
run: |
50+
sudo apt update
51+
sudo apt install libev-dev -y
52+
- name: Install tox
53+
run: pip install tox
54+
- name: Unit tests
55+
run: |
56+
tox -e ${{ matrix.python-version }}
57+
- name: Wait for etcd to be ready
58+
run: |
59+
for i in $(seq 1 10); do
60+
nc -z 127.0.0.1 2379 && echo "etcd is ready!" && break
61+
echo "Waiting for etcd..."
62+
sleep 1
63+
done
64+
- name: Functional tests
65+
run: |
66+
tox -e ${{ matrix.python-version }}-functional

0 commit comments

Comments
 (0)