Skip to content

Commit 7b9f69a

Browse files
committed
chore: migrate from setuptools to Poetry
- Convert pyproject.toml to Poetry format - Add poetry.lock for reproducible builds - Update CI workflows to use Poetry: - Use snok/install-poetry action - Update actions/checkout to v4, setup-python to v5 - Add Python 3.11, 3.12 to feature branch test matrix - Move requests-mock to dev dependencies Build and publish to PyPI/TestPyPI unchanged.
1 parent adadc75 commit 7b9f69a

5 files changed

Lines changed: 515 additions & 73 deletions

File tree

.github/workflows/build-and-test-mlbstatsapi-prd.yml

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,36 @@
1-
name: Python Build MLBstats API
1+
name: Python Build MLBstats API
22

33
on:
44
push:
55
branches:
66
- main
7+
78
jobs:
89
build:
9-
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
1313
python-version: ["3.10"]
1414

1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v4
18+
uses: actions/setup-python@v5
1919
with:
2020
python-version: ${{ matrix.python-version }}
21+
- name: Install Poetry
22+
uses: snok/install-poetry@v1
23+
with:
24+
virtualenvs-create: true
25+
virtualenvs-in-project: true
2126
- name: Install dependencies
22-
run: |
23-
python3 -m pip install --upgrade pip
24-
python3 -m pip install --upgrade pytest
25-
python3 -m pip install --upgrade build
26-
python3 -m pip install --upgrade requests
27-
python3 -m pip install --upgrade requests_mock
27+
run: poetry install --no-interaction
2828
- name: Test with mocks with pytest
29-
run: |
30-
python3 -m pytest tests/mock_tests/*
29+
run: poetry run pytest tests/mock_tests/
3130
- name: Test external tests with pytest
32-
run: |
33-
python3 -m pytest tests/external_tests/*
34-
- name: build and install
35-
run: |
36-
python3 -m build
37-
python3 -m pip install .
31+
run: poetry run pytest tests/external_tests/
32+
- name: Build package
33+
run: poetry build
3834
- name: Publish a Python distribution to PyPI
3935
uses: pypa/gh-action-pypi-publish@release/v1
4036
with:

.github/workflows/build-and-test-mlbstatsapi-test.yml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,32 @@ on:
77

88
jobs:
99
build:
10-
1110
runs-on: ubuntu-latest
1211
strategy:
1312
matrix:
1413
python-version: ["3.10"]
1514

1615
steps:
17-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1817
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v4
18+
uses: actions/setup-python@v5
2019
with:
2120
python-version: ${{ matrix.python-version }}
21+
- name: Install Poetry
22+
uses: snok/install-poetry@v1
23+
with:
24+
virtualenvs-create: true
25+
virtualenvs-in-project: true
2226
- name: Install dependencies
23-
run: |
24-
python3 -m pip install --upgrade pip
25-
python3 -m pip install --upgrade pytest
26-
python3 -m pip install --upgrade build
27-
python3 -m pip install --upgrade requests
28-
python3 -m pip install --upgrade requests_mock
27+
run: poetry install --no-interaction
2928
- name: Test with mocks with pytest
30-
run: |
31-
python3 -m pytest tests/mock_tests/*
29+
run: poetry run pytest tests/mock_tests/
3230
- name: Test external tests with pytest
33-
run: |
34-
python3 -m pytest tests/external_tests/*
35-
- name: build and install
36-
run: |
37-
python3 -m build
38-
python3 -m pip install .
31+
run: poetry run pytest tests/external_tests/
32+
- name: Build package
33+
run: poetry build
3934
- name: Publish package to TestPyPI
4035
uses: pypa/gh-action-pypi-publish@release/v1
4136
with:
4237
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
4338
repository_url: https://test.pypi.org/legacy/
44-
45-
46-
Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Python Build MLBstats API
1+
name: Python Build MLBstats API
22

33
on:
44
push:
@@ -11,28 +11,24 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.10"]
14+
python-version: ["3.10", "3.11", "3.12"]
1515

1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1818
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v4
19+
uses: actions/setup-python@v5
2020
with:
2121
python-version: ${{ matrix.python-version }}
22+
- name: Install Poetry
23+
uses: snok/install-poetry@v1
24+
with:
25+
virtualenvs-create: true
26+
virtualenvs-in-project: true
2227
- name: Install dependencies
23-
run: |
24-
python3 -m pip install --upgrade pip
25-
python3 -m pip install --upgrade pytest
26-
python3 -m pip install --upgrade build
27-
python3 -m pip install --upgrade requests
28-
python3 -m pip install --upgrade requests_mock
28+
run: poetry install --no-interaction
2929
- name: Test with mocks with pytest
30-
run: |
31-
python3 -m pytest tests/mock_tests/*
30+
run: poetry run pytest tests/mock_tests/
3231
- name: Test external tests with pytest
33-
run: |
34-
python3 -m pytest tests/external_tests/*
35-
- name: build and install
36-
run: |
37-
python3 -m build
38-
python3 -m pip install .
32+
run: poetry run pytest tests/external_tests/
33+
- name: Build package
34+
run: poetry build

0 commit comments

Comments
 (0)