Skip to content

Commit d995042

Browse files
authored
Merge pull request #19 from soda480/0.3.1
build: add ability to build against all targeted Python versions
2 parents 493ecaa + 70f255f commit d995042

File tree

6 files changed

+65
-32
lines changed

6 files changed

+65
-32
lines changed

.github/workflows/main.yml

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,48 @@ on:
99
branches:
1010
- main
1111
jobs:
12-
build:
12+
build-images:
13+
strategy:
14+
matrix:
15+
version: ['3.7', '3.8', '3.9', '3.10']
16+
name: Build Python Docker images
1317
runs-on: ubuntu-20.04
1418
steps:
15-
- uses: actions/checkout@v2
16-
17-
- name: Build Docker image
18-
run: |
19-
docker image build --target build-image -t github3api:latest .
20-
21-
- name: Prepare coverage
22-
run: |
23-
ID=$(docker create github3api)
24-
docker cp $ID:/code/target/reports/github3api_coverage.xml github3api_coverage.xml
25-
sed -i -e 's,filename="github3api/,filename="src/main/python/github3api/,g' github3api_coverage.xml
26-
27-
- name: Upload coverage to Codecov
28-
uses: codecov/codecov-action@v1
29-
with:
30-
token: ${{ secrets.CODECOV_TOKEN }}
31-
file: github3api_coverage.xml
19+
- uses: actions/checkout@v3
20+
- name: build github3api ${{ matrix.version }} image
21+
run:
22+
docker image build --target build-image --build-arg PYTHON_VERSION=${{ matrix.version }} -t github3api:${{ matrix.version }} .
23+
- name: save github3api ${{ matrix.version }} image
24+
if: ${{ matrix.version == '3.9' }}
25+
run: |
26+
mkdir -p images
27+
docker save --output images/github3api-${{ matrix.version }}.tar github3api:${{ matrix.version }}
28+
- name: upload github3api ${{ matrix.version }} image artifact
29+
if: ${{ matrix.version == '3.9' }}
30+
uses: actions/upload-artifact@v2
31+
with:
32+
name: image
33+
path: images/github3api-${{ matrix.version }}.tar
34+
coverage:
35+
name: Publish Code Coverage Report
36+
needs: build-images
37+
runs-on: ubuntu-20.04
38+
steps:
39+
- name: download image artifact
40+
uses: actions/download-artifact@v2
41+
with:
42+
name: image
43+
path: images/
44+
- name: load image
45+
run:
46+
docker load --input images/github3api-3.9.tar
47+
- name: prepare report
48+
run: |
49+
ID=$(docker create github3api:3.9)
50+
docker cp $ID:/code/target/reports/github3api_coverage.xml github3api_coverage.xml
51+
sed -i -e 's,filename="github3api/,filename="src/main/python/github3api/,g' github3api_coverage.xml
52+
- name: upload report
53+
uses: codecov/codecov-action@v1
54+
with:
55+
token: ${{ secrets.CODECOV_TOKEN }}
56+
file: github3api_coverage.xml

Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
FROM python:3.9-slim AS build-image
16+
ARG PYTHON_VERSION=3.9
17+
FROM python:${PYTHON_VERSION}-slim AS build-image
1718
ENV PYTHONDONTWRITEBYTECODE 1
1819
WORKDIR /code
1920
COPY . /code/
20-
RUN pip install pybuilder
21-
RUN pyb install
21+
RUN pip install --upgrade pip && pip install pybuilder
22+
RUN pyb -X && pyb install
2223

23-
FROM python:3.9-alpine
24+
FROM python:${PYTHON_VERSION}-slim
2425
ENV PYTHONDONTWRITEBYTECODE 1
2526
WORKDIR /opt/github3api
2627
COPY --from=build-image /code/target/dist/github3api-*/dist/github3api-*.tar.gz /opt/github3api

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
# github3api #
1+
# github3api
22
[![GitHub Workflow Status](https://github.com/soda480/github3api/workflows/build/badge.svg)](https://github.com/soda480/github3api/actions)
33
[![Code Coverage](https://codecov.io/gh/soda480/github3api/branch/master/graph/badge.svg)](https://codecov.io/gh/soda480/github3api)
44
[![Code Grade](https://api.codiga.io/project/13337/status/svg)](https://frontend.code-inspector.com/project/13337/dashboard)
55
[![vulnerabilities](https://img.shields.io/badge/vulnerabilities-None-brightgreen)](https://pypi.org/project/bandit/)
66
[![PyPI version](https://badge.fury.io/py/github3api.svg)](https://app.codiga.io/public/project/13337/github3api/dashboard)
7-
[![python](https://img.shields.io/badge/python-3.9-teal)](https://www.python.org/downloads/)
7+
[![python](https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9%20%7C%203.10-teal)](https://www.python.org/downloads/)
88

99
An advanced REST client for the GitHub API. It is a subclass of [rest3client](https://pypi.org/project/rest3client/) tailored for the GitHub API with special optional directives for GET requests that can return all pages from an endpoint or return a generator that can be iterated over (for paged requests). By default all requests will be retried if ratelimit request limit is reached.
1010

1111
Support for executing Graphql queries including paging; Graphql queries are also retried if Graphql rate limiting occurs.
1212

1313

14-
### Installation ###
14+
### Installation
1515
```bash
1616
pip install github3api
1717
```
1818

19-
### Example Usage ###
19+
### Example Usage
2020

2121
```python
2222
>>> from github3api import GitHubAPI
@@ -132,7 +132,7 @@ For Graphql paged queries:
132132
- the keys method argument is a dot annotated string that is used to access the resulting dictionary response object
133133
- the query is retried every 60 seconds (for up to an hour) if a ratelimit occur
134134

135-
### Projects using `github3api` ###
135+
### Projects using `github3api`
136136

137137
* [edgexfoundry/sync-github-labels](https://github.com/edgexfoundry/cd-management/tree/git-label-sync) A script that synchronizes GitHub labels and milestones
138138

@@ -146,7 +146,7 @@ For Graphql paged queries:
146146

147147
* [edgexfoundry/edgex-dev-badge](https://github.com/edgexfoundry/edgex-dev-badge) Rules based GitHub badge scanner
148148

149-
### Development ###
149+
### Development
150150

151151
Ensure the latest version of Docker is installed on your development server. Fork and clone the repository.
152152

@@ -169,7 +169,7 @@ docker container run \
169169
-e https_proxy \
170170
-v $PWD:/code \
171171
github3api:latest \
172-
/bin/bash
172+
bash
173173
```
174174

175175
Execute the build:

build.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
authors = [Author('Emilio Reyes', 'emilio.reyes@intel.com')]
3131
summary = 'An advanced REST client for the GitHub API'
3232
url = 'https://github.com/soda480/github3api'
33-
version = '0.3.0'
33+
version = '0.3.1'
3434
default_task = [
3535
'clean',
3636
'analyze',
@@ -65,10 +65,10 @@ def set_properties(project):
6565
'License :: OSI Approved :: Apache Software License',
6666
'Operating System :: POSIX :: Linux',
6767
'Programming Language :: Python',
68-
'Programming Language :: Python :: 3.6',
6968
'Programming Language :: Python :: 3.7',
7069
'Programming Language :: Python :: 3.8',
7170
'Programming Language :: Python :: 3.9',
71+
'Programming Language :: Python :: 3.10',
7272
'Topic :: Software Development :: Libraries',
7373
'Topic :: Software Development :: Libraries :: Python Modules',
7474
'Topic :: System :: Networking',
@@ -77,4 +77,3 @@ def set_properties(project):
7777
project.set_property('radon_break_build_complexity_threshold', 14)
7878
project.set_property('bandit_break_build', True)
7979
project.set_property('anybadge_exclude', 'coverage, complexity')
80-
project.set_property('anybadge_use_shields', True)

build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
versions=( '3.7' '3.8' '3.9' '3.10' )
2+
for version in "${versions[@]}";
3+
do
4+
docker image build --build-arg PYTHON_VERSION=$version -t github3api:$version .
5+
done

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["pybuilder>=0.12.0"]
3+
build-backend = "pybuilder.pep517"

0 commit comments

Comments
 (0)