Skip to content

Commit 37928de

Browse files
committed
Generate project using npx projen
1 parent bdab543 commit 37928de

14 files changed

+855
-0
lines changed

.github/workflows/ci.yml

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".
2+
name: ci
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
workflow_dispatch: {}
11+
jobs:
12+
lint:
13+
needs: []
14+
name: lint / ${{ matrix.os }} / ${{ matrix.python-version }}
15+
runs-on: ${{ matrix.os }}-latest
16+
strategy:
17+
matrix:
18+
os:
19+
- ubuntu
20+
python-version:
21+
- "3.9"
22+
steps:
23+
- name: checkout
24+
uses: actions/checkout@v2
25+
- name: set up Python ${{ matrix.python-version }}
26+
uses: actions/checkout@v2
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: get full Python version
30+
id: full-python-version
31+
run: echo ::set-output name=version::$(python -c "import sys;
32+
print('-'.join(str(v) for v in sys.version_info))")
33+
- name: install Poetry using bash
34+
if: matrix.os == 'ubuntu' || matrix.os == 'macos'
35+
run: >-
36+
curl -sSL
37+
https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
38+
| python
39+
40+
echo "::add-path::$HOME/.poetry/bin"
41+
- name: install Poetry using pwsh
42+
if: matrix.os == 'windows'
43+
run: >-
44+
(Invoke-WebRequest -Uri
45+
https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
46+
-UseBasicParsing).Content | python
47+
48+
echo "::add-path::$HOME/.poetry/bin"
49+
- name: set up cache
50+
uses: actions/cache@v2
51+
id: cache
52+
with:
53+
path: .venv
54+
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{
55+
hashFiles('**/poetry.lock') }}
56+
- name: ensure cache is healthy
57+
if: steps.cache.outputs.cache-hit == 'true'
58+
run: poetry run pip --version || rm -rf .venv
59+
- name: lint
60+
run: make lint
61+
test:
62+
needs:
63+
- lint
64+
name: test / ${{ matrix.os }} / ${{ matrix.python-version }}
65+
runs-on: ${{ matrix.os }}-latest
66+
strategy:
67+
matrix:
68+
os:
69+
- ubuntu
70+
- macos
71+
- windows
72+
python-version:
73+
- "3.6"
74+
- "3.7"
75+
- "3.8"
76+
- "3.9"
77+
steps:
78+
- name: checkout
79+
uses: actions/checkout@v2
80+
- name: set up Python ${{ matrix.python-version }}
81+
uses: actions/checkout@v2
82+
with:
83+
python-version: ${{ matrix.python-version }}
84+
- name: get full Python version
85+
id: full-python-version
86+
run: echo ::set-output name=version::$(python -c "import sys;
87+
print('-'.join(str(v) for v in sys.version_info))")
88+
- name: install Poetry using bash
89+
if: matrix.os == 'ubuntu' || matrix.os == 'macos'
90+
run: >-
91+
curl -sSL
92+
https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
93+
| python
94+
95+
echo "::add-path::$HOME/.poetry/bin"
96+
- name: install Poetry using pwsh
97+
if: matrix.os == 'windows'
98+
run: >-
99+
(Invoke-WebRequest -Uri
100+
https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
101+
-UseBasicParsing).Content | python
102+
103+
echo "::add-path::$HOME/.poetry/bin"
104+
- name: set up cache
105+
uses: actions/cache@v2
106+
id: cache
107+
with:
108+
path: .venv
109+
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{
110+
hashFiles('**/poetry.lock') }}
111+
- name: ensure cache is healthy
112+
if: steps.cache.outputs.cache-hit == 'true'
113+
run: poetry run pip --version || rm -rf .venv
114+
- name: test
115+
run: make test
116+
dependabot-automerge:
117+
if: github.actor == 'dependabot[bot]'
118+
needs:
119+
- lint
120+
- test
121+
name: dependabot-automerge
122+
runs-on: ubuntu-latest
123+
steps:
124+
- uses: actions/github-script@v3
125+
with:
126+
github-token: ${{ secrets.GITHUB_TOKEN }}
127+
script: |-
128+
github.pullRequests.createReview({
129+
owner: context.payload.repository.owner.login,
130+
repo: context.payload.repository.name,
131+
pull_number: context.payload.pull_request.number,
132+
event: 'APPROVE'
133+
})
134+
github.pullRequests.merge({
135+
owner: context.payload.repository.owner.login,
136+
repo: context.payload.repository.name,
137+
pull_number: context.payload.pull_request.number
138+
})

.github/workflows/publish.yml

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".
2+
name: publish
3+
on:
4+
push:
5+
tags:
6+
- "*.*.*"
7+
workflow_dispatch: {}
8+
jobs:
9+
publish:
10+
needs: []
11+
name: publish / ${{ matrix.os }} / ${{ matrix.python-version }}
12+
runs-on: ${{ matrix.os }}-latest
13+
strategy:
14+
matrix:
15+
os:
16+
- ubuntu
17+
python-version:
18+
- "3.8"
19+
steps:
20+
- name: checkout
21+
uses: actions/checkout@v2
22+
- name: set up Python ${{ matrix.python-version }}
23+
uses: actions/checkout@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: get full Python version
27+
id: full-python-version
28+
run: echo ::set-output name=version::$(python -c "import sys;
29+
print('-'.join(str(v) for v in sys.version_info))")
30+
- name: install Poetry using bash
31+
if: matrix.os == 'ubuntu' || matrix.os == 'macos'
32+
run: >-
33+
curl -sSL
34+
https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
35+
| python
36+
37+
echo "::add-path::$HOME/.poetry/bin"
38+
- name: install Poetry using pwsh
39+
if: matrix.os == 'windows'
40+
run: >-
41+
(Invoke-WebRequest -Uri
42+
https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
43+
-UseBasicParsing).Content | python
44+
45+
echo "::add-path::$HOME/.poetry/bin"
46+
- name: set up cache
47+
uses: actions/cache@v2
48+
id: cache
49+
with:
50+
path: .venv
51+
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{
52+
hashFiles('**/poetry.lock') }}
53+
- name: ensure cache is healthy
54+
if: steps.cache.outputs.cache-hit == 'true'
55+
run: poetry run pip --version || rm -rf .venv
56+
- name: get tag
57+
id: tag
58+
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
59+
- name: build dist
60+
run: make dist
61+
- name: check tag matches version
62+
run: ls dist/synth-a-py-${{ steps.tag.outputs.tag }}.tar.gz
63+
dist/synth-a-py-0.1.0.tar.gz dist/synth_a_py-${{ steps.tag.outputs.tag
64+
}}-py3-none-any.whl dist/synth_a_py-0.1.0-py3-none-any.whl
65+
- name: create release
66+
id: create_release
67+
uses: actions/create-release@v1
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
with:
71+
tag_name: ${{ steps.tag.outputs.tag }}
72+
release_name: ${{ steps.tag.outputs.tag }}
73+
draft: false
74+
prerelease: false
75+
- name: upload release asset
76+
uses: actions/upload-release-asset@v1
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
with:
80+
upload_url: ${{ steps.create_release.outputs.upload_url }}
81+
asset_path: dist/synth-a-py-0.1.0.tar.gz
82+
asset_name: synth-a-py-0.1.0.tar.gz
83+
asset_content_type: application/gzip
84+
- name: publish to pypi
85+
env:
86+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
87+
run: make publish

.gitignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".
2+
*.egg
3+
*.egg-info/
4+
*.pyc
5+
.cache/
6+
.idea/
7+
.mypy_cache/
8+
.venv/
9+
dist/
10+
node_modules/
11+
!/synth_a_py/__init__.py
12+
!/synth_a_py/py.typed
13+
!/tests/__init__.py
14+
!/tests/test_version.py
15+
!/stubs/pyprojroot.pyi
16+
!/README.md
17+
!/pyproject.toml
18+
!/poetry.toml
19+
!/LICENSE
20+
!/Makefile
21+
!/.github/workflows/ci.yml
22+
!/.github/workflows/publish.yml

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2020 Joseph Egan
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

Makefile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.PHONY: all
2+
all: lint test
3+
4+
.PHONY: lint
5+
lint: .venv
6+
MYPYPATH=./stubs poetry run mypy --strict synth_a_py tests
7+
poetry run flake8 synth_a_py tests
8+
poetry run isort --check-only --profile black synth_a_py tests
9+
poetry run black --check --diff synth_a_py tests
10+
11+
.PHONY: fmt
12+
fmt: .venv
13+
poetry run isort --profile black synth_a_py tests
14+
poetry run black synth_a_py tests
15+
16+
.PHONY: test
17+
test: .venv
18+
poetry run pytest --verbose --capture=no
19+
20+
.PHONY: publish
21+
publish: dist
22+
poetry publish
23+
24+
.PHONY: dist
25+
dist: dist/synth-a-py-0.1.0.tar.gz dist/synth_a_py-0.1.0-py3-none-any.whl
26+
27+
dist/synth-a-py-0.1.0.tar.gz dist/synth_a_py-0.1.0-py3-none-any.whl: $(shell find synth_a_py -type f -name '*.py')
28+
poetry build
29+
30+
.venv: poetry.lock
31+
poetry install
32+
@touch -c .venv
33+
34+
poetry.lock: pyproject.toml
35+
poetry lock
36+
@touch -c poetry.lock

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# synth-a-py
2+
3+
![Build](https://github.com/eganjs/synth-a-py/workflows/ci/badge.svg)
4+
5+
Project configuration as code
6+
7+
# Updating project config
8+
9+
To do this make edits to the `.projenrc.js` file in the root of the project and run `npx projen` to update existing or generate new config. Please also use `npx prettier --trailing-comma all --write .projenrc.js` to format this file.

0 commit comments

Comments
 (0)