-
Notifications
You must be signed in to change notification settings - Fork 16
154 lines (139 loc) · 5.83 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: CI for Template
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: 45 6 * * *
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
tests:
name: ${{ matrix.copier_config.name }} - Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ['3.8', '3.9', '3.10']
copier_config:
- name: Base example
package_name: example_package # The default package_name
extra_flags: ''
foldername: base_example
- name: Black w/o example module
package_name: 'drewtonian' # Same module name provided in `extra_flags` on the next line.
extra_flags: >-
--data project_name=new_science
--data package_name=drewtonian
--data author_name=Drew
--data [email protected]
--data project_license=BSD
--data preferred_linter=black
--data use_isort=false
--data mypy_type_checking=basic
--data create_example_module=no
--data include_notebooks=no
--data use_gitlfs=disabled
foldername: 'black_w_o_example_module'
- name: Black w/ example
package_name: 'drewtonian' # Same module name provided in `extra_flags` on the next line.
extra_flags: >-
--data project_name=new_science
--data package_name=drewtonian
--data author_name=Drew
--data [email protected]
--data project_license=BSD
--data preferred_linter=black
--data use_isort=false
--data mypy_type_checking=basic
--data create_example_module=yes
--data include_notebooks=no
--data use_gitlfs=disabled
foldername: 'black_w_example_module'
- name: Pylint w/o example
package_name: 'drewtonian' # Same module name provided in `extra_flags` on the next line.
extra_flags: >-
--data project_name=new_science
--data package_name=drewtonian
--data author_name=Drew
--data [email protected]
--data project_license=BSD
--data preferred_linter=pylint
--data use_isort=false
--data mypy_type_checking=basic
--data create_example_module=no
--data include_notebooks=no
--data use_gitlfs=disabled
foldername: 'pylint_w_o_example_module'
- name: No sphinx docs
package_name: 'drewtonian'
extra_flags: >-
--data project_name=new_science
--data package_name=drewtonian
--data include_docs=no
--data include_notebooks=no
foldername: 'no_sphinx_docs'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
sudo apt-get update
python -m pip install --upgrade pip
python -m pip install copier mypy
- name: Generate package
run: |
copier copy --vcs-ref HEAD --defaults ${{ matrix.copier_config.extra_flags }} ./ ../test/${{ matrix.copier_config.foldername }}
cd ../test/${{ matrix.copier_config.foldername }}
cat .copier-answers.yml
- name: Build package
run: |
cd ../test/${{ matrix.copier_config.foldername }}
git config --global user.email "[email protected]"
git config --global user.name "Test Name"
git init --initial-branch=main
git add src
git commit -m initial
pip install .
pip install .[dev]
- name: pylint checks
if: ${{ contains (matrix.copier_config.name, 'Base') }}
run: |
cd ../test/${{ matrix.copier_config.foldername }}
python -m pylint --recursive=y ./src/ --rcfile=./src/.pylintrc
- name: black checks
if: ${{ contains(matrix.copier_config.extra_flags, 'preferred_linter=black') }}
uses: psf/black@stable
with:
src: "../test/${{ matrix.copier_config.foldername }}/src"
- name: mypy checks basic
if: ${{ contains(matrix.copier_config.extra_flags, 'mypy_type_checking=basic') && !contains(matrix.copier_config.extra_flags, 'create_example_module=no') }}
run: |
cd "../test/${{ matrix.copier_config.foldername }}"
mypy src tests
- name: mypy checks strict
if: ${{ contains(matrix.copier_config.extra_flags, 'mypy_type_checking=strict') && !contains(matrix.copier_config.extra_flags, 'create_example_module=no') }}
run: |
cd "../test/${{ matrix.copier_config.foldername }}"
mypy --strict src tests
- name: Install notebook requirements
if: ${{ !contains(matrix.copier_config.extra_flags, 'include_notebooks=no') }}
run: |
sudo apt-get install pandoc
pip install -r ../test/${{ matrix.copier_config.foldername }}/docs/requirements.txt
cat ../test/${{ matrix.copier_config.foldername }}/docs/requirements.txt
- name: Build docs
if: ${{ !contains(matrix.copier_config.extra_flags, 'include_docs=no') }}
run: |
cd ../test/${{ matrix.copier_config.foldername }}
sphinx-build -T -E -b html -d docs/build/doctrees ./docs docs/build/html
- name: Tests
if: ${{ !contains(matrix.copier_config.extra_flags, 'create_example_module=no') }}
run: |
cd ../test/${{ matrix.copier_config.foldername }}
python -m pytest tests --cov=${{ matrix.copier_config.package_name }} --cov-report=xml