Skip to content

Commit 12ee122

Browse files
authored
Merge pull request #5 from sonatype-nexus-community/feat/support-python-3.10
feat: typecheck this library #4 BREAKING CHANGE: #4 feat: Support for Python 3.10 #3 doc: Publish documentation #6 fix: Caching of OSS Index Responses can lead to exceptions? #2 feat: Support authentication to OSSIndex #1
2 parents 32f1ea7 + f4b8b01 commit 12ee122

32 files changed

+1901
-517
lines changed

.github/workflows/ci.yml

+76-20
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
#
2+
# Copyright 2022-Present Sonatype Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
116
# For details of what checks are run for PRs please refer below
217
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
318
name: Python CI
419

520
on:
621
push:
7-
branches: ["master"]
22+
branches: ["master", "main"]
823
pull_request:
924
workflow_dispatch:
1025
schedule:
@@ -14,10 +29,12 @@ on:
1429

1530
env:
1631
REPORTS_DIR: CI_reports
32+
PYTHON_VERISON_DEFAULT: "3.10"
33+
POETRY_VERSION: "1.1.11"
1734

1835
jobs:
1936
coding-standards:
20-
name: Linting & Coding Standards
37+
name: Linting & CodingStandards
2138
runs-on: ubuntu-latest
2239
steps:
2340
- name: Checkout
@@ -27,37 +44,78 @@ jobs:
2744
# see https://github.com/actions/setup-python
2845
uses: actions/setup-python@v2
2946
with:
30-
python-version: 3.9
47+
python-version: ${{ env.PYTHON_VERISON_DEFAULT }}
3148
architecture: 'x64'
3249
- name: Install poetry
3350
# see https://github.com/marketplace/actions/setup-poetry
3451
uses: Gr1N/setup-poetry@v7
3552
with:
36-
poetry-version: 1.1.8
37-
- uses: actions/cache@v2
38-
with:
39-
path: ~/.cache/pypoetry/virtualenvs
40-
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
53+
poetry-version: ${{ env.POETRY_VERSION }}
4154
- name: Install dependencies
42-
run: poetry install
55+
run: poetry install --no-root
4356
- name: Run tox
4457
run: poetry run tox -e flake8
4558

46-
build-and-test:
47-
name: Build & Test (Python ${{ matrix.python-version }}
59+
static-code-analysis:
60+
name: StaticCodingAnalysis (py${{ matrix.python-version}} ${{ matrix.toxenv-factor }})
4861
runs-on: ubuntu-latest
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
include:
66+
- # test with the locked dependencies
67+
python-version: '3.10'
68+
toxenv-factor: 'locked'
69+
- # test with the lowest dependencies
70+
python-version: '3.6'
71+
toxenv-factor: 'lowest'
72+
steps:
73+
- name: Checkout
74+
# see https://github.com/actions/checkout
75+
uses: actions/checkout@v2
76+
- name: Setup Python Environment
77+
# see https://github.com/actions/setup-python
78+
uses: actions/setup-python@v2
79+
with:
80+
python-version: ${{ matrix.python-version }}
81+
architecture: 'x64'
82+
- name: Install poetry
83+
# see https://github.com/marketplace/actions/setup-poetry
84+
uses: Gr1N/setup-poetry@v7
85+
with:
86+
poetry-version: ${{ env.POETRY_VERSION }}
87+
- name: Install dependencies
88+
run: poetry install --no-root
89+
- name: Run tox
90+
run: poetry run tox -e mypy-${{ matrix.toxenv-factor }}
91+
92+
build-and-test:
93+
name: Test (${{ matrix.os }} py${{ matrix.python-version }} ${{ matrix.toxenv-factor }})
94+
runs-on: ${{ matrix.os }}
4995
env:
5096
REPORTS_ARTIFACT: tests-reports
5197
strategy:
5298
fail-fast: false
5399
matrix:
100+
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
54101
python-version:
55-
- "3.9" # highest supported
102+
- "3.10" # highest supported
103+
- "3.9"
56104
- "3.8"
57105
- "3.7"
58106
- "3.6" # lowest supported
107+
toxenv-factor: ['locked']
108+
include:
109+
- # test with the lowest dependencies
110+
os: 'ubuntu-latest'
111+
python-version: '3.6'
112+
toxenv: 'lowest'
59113
timeout-minutes: 30
60114
steps:
115+
- name: Disabled Git auto EOL CRLF transforms
116+
run: |
117+
git config --global core.autocrlf false
118+
git config --global core.eol lf
61119
- name: Checkout
62120
# see https://github.com/actions/checkout
63121
uses: actions/checkout@v2
@@ -69,25 +127,23 @@ jobs:
69127
with:
70128
python-version: ${{ matrix.python-version }}
71129
architecture: 'x64'
130+
- name: Validate Python Environment
131+
run: echo "import sys; print('Python %s on %s in %s' % (sys.version, sys.platform, sys.getdefaultencoding()))" | python
72132
- name: Install poetry
73133
# see https://github.com/marketplace/actions/setup-poetry
74134
uses: Gr1N/setup-poetry@v7
75135
with:
76-
poetry-version: 1.1.8
77-
- uses: actions/cache@v2
78-
with:
79-
path: ~/.cache/pypoetry/virtualenvs
80-
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
136+
poetry-version: ${{ env.POETRY_VERSION }}
81137
- name: Install dependencies
82-
run: poetry install
138+
run: poetry install --no-root
83139
- name: Ensure build successful
84140
run: poetry build
85141
- name: Run tox
86-
run: poetry run tox -e py${{ matrix.python-version }}
142+
run: poetry run tox -e py-${{ matrix.toxenv-factor }} -s false
87143
- name: Generate coverage reports
88144
run: >
89145
poetry run coverage report &&
90-
poetry run coverage xml -o ${{ env.REPORTS_DIR }}/coverage.xml &&
146+
poetry run coverage xml -o ${{ env.REPORTS_DIR }}/coverage-${{ matrix.os }}-${{ matrix.python-version }}.xml &&
91147
poetry run coverage html -d ${{ env.REPORTS_DIR }}
92148
- name: Artifact reports
93149
if: ${{ ! cancelled() }}

.github/workflows/deploy.yml

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
#
2+
# Copyright 2022-Present Sonatype Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
116
name: Deploy to PyPI
217

318
on:
@@ -28,6 +43,5 @@ jobs:
2843
- name: Python Semantic Release
2944
uses: relekang/python-semantic-release@master
3045
with:
31-
# github_token: ${{ secrets.GITHUB_TOKEN }}
46+
github_token: ${{ secrets.GITHUB_TOKEN }}
3247
pypi_token: ${{ secrets.PYPI_TOKEN }}
33-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#
2+
# Copyright 2022-Present Sonatype Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
name: Manual Pre Release Publish
17+
18+
on:
19+
workflow_dispatch:
20+
inputs:
21+
release_candidate_suffix:
22+
description: 'RC Suffix e.g. rc0, beta1, alpha2. Do not include a leading hyphen.'
23+
required: true
24+
type: string
25+
26+
jobs:
27+
release_candidate:
28+
runs-on: ubuntu-latest
29+
concurrency: release_candidate
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v2
33+
with:
34+
fetch-depth: 0
35+
- uses: actions/setup-python@v2
36+
with:
37+
python-version: 3.9
38+
- name: Install dependencies
39+
run: |
40+
python -m pip install poetry --upgrade pip
41+
poetry config virtualenvs.create false
42+
poetry install
43+
python -m pip install python-semantic-release
44+
- name: Apply Pre Release Version
45+
run: |
46+
RC_VERSION="$(semantic-release --noop --major print-version)-${{ github.event.inputs.release_candidate_suffix }}"
47+
echo "RC Version will be: ${RC_VERSION}"
48+
poetry version ${RC_VERSION}
49+
poetry build
50+
- name: Publish Pre Release 📦 to PyPI
51+
uses: pypa/gh-action-pypi-publish@master
52+
with:
53+
password: ${{ secrets.PYPI_TOKEN }}

.mypy.ini

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#
2+
# Copyright 2022-Present Sonatype Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
[mypy]
17+
18+
files = ossindex/
19+
20+
show_error_codes = True
21+
pretty = True
22+
23+
warn_unreachable = True
24+
allow_redefinition = False
25+
26+
# ignore_missing_imports = False
27+
# follow_imports = normal
28+
# follow_imports_for_stubs = True
29+
30+
### Strict mode ###
31+
warn_unused_configs = True
32+
disallow_subclassing_any = True
33+
disallow_any_generics = True
34+
disallow_untyped_calls = True
35+
disallow_untyped_defs = True
36+
disallow_incomplete_defs = True
37+
check_untyped_defs = True
38+
disallow_untyped_decorators = True
39+
no_implicit_optional = True
40+
warn_redundant_casts = True
41+
warn_return_any = True
42+
no_implicit_reexport = True
43+
44+
# needed to silence some py37|py38 differences
45+
warn_unused_ignores = False
46+
47+
# See https://tinydb.readthedocs.io/en/latest/usage.html#mypy-type-checking
48+
plugins = tinydb.mypy_plugin
49+
50+
[mypy-pytest.*]
51+
ignore_missing_imports = True
52+
53+
[mypy-tests.*]
54+
disallow_untyped_decorators = False

.readthedocs.yaml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#
2+
# Copyright 2022-Present Sonatype Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
# Read the Docs configuration file
18+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
19+
20+
# Required
21+
version: 2
22+
23+
# Set the version of Python and other tools you might need
24+
build:
25+
os: ubuntu-20.04
26+
tools:
27+
python: "3.9"
28+
# You can also specify other tool versions:
29+
# nodejs: "16"
30+
# rust: "1.55"
31+
# golang: "1.17"
32+
33+
# Build documentation in the docs/ directory with Sphinx
34+
sphinx:
35+
configuration: docs/conf.py
36+
37+
# Formats
38+
formats: all
39+
40+
# Optionally declare the Python requirements required to build your docs
41+
python:
42+
install:
43+
- method: pip
44+
path: .
45+
- requirements: docs/requirements.txt

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/sonatype-nexus-community/ossindex-python/Python%20CI)
44
![Python Version Support](https://img.shields.io/badge/python-3.6+-blue)
55
![PyPI Version](https://img.shields.io/pypi/v/ossindex-lib?label=PyPI&logo=pypi)
6+
[![Documentation](https://readthedocs.org/projects/ossindex-library/badge/?version=latest)](https://readthedocs.org/projects/ossindex-library)
67
[![GitHub license](https://img.shields.io/github/license/sonatype-nexus-community/ossindex-python)](https://github.com/sonatype-nexus-community/ossindex-python/blob/main/LICENSE)
78
[![GitHub issues](https://img.shields.io/github/issues/sonatype-nexus-community/ossindex-python)](https://github.com/sonatype-nexus-community/ossindex-python/issues)
89
[![GitHub forks](https://img.shields.io/github/forks/sonatype-nexus-community/ossindex-python)](https://github.com/sonatype-nexus-community/ossindex-python/network)

docs/changelog.rst

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.. # Copyright 2022-Present Sonatype Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
.. mdinclude:: ../CHANGELOG.md

0 commit comments

Comments
 (0)