Skip to content

Commit 5ba3906

Browse files
committed
CI/CD: Added tox for multi-version checks
1 parent ae055f1 commit 5ba3906

File tree

7 files changed

+132
-6
lines changed

7 files changed

+132
-6
lines changed

.github/workflows/build_pkg.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build package
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
artifact-name:
7+
description: "Name of an artifact"
8+
type: "string"
9+
required: false
10+
default: "package"
11+
12+
jobs:
13+
build-pkg:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.x'
21+
22+
- name: Install dependencies
23+
run: pip install -U build twine
24+
- name: Build 📦 package
25+
run: python -m build
26+
- name: Check 📦 package
27+
run: twine check dist/*
28+
29+
- uses: actions/upload-artifact@v3
30+
with:
31+
name: ${{ inputs.artifact-name }}
32+
path: dist

.github/workflows/tests.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Tests
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
merge_group:
8+
9+
jobs:
10+
11+
build:
12+
uses: "./.github/workflows/build_pkg.yml"
13+
with:
14+
artifact-name: package
15+
16+
test:
17+
runs-on: ${{ matrix.os }}
18+
name: test (Python ${{ matrix.python-version }} on ${{ matrix.os-label }})
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
# keep it sync with tox.ini [gh-actions] section
23+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"]
24+
os: ["ubuntu-latest"]
25+
os-label: ["Ubuntu"]
26+
include:
27+
- {python-version: "3.8", os: "windows-latest", os-label: "Windows"}
28+
- {python-version: "3.8", os: "macos-latest", os-label: "macOS"}
29+
steps:
30+
- uses: actions/checkout@v3
31+
- name: Set up Python
32+
uses: actions/setup-python@v4
33+
with:
34+
python-version: "${{ matrix.python-version }}"
35+
- name: Install tox
36+
run: |
37+
python -m pip install --upgrade pip
38+
pip install tox tox-gh-actions
39+
- name: Run tests
40+
run: tox
41+
- name: Upload coverage to Codecov
42+
uses: codecov/codecov-action@v3
43+
env:
44+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
45+
46+
test_success:
47+
# this aggregates success state of all jobs listed in `needs`
48+
# this is the only required check to pass CI
49+
name: "Test success"
50+
runs-on: ubuntu-latest
51+
needs: [test]
52+
steps:
53+
- name: "Noop"
54+
run: true
55+
shell: bash

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# [Shellhub Python SDK]
22

3+
[![codecov](https://codecov.io/gh/Seluj78/shellhub-python/graph/badge.svg?token=FPWuNDtwdz)](https://codecov.io/gh/Seluj78/shellhub-python)
4+
35
* [What is it](#what-is-it)
46
* [Installation](#installation)
57
* [Locally](#locally)

codecov.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
comment:
2+
after_n_builds: 4
3+
4+
codecov:
5+
disable_default_path_fixes: true # Automatic detection does not discover all files
6+
7+
fixes:
8+
- "::shellhub/"

pyproject.toml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,25 @@ authors = [
3131
]
3232
readme = "README.md"
3333
dynamic = ["version"]
34-
requires-python = ">=3.11"
34+
requires-python = ">=3.7"
3535
classifiers=[
3636
"Development Status :: 3 - Alpha",
3737
"Intended Audience :: Developers",
3838
"Natural Language:: English",
3939
"Topic :: Software Development :: Libraries :: Python Modules",
4040
"License :: Other/Proprietary License",
41-
"Programming Language :: Python :: 3.11",
42-
"Programming Language :: Python :: 3.10",
43-
"Programming Language :: Python :: 3.9",
41+
"Operating System :: OS Independent",
42+
"Programming Language :: Python",
43+
"Programming Language :: Python :: 3",
44+
"Programming Language :: Python :: 3.7",
4445
"Programming Language :: Python :: 3.8",
46+
"Programming Language :: Python :: 3.9",
47+
"Programming Language :: Python :: 3.10",
48+
"Programming Language :: Python :: 3.11",
49+
"Programming Language :: Python :: 3.12",
50+
"Topic :: Software Development",
4551
]
46-
dependencies = [""]
52+
dependencies = ["requests>=2.31.0"]
4753

4854
[tool.setuptools]
4955
packages = ["shellhub"]

requirements-dev.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ pre-commit
88

99
pytest
1010
requests-mock
11-
pytest-cov
11+
pytest-cov
12+
tox
13+
build
14+
setuptools
15+
wheel
16+
twine

tox.ini

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[tox]
2+
envlist =
3+
py{37,38,39,310,311,312},
4+
5+
[gh-actions]
6+
# this make sure each ci job only run tests once.
7+
# keey it sync with workflows/tests.yaml matrix
8+
python =
9+
3.7: py37
10+
3.8: py38
11+
3.9: py39
12+
3.10: py310
13+
3.11: py311
14+
3.12: py312
15+
16+
[testenv]
17+
deps = -rrequirements-dev.txt
18+
commands = pytest --cov=shellhub --cov-report=xml {posargs}

0 commit comments

Comments
 (0)