Skip to content

Commit c513cd9

Browse files
committed
Updating README.md, Implementing CI/CD
1 parent 3dcf17f commit c513cd9

16 files changed

Lines changed: 687 additions & 56 deletions

.github/workflows/ci.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest, macos-latest, windows-latest]
16+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install Poetry
27+
uses: snok/install-poetry@v1
28+
with:
29+
version: latest
30+
virtualenvs-create: true
31+
virtualenvs-in-project: true
32+
33+
- name: Load cached venv
34+
id: cached-poetry-dependencies
35+
uses: actions/cache@v4
36+
with:
37+
path: .venv
38+
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
39+
40+
- name: Install dependencies
41+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
42+
run: poetry install --no-interaction --no-root
43+
44+
- name: Install project
45+
run: poetry install --no-interaction
46+
47+
- name: Run linting
48+
run: |
49+
poetry run ruff check src/ tests/
50+
poetry run black --check src/ tests/
51+
52+
- name: Run type checking
53+
run: poetry run mypy src/
54+
55+
- name: Run tests
56+
run: poetry run pytest --cov=value --cov-report=xml --cov-report=term-missing
57+
58+
- name: Upload coverage to Codecov
59+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
60+
uses: codecov/codecov-action@v4
61+
with:
62+
files: ./coverage.xml
63+
fail_ci_if_error: false
64+
verbose: true
65+
66+
test-extras:
67+
runs-on: ubuntu-latest
68+
strategy:
69+
matrix:
70+
extra: [genai, langchain, all]
71+
72+
steps:
73+
- uses: actions/checkout@v4
74+
75+
- name: Set up Python
76+
uses: actions/setup-python@v5
77+
with:
78+
python-version: "3.11"
79+
80+
- name: Install Poetry
81+
uses: snok/install-poetry@v1
82+
with:
83+
version: latest
84+
virtualenvs-create: true
85+
virtualenvs-in-project: true
86+
87+
- name: Install with extra [${{ matrix.extra }}]
88+
run: poetry install --no-interaction --extras ${{ matrix.extra }}
89+
90+
- name: Verify extra imports work
91+
run: |
92+
poetry run python -c "from value import auto_instrument, get_supported_libraries; print(get_supported_libraries())"
93+
94+
build:
95+
runs-on: ubuntu-latest
96+
needs: [test]
97+
98+
steps:
99+
- uses: actions/checkout@v4
100+
101+
- name: Set up Python
102+
uses: actions/setup-python@v5
103+
with:
104+
python-version: "3.11"
105+
106+
- name: Install Poetry
107+
uses: snok/install-poetry@v1
108+
with:
109+
version: latest
110+
111+
- name: Build package
112+
run: poetry build
113+
114+
- name: Check package
115+
run: |
116+
pip install twine
117+
twine check dist/*
118+
119+
- name: Upload build artifacts
120+
uses: actions/upload-artifact@v4
121+
with:
122+
name: dist
123+
path: dist/

.github/workflows/publish.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
publish_to:
9+
description: "Publish to"
10+
required: true
11+
default: "testpypi"
12+
type: choice
13+
options:
14+
- testpypi
15+
- pypi
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.11"
28+
29+
- name: Install Poetry
30+
uses: snok/install-poetry@v1
31+
with:
32+
version: latest
33+
34+
- name: Build package
35+
run: poetry build
36+
37+
- name: Check package
38+
run: |
39+
pip install twine
40+
twine check dist/*
41+
42+
- name: Upload build artifacts
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: dist
46+
path: dist/
47+
48+
publish-testpypi:
49+
runs-on: ubuntu-latest
50+
needs: [build]
51+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.publish_to == 'testpypi'
52+
environment:
53+
name: testpypi
54+
url: https://test.pypi.org/project/value-python/
55+
56+
permissions:
57+
id-token: write
58+
59+
steps:
60+
- name: Download build artifacts
61+
uses: actions/download-artifact@v4
62+
with:
63+
name: dist
64+
path: dist/
65+
66+
- name: Publish to TestPyPI
67+
uses: pypa/gh-action-pypi-publish@release/v1
68+
with:
69+
repository-url: https://test.pypi.org/legacy/
70+
71+
publish-pypi:
72+
runs-on: ubuntu-latest
73+
needs: [build]
74+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish_to == 'pypi')
75+
environment:
76+
name: pypi
77+
url: https://pypi.org/project/value-python/
78+
79+
permissions:
80+
id-token: write
81+
82+
steps:
83+
- name: Download build artifacts
84+
uses: actions/download-artifact@v4
85+
with:
86+
name: dist
87+
path: dist/
88+
89+
- name: Publish to PyPI
90+
uses: pypa/gh-action-pypi-publish@release/v1

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Valmi.io
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)