-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
804 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [develop, release-**] | ||
|
||
defaults: | ||
run: | ||
working-directory: ./python/pytv1 | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.7" | ||
- name: Install hatch | ||
run: pip install --upgrade hatch | ||
- name: Run hatch build | ||
run: hatch --verbose build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: coverage | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [develop, release-**] | ||
|
||
defaults: | ||
run: | ||
working-directory: ./python/pytv1 | ||
|
||
jobs: | ||
coverage: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
total: ${{ steps.cov.outputs.total }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.7" | ||
- name: Install dependencies | ||
run: pip install -e ".[dev]" | ||
- name: Run pytest coverage | ||
id: cov | ||
shell: bash {0} | ||
run: | | ||
pytest --mock-url="${{ secrets.API_URL }}" --cov-fail-under=95 --cov-report=term-missing --cov-report=xml --cov=pytmv1 --verbose | ||
rc=$? | ||
echo "total=$(head -2 coverage.xml|grep -Po 'line-rate="\K\d{1}\.?\d{0,4}' |awk '{print $1 * 100}'|cut -d. -f1)" >> $GITHUB_OUTPUT | ||
exit $rc | ||
badge: | ||
runs-on: ubuntu-latest | ||
needs: coverage | ||
if: ${{ always() && github.event_name == 'push' && needs.coverage.outputs.total != '' }} | ||
steps: | ||
- name: Install curl | ||
run: sudo apt install -y curl | ||
- if: ${{ needs.coverage.outputs.total < 25 }} | ||
run: echo "color=red" >> $GITHUB_ENV | ||
- if: ${{ needs.coverage.outputs.total >= 25 && needs.coverage.outputs.total < 50 }} | ||
run: echo "color=orange" >> $GITHUB_ENV | ||
- if: ${{ needs.coverage.outputs.total >= 50 && needs.coverage.outputs.total < 75 }} | ||
run: echo "color=yellow" >> $GITHUB_ENV | ||
- if: ${{ needs.coverage.outputs.total >= 75 && needs.coverage.outputs.total < 90 }} | ||
run: echo "color=yellowgreen" >> $GITHUB_ENV | ||
- if: ${{ needs.coverage.outputs.total >= 90 && needs.coverage.outputs.total < 95 }} | ||
run: echo "color=green" >> $GITHUB_ENV | ||
- if: ${{ needs.coverage.outputs.total >= 95 }} | ||
run: echo "color=brightgreen" >> $GITHUB_ENV | ||
- name: Update coverage badge | ||
run: | | ||
curl \ | ||
-X PATCH \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.GIST_TOKEN }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/gists/6c39ef59cc8beb9595e91fc96793de5b \ | ||
-d '{ | ||
"files": { | ||
"coverage.json": { | ||
"content": "{\n\"schemaVersion\": 1,\n\"label\": \"coverage\",\n\"message\": \"${{ needs.coverage.outputs.total }}%\",\n\"color\": \"${{ env.color }}\"\n}" | ||
} | ||
} | ||
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: lint | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [develop, release-**] | ||
|
||
defaults: | ||
run: | ||
working-directory: ./python/pytv1 | ||
|
||
jobs: | ||
black: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.7" | ||
- name: Install dependencies | ||
run: pip install --upgrade pip black | ||
- name: Run black | ||
run: black --check --diff --verbose . | ||
isort: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.7" | ||
- name: Install dependencies | ||
run: pip install --upgrade pip isort[colors] | ||
- name: Run isort | ||
run: isort --check-only --diff --verbose . | ||
flake8: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.7" | ||
- name: Install dependencies | ||
run: pip install --upgrade pip flake8 | ||
- name: Run flake8 | ||
run: flake8 --verbose . | ||
mypy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.7" | ||
- name: Install dependencies | ||
run: pip install --upgrade pip mypy==1.0.1 pydantic==1.10.4 | ||
- name: Run mypy | ||
run: mypy --install-types --non-interactive ./src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "Release version" | ||
required: true | ||
type: string | ||
|
||
defaults: | ||
run: | ||
working-directory: ./python/pytv1 | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
env: | ||
VERSION: ${{ github.event.inputs.version }} | ||
BRANCH: pytv1-release-${{ github.event.inputs.version }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ssh-key: ${{ secrets.GIT_USER_SSH }} | ||
fetch-depth: 0 | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.7" | ||
- name: Set up Git | ||
run: | | ||
git config --add user.name "${{ secrets.GIT_USER_NAME }}" | ||
git config --add user.email "${{ secrets.GIT_USER_EMAIL }}" | ||
- name: Run build | ||
run: | | ||
pip install --upgrade hatch | ||
hatch version ${{ env.VERSION }} | ||
hatch --verbose build | ||
- name: Publish package to PyPI | ||
uses: pypa/[email protected] | ||
with: | ||
password: ${{ secrets.PYPI_TOKEN }} | ||
verbose: true | ||
- name: Merge release branch | ||
run: | | ||
git checkout ${{ env.BRANCH }} | ||
git commit -am "Release ${{ env.VERSION }}: increment version" | ||
git checkout main | ||
git merge --no-ff ${{ env.BRANCH }} | ||
git tag -a pytv1-${{ env.VERSION }} -m "Release ${{ env.VERSION }}" | ||
git checkout develop | ||
git merge --no-ff main | ||
git push --atomic origin main develop ${{ env.BRANCH }} refs/tags/pytv1-${{ env.VERSION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: test | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [develop, release-**] | ||
|
||
defaults: | ||
run: | ||
working-directory: ./python/pytv1 | ||
|
||
jobs: | ||
unit: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: pip install -e ".[dev]" | ||
- name: Run pytest | ||
run: pytest --mock-url="https://dummy.com" --verbose ./tests/unit | ||
integration: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: pip install -e ".[dev]" | ||
- name: Run pytest | ||
run: pytest --mock-url="${{ secrets.API_URL }}" --verbose ./tests/integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
*.DS_Store | ||
**\*.DS_Store | ||
.idea/ | ||
__pycache__/ | ||
.mypy_cache/ | ||
.pytest_cache/ | ||
.coverage | ||
venv/ |
File renamed without changes.
Oops, something went wrong.