Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit e035740

Browse files
author
John Andersen
committed
Update to setup.cfg style add workflows
Signed-off-by: John Andersen <john.s.andersen@intel.com>
1 parent df71d2c commit e035740

23 files changed

+659
-161
lines changed

.coveragerc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[run]
2+
source =
3+
project_example_for_python
4+
tests
5+
branch = True
6+
7+
[report]
8+
exclude_lines =
9+
no cov
10+
no qa
11+
noqa
12+
pragma: no cover
13+
if __name__ == .__main__.:

.github/workflows/pages.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types:
9+
- opened
10+
branches:
11+
- main
12+
13+
jobs:
14+
pages:
15+
name: Build GitHub Pages
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Build docs
21+
run: |
22+
python3 -m pip install -U pip
23+
python3 -m pip install -U setuptools wheel
24+
python3 -m pip install .[dev]
25+
python3 -m sphinx -W -b html docs built_html_docs/
26+
echo ${{ github.ref }}
27+
- name: Deploy to GitHub Pages
28+
if: ${{ github.ref == 'refs/head/main' }}
29+
uses: crazy-max/ghaction-github-pages@v2
30+
with:
31+
target_branch: gh-pages
32+
build_dir: built_html_docs
33+
jekyll: false
34+
verbose: true
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Publish Release
2+
# From
3+
# https://github.com/pdxjohnny/httptest/blob/master/.github/workflows/release.yml
4+
5+
on:
6+
push:
7+
tags:
8+
- '*'
9+
workflow_dispatch: {}
10+
11+
jobs:
12+
build:
13+
name: Build
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version:
18+
- "3.10"
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Get pip cache
26+
id: pip-cache
27+
run: |
28+
python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
29+
- name: pip cache
30+
uses: actions/cache@v1
31+
with:
32+
path: ${{ steps.pip-cache.outputs.dir }}
33+
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
34+
restore-keys: |
35+
${{ runner.os }}-pip-
36+
- name: Install dependencies
37+
run: |
38+
python -m pip install -U pip setuptools wheel
39+
python -m pip install -U build
40+
- name: Build
41+
run: |
42+
python -m build .
43+
- uses: actions/upload-artifact@v2
44+
with:
45+
name: dist
46+
path: dist
47+
48+
pypi:
49+
name: PyPi
50+
runs-on: ubuntu-latest
51+
needs: build
52+
steps:
53+
- uses: actions/download-artifact@v2
54+
with:
55+
name: dist
56+
path: dist
57+
- name: Get pip cache
58+
id: pip-cache
59+
run: |
60+
python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
61+
- name: pip cache
62+
uses: actions/cache@v1
63+
with:
64+
path: ${{ steps.pip-cache.outputs.dir }}
65+
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
66+
restore-keys: |
67+
${{ runner.os }}-pip-
68+
- name: Install dependencies
69+
run: |
70+
python -m pip install -U pip setuptools wheel
71+
python -m pip install -U twine
72+
- name: Release
73+
env:
74+
TWINE_USERNAME: __token__
75+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
76+
run: |
77+
python -m twine upload dist/*
78+
79+
github:
80+
name: GitHub
81+
runs-on: ubuntu-latest
82+
needs: build
83+
steps:
84+
- uses: actions/checkout@v2
85+
- uses: actions/download-artifact@v2
86+
with:
87+
name: dist
88+
path: dist
89+
- name: Upload wheel
90+
env:
91+
GH_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
run: |
93+
set -x
94+
95+
tag=$(echo "${{ github.ref }}" | sed -e 's/.*\///g')
96+
97+
cd dist
98+
wheel=$(echo *.whl)
99+
100+
notes=$(curl \
101+
--header "Accept: application/vnd.github.v3+json" \
102+
--header "Authorization: Bearer ${GH_ACCESS_TOKEN}" \
103+
--url "https://api.github.com/repos/${{ github.repository }}/releases/generate-notes" \
104+
--data "{\"tag_name\": \"${tag}\"}")
105+
echo "${notes}"
106+
# TODO Update release body with notes, need to JSON escape
107+
# https://docs.github.com/en/rest/reference/releases#update-a-release
108+
109+
id=$(curl \
110+
--header "Accept: application/vnd.github.v3+json" \
111+
--header "Authorization: Bearer ${GH_ACCESS_TOKEN}" \
112+
--url "https://api.github.com/repos/${{ github.repository }}/releases/tags/${tag}" |
113+
grep '"id"' |
114+
head -n 1 |
115+
sed -e 's/.*"id": //' -e 's/,//')
116+
echo "release id: ${id}"
117+
118+
curl --request POST \
119+
--url "https://uploads.github.com/repos/${{ github.repository }}/releases/${id}/assets?name=${wheel}&access_token=${GH_ACCESS_TOKEN}" \
120+
--header "Authorization: Bearer ${GH_ACCESS_TOKEN}" \
121+
--header "Content-Type: application/octet-stream" \
122+
--data-binary @"${wheel}" \
123+
--fail

.github/workflows/testing.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
max-parallel: 40
11+
matrix:
12+
check: [style]
13+
python-version: [3.7]
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Get pip cache
22+
id: pip-cache
23+
run: |
24+
python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
25+
- name: pip cache
26+
uses: actions/cache@v1
27+
with:
28+
path: ${{ steps.pip-cache.outputs.dir }}
29+
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
30+
restore-keys: |
31+
${{ runner.os }}-pip-
32+
- name: Install dependencies
33+
run: |
34+
pip install -U black
35+
- name: Run check
36+
run: |
37+
black --check .
38+
39+
test:
40+
runs-on: ubuntu-latest
41+
strategy:
42+
fail-fast: false
43+
max-parallel: 40
44+
matrix:
45+
python-version:
46+
- 3.7
47+
- 3.8
48+
49+
steps:
50+
- uses: actions/checkout@v2
51+
- name: Set up Python ${{ matrix.python-version }}
52+
uses: actions/setup-python@v1
53+
with:
54+
python-version: ${{ matrix.python-version }}
55+
- name: Get pip cache
56+
id: pip-cache
57+
run: |
58+
python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
59+
- name: pip cache
60+
uses: actions/cache@v1
61+
with:
62+
path: ${{ steps.pip-cache.outputs.dir }}
63+
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
64+
restore-keys: |
65+
${{ runner.os }}-pip-
66+
- name: Install dependencies
67+
run: |
68+
set -x
69+
pip install -U pip
70+
pip install -U .
71+
- name: Test
72+
run: |
73+
set -x
74+
python -m unittest discover -v

.gitignore

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
1-
*__pycache__/
2-
*.swp
1+
*.log
32
*.pyc
3+
.cache/
4+
.coverage
5+
.idea/
6+
.vscode/
47
*.egg-info/
5-
pages/
8+
build/
9+
dist/
10+
docs/build/
11+
venv/
12+
wheelhouse/
13+
*.egss
14+
.mypy_cache/
15+
*.swp
16+
.venv/
17+
.eggs/
18+
*.modeldir
19+
*.db
20+
htmlcov/
21+
built_html_docs/

CONTRIBUTING.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONTRIBUTING
2+
############
3+
4+
See `docs <docs/contributing/index>`_

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) 2021 johnsa1
2+
3+
MIT License
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.

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include README.rst
2+
include LICENSE
3+
recursive-include project_example_for_python *

README.md

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)