Skip to content

Commit 4f826d2

Browse files
authored
feat: setup the repo with CI using github actions
2 parents 920ff45 + 034d031 commit 4f826d2

12 files changed

+1239
-3
lines changed

.flake8

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[flake8]
2+
exclude = .git,.eggs,__pycache__,venv,old,build,dist,*.egg-info,.venv
3+
max-line-length = 120
4+
extend-ignore =
5+
# See https://github.com/PyCQA/pycodestyle/issues/373
6+
E203

.github/pull_request_template.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
To help us get this pull request reviewed and merged quickly, please be sure to include the following items:
2+
3+
* [ ] Tests (if applicable)
4+
* [ ] Documentation (if applicable)
5+
* [ ] A full explanation here in the PR description of the work done and statistical methods used
6+
7+
## PR Type
8+
What kind of change does this PR introduce?
9+
10+
* [ ] Bugfix
11+
* [ ] Feature
12+
* [ ] Code style update (formatting, local variables)
13+
* [ ] Refactoring (no functional changes, no api changes)
14+
* [ ] Build related changes
15+
* [ ] CI related changes
16+
* [ ] Documentation content changes
17+
* [ ] Tests
18+
* [ ] Other
19+
20+
## Backward Compatibility
21+
22+
Is this change backward compatible with the most recently released version? Does it introduce changes which might change the user experience in any way? Does it alter the API in any way?
23+
24+
* [ ] Yes (backward compatible)
25+
* [ ] No (breaking changes)

.github/workflows/ci.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: CI
2+
3+
on:
4+
pull_request: {}
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
tests:
10+
name: Format and Tests
11+
runs-on: "${{ matrix.os }}"
12+
continue-on-error: ${{ matrix.experimental }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-latest]
17+
python-version: ['3.7', '3.8', '3.9', '3.10']
18+
experimental: [false]
19+
include:
20+
- os: ubuntu-latest
21+
- os: windows-latest
22+
- os: macos-latest
23+
env:
24+
PYTHON: ${{ matrix.python-version }}
25+
OS: ${{ matrix.os }}
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
30+
- name: Set up Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v2
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
35+
- name: Get full Python version
36+
id: full-python-version
37+
shell: bash
38+
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
39+
40+
- name: Bootstrap poetry
41+
shell: bash
42+
run: |
43+
curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py \
44+
| python - -y ${{ matrix.bootstrap-args }}
45+
- name: Update PATH
46+
if: ${{ matrix.os != 'windows-latest' }}
47+
shell: bash
48+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
49+
50+
- name: Update Path for Windows
51+
if: ${{ matrix.os == 'windows-latest' }}
52+
shell: bash
53+
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
54+
55+
- name: Configure poetry
56+
shell: bash
57+
run: poetry config virtualenvs.in-project true
58+
59+
- name: Set up cache
60+
uses: actions/cache@v2
61+
id: cache
62+
with:
63+
path: .venv
64+
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
65+
66+
- name: Ensure cache is healthy
67+
if: steps.cache.outputs.cache-hit == 'true'
68+
shell: bash
69+
run: timeout 10s poetry run pip --version || rm -rf .venv
70+
71+
- name: Install dependencies
72+
shell: bash
73+
run: poetry install
74+
75+
- name: Format check
76+
shell: bash
77+
run: poetry run format-check
78+
79+
- name: Lint
80+
shell: bash
81+
run: poetry run lint
82+
83+
- name: Lint
84+
shell: bash
85+
run: poetry run type-check
86+
87+
- name: Unit test
88+
shell: bash
89+
run: poetry run test

CONTRIBUTING.md

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,85 @@ approved, other developers with commit access may commit it for the author. When
107107
doing so, it is important to retain correct attribution of the contribution.
108108
Generally speaking, Git handles attribution automatically.
109109
110+
## Development
111+
112+
### Local Setup
113+
114+
This project uses [Poetry](https://python-poetry.org/) to manage its dependencies. If you are not familiar with this tool, we highly recommend checking out [poetry docs](https://python-poetry.org/docs/) to get used to the basic usage.
115+
116+
Step 1: Install Poetry [here](https://python-poetry.org/docs/#installation)
117+
118+
Step 2: Run poetry install
119+
120+
Step 3: Optionally Run poetry shell
121+
122+
Additional info if you run into trouble: [Poetry Environments](https://python-poetry.org/docs/managing-environments/)
123+
124+
You could use pyenv with poetry together by following [this section](#setup-with-pyenv)
125+
126+
### Setup with pyenv
127+
128+
It is recommended to use pyenv to switch between Python versions:
129+
130+
Install pyenv [here]https://github.com/pyenv/pyenv#installation)
131+
132+
Install and set python version with pyenv:
133+
134+
```console
135+
pyenv install 3.7.8
136+
pyenv local 3.7.8
137+
```
138+
139+
Note: You are welcome to use any python version >= 3.7.1
140+
141+
To validate that your poetry venv is using the correct python version
142+
143+
```console
144+
poetry env info
145+
```
146+
147+
Once pyenv and poetry are installed correctly:
148+
149+
Install dependencies
150+
151+
```console
152+
poetry install
153+
```
154+
155+
### Scripts
156+
157+
A number of common checks and tools have been wired up with poetry scripts. Here are some examples
158+
159+
#### Linting
160+
```
161+
poetry run lint # will run the linter checks configured for this project
162+
```
163+
164+
#### Testing
165+
```
166+
poetry run test # run unit tests uning the testing framworks configured for this project
167+
```
168+
169+
#### Format checking
170+
```
171+
poetry run format # run a format checker configured for this project.
172+
```
173+
174+
#### Type checking
175+
```
176+
poetry run type-check # run type check configured for this project.
177+
```
178+
179+
#### All checks
180+
There is also an easy way to run all of these checks at once:
181+
182+
```
183+
poetry run qa # run all checks
184+
```
185+
110186
## Code Style and Documentation
111187

112-
Ensure that your contribution follows the standards set by the project's style
113-
guide with respect to patterns, naming, documentation and testing.
188+
Ensure that your contribution follows the [PEP 8 – Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/) style guide with respect to patterns, naming, documentation and testing.
114189

115190
# Additional Resources
116191

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# sample-size
1+
# sample-size
2+
3+
This python project is a helper package that uses power analysis to calculate required sample size for any experiment.
4+
5+
## Contributing
6+
7+
All contributors and contributions are welcome! Please see the [contributing docs](CONTRIBUTING.md) for more information.

0 commit comments

Comments
 (0)