Skip to content

Commit be6e98d

Browse files
committed
Merge remote-tracking branch 'origin/main' into 235-zenodo-integration
2 parents 2514217 + 72678ca commit be6e98d

File tree

8 files changed

+649
-19
lines changed

8 files changed

+649
-19
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
os: ['ubuntu-latest', 'macos-latest']
16+
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
1717
python-version: ['3.6', '3.7', '3.8', '3.9']
1818
steps:
1919
- uses: actions/checkout@v2

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ cookiecutter https://github.com/nlesc/python-template.git
6161
| package_name | my_python_package | Name of the package. Avoid using spaces, dashes, or uppercase letters for the best experience across operating systems. |
6262
| project_name | my-python-project | Name of the project that contains the package. Avoid using spaces or uppercase letters for the best experience across operating systems. |
6363
| package_short_description |   | The information that you enter here will end up in the README, documentation, license, and setup.cfg, so it may be a good idea to prepare something in advance. |
64+
| keyword1 | keyword1 | A term that describes your package. |
65+
| keyword2 | keyword2 | Another term that describes your package. |
6466
| version | 0.1.0 |   |
6567
| github_organization | <my-github-organization> | GitHub organization that will contain this project's repository. This can also be your GitHub user name. |
6668
| license | Apache Software License 2.0 | The software license under which the code is made available. |

cookiecutter.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"project_name": "my-python-project",
44
"_copy_without_render": [".github/workflows/*"],
55
"package_short_description": "",
6+
"keyword1": "keyword1",
7+
"keyword2": "keyword2",
68
"version": "0.1.0",
79
"github_organization": "<my-github-organization>",
810
"license": ["Apache Software License 2.0", "MIT license", "BSD license", "ISC license", "GNU General Public License v3 or later", "Not open source"],

tests/test_project.py

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import os
22
import subprocess
3+
from pathlib import Path
4+
from shutil import which
35
from sys import platform
46
from typing import Sequence
57

68
import pytest
79

10+
IS_WINDOWS = platform.startswith("win")
11+
IS_WINDOWS_CI = IS_WINDOWS and os.environ.get('CI', False)
12+
813

914
def test_project_folder(cookies):
1015
project = cookies.bake()
@@ -16,37 +21,46 @@ def test_project_folder(cookies):
1621

1722

1823
def run(args: Sequence[str], dirpath: os.PathLike) -> subprocess.CompletedProcess:
19-
return subprocess.run(args=args,
20-
stdout=subprocess.PIPE,
21-
stderr=subprocess.PIPE,
22-
cwd=dirpath,
23-
encoding="utf-8")
24+
completed_process = subprocess.run(args=args,
25+
stdout=subprocess.PIPE,
26+
stderr=subprocess.PIPE,
27+
cwd=dirpath,
28+
encoding="utf-8")
29+
print(completed_process.stdout)
30+
print(completed_process.stderr)
31+
return completed_process
2432

2533

2634
@pytest.fixture
2735
def baked_with_development_dependencies(cookies):
2836
result = cookies.bake()
29-
env_output = run(['python3', '-m', 'venv', 'env'], result.project)
30-
assert env_output.returncode == 0
31-
env_bin = 'env/Scripts/' if platform.startswith("win") else 'env/bin/'
32-
latest_pip_output = run([f'{env_bin}pip3', 'install', '--upgrade', 'pip', 'setuptools'], result.project)
37+
if IS_WINDOWS_CI:
38+
# Creating virtualenv does not work on Windows CI,
39+
# falling back to using current pip3 dir
40+
pip = Path(which('pip3'))
41+
bin_dir = str(pip.parent) + '\\'
42+
else:
43+
env_output = run(['python3', '-m', 'venv', 'env'], result.project)
44+
assert env_output.returncode == 0
45+
bin_dir = 'env/Scripts/' if IS_WINDOWS else 'env/bin/'
46+
latest_pip_output = run([f'{bin_dir}pip3', 'install', '--upgrade', 'pip', 'setuptools'], result.project)
3347
assert latest_pip_output.returncode == 0
34-
pip_output = run([f'{env_bin}pip3', 'install', '--editable', '.[dev]'], result.project)
48+
pip_output = run([f'{bin_dir}pip3', 'install', '--editable', '.[dev]'], result.project)
3549
assert pip_output.returncode == 0
36-
return result.project, env_bin
50+
return result.project, bin_dir
3751

3852

3953
def test_pytest(baked_with_development_dependencies):
40-
project_dir, env_bin = baked_with_development_dependencies
41-
pytest_output = run([f'{env_bin}pytest'], project_dir)
54+
project_dir, bin_dir = baked_with_development_dependencies
55+
pytest_output = run([f'{bin_dir}pytest'], project_dir)
4256
assert pytest_output.returncode == 0
4357
assert '== 4 passed in' in pytest_output.stdout
4458
assert (project_dir / 'coverage.xml').exists()
4559
assert (project_dir / 'htmlcov/index.html').exists()
4660

4761

4862
def test_subpackage(baked_with_development_dependencies):
49-
project_dir, env_bin = baked_with_development_dependencies
63+
project_dir, bin_dir = baked_with_development_dependencies
5064
subpackage = (project_dir / 'my_python_package' / 'mysub')
5165
subpackage.mkdir()
5266
(subpackage / '__init__.py').write_text('FOO = "bar"', encoding="utf-8")
@@ -55,7 +69,19 @@ def test_subpackage(baked_with_development_dependencies):
5569
subsubpackage.mkdir()
5670
(subsubpackage / '__init__.py').write_text('FOO = "bar"', encoding="utf-8")
5771

58-
build_output = run([f'{env_bin}python3', 'setup.py', 'build'], project_dir)
72+
if IS_WINDOWS_CI:
73+
# On Windows CI python and pip executable are in different paths
74+
bin_dir = ''
75+
build_output = run([f'{bin_dir}python', 'setup.py', 'build'], project_dir)
5976
assert build_output.returncode == 0
6077
assert (project_dir / 'build' / 'lib' / 'my_python_package' / 'mysub' / '__init__.py').exists()
6178
assert (project_dir / 'build' / 'lib' / 'my_python_package' / 'mysub' / 'mysub2' / '__init__.py').exists()
79+
80+
81+
def test_generate_api_docs(baked_with_development_dependencies):
82+
project_dir, bin_dir = baked_with_development_dependencies
83+
84+
build_output = run([f'{bin_dir}sphinx-build', '-b', 'html', 'docs', 'docs/_build/html'], project_dir)
85+
assert build_output.returncode == 0
86+
assert 'build succeeded' in build_output.stdout
87+
assert (project_dir / 'docs' / '_build' / 'html' / 'index.html').exists()

{{cookiecutter.project_name}}/.github/next_steps/02_citation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ It is likely that your `CITATION.cff` currently doesn't pass validation. The err
99
- [ ] Add more authors if needed
1010
- [ ] Update `date-released` using the YYYY-MM-DD format.
1111
- [ ] Update the `doi` key with the conceptDOI for your repository (see [https://help.zenodo.org](https://help.zenodo.org/) for more information on what a conceptDOI is). If your project doesn't have a DOI yet, you can use the string `10.0000/FIXME` to pass validation.
12-
- [ ] Update the `keywords` array with some keywords of your own that describe your project.
12+
- [ ] Verify that the `keywords` array accurately describes your project.
1313

1414
Once you do all the steps above, the `cffconvert` workflow will tell you what content it expected to see in `.zenodo.json`. Copy-paste from the GitHub Action log into a new file `.zenodo.json`. Afterwards, the `cffconvert` GitHub Action should be green.
1515

0 commit comments

Comments
 (0)