Skip to content

Commit 0a37530

Browse files
authored
Initial commit
0 parents  commit 0a37530

24 files changed

+1083
-0
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 =
3+
.git,
4+
__pycache__,
5+
build
6+
max-complexity = 10

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/ISSUE_TEMPLATE/user-story.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: User story
3+
about: This template provides a basic structure for user story issues.
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
# User story
11+
As a ..., I want to ..., so I can ...
12+
13+
*Ideally, this is in the issue title, but if not, you can put it here. If so, delete this section.*
14+
15+
# Acceptance criteria
16+
- [ ] This is something that can be verified to show that this user story is satisfied.
17+
18+
# Sprint Ready Checklist
19+
- [ ] 1. Acceptance criteria defined
20+
- [ ] 2. Team understands acceptance criteria
21+
- [ ] 3. Team has defined solution / steps to satisfy acceptance criteria
22+
- [ ] 4. Acceptance criteria is verifiable / testable
23+
- [ ] 5. External / 3rd Party dependencies identified
24+
- [ ] 6. Ticket is prioritized and sized
25+
26+
# Notes
27+
*Add any helpful notes here.*

.github/workflows/init.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Workflow runs only once when the template is first used.
2+
# File can be safely deleted after repo is initialized.
3+
name: Initialize repository
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
initialize-package:
11+
name: Initialize the package
12+
if: ${{github.event.repository.name != 'aind-library-template'}}
13+
runs-on: ubuntu-latest
14+
env:
15+
REPO_NAME: ${{ github.event.repository.name }}
16+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
- name: Rename package
21+
run: |
22+
pkg_name=$(echo "${REPO_NAME}" | tr - _)
23+
current_description='description = "Prints messages to stdout. Simple boilerplate for libraries."'
24+
new_description='description = "Generated from aind-library-template"'
25+
readme_description='Template for a minimal, basic repository for an AIND library.'
26+
new_readme_description='Generated from aind-library-template'
27+
echo "Package Name ${pkg_name}"
28+
mkdir src/${pkg_name}
29+
touch src/${pkg_name}/__init__.py
30+
echo '"""Init package"""' >> src/${pkg_name}/__init__.py
31+
echo '__version__ = "0.0.0"' >> src/${pkg_name}/__init__.py
32+
sed -i "s/aind_library_template/${pkg_name}/" pyproject.toml
33+
sed -i "s/aind-library-template/${REPO_NAME}/" pyproject.toml
34+
sed -i "s/aind_library_template/${pkg_name}/" doc_template/source/conf.py
35+
sed -i "s/${current_description}/${new_description}/" pyproject.toml
36+
sed -i "/pandas/d" pyproject.toml
37+
sed -i "s/aind-library-template/${REPO_NAME}/" README.md
38+
sed -i "s/${readme_description}/${new_readme_description}/" README.md
39+
- name: Commit changes
40+
uses: EndBug/add-and-commit@v9
41+
with:
42+
default_author: github_actions
43+
message: "ci: version bump [skip actions]"
44+
add: '["pyproject.toml", "README.md", "src/*", "doc_template/source/conf.py"]'
45+
remove: '["-r src/aind_library_template", "tests/test_message_handler.py"]'
46+
- name: Add first tag
47+
run: |
48+
git tag v0.0.0
49+
git push origin v0.0.0
50+
- name: Disable workflow
51+
run: |
52+
gh workflow disable -R $GITHUB_REPOSITORY "${{ github.workflow }}"

.github/workflows/tag_and_publish.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Tag and publish
2+
on:
3+
push:
4+
branches:
5+
- main
6+
# Remove line 61 to enable automated semantic version bumps.
7+
# Change line 67 from "if: false" to "if: true" to enable PyPI publishing.
8+
# Requires that svc-aindscicomp be added as an admin to repo.
9+
jobs:
10+
update_badges:
11+
runs-on: ubuntu-latest
12+
continue-on-error: true
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
ref: ${{ env.DEFAULT_BRANCH }}
17+
fetch-depth: 0
18+
token: ${{ secrets.SERVICE_TOKEN }}
19+
- name: Set up Python 3.8
20+
uses: actions/setup-python@v3
21+
with:
22+
python-version: 3.8
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install -e .[dev] --no-cache-dir
26+
- name: Get Python version and Update README.md
27+
run: |
28+
python_version=$(grep "requires-python" pyproject.toml | grep -o ">=[^\"]*")
29+
python_badge=$(grep -o 'python-[^)]*' README.md)
30+
new_python_badge="python-$python_version-blue?logo=python"
31+
sed -i "s/$python_badge/$new_python_badge/g" README.md
32+
- name: Get interrogate values and Update README.md
33+
run: |
34+
interrogate_val=$(interrogate . | grep -o 'actual: [0-9]*\.[0-9]*' | awk '{print $2}')
35+
interrogate_badge=$(grep -o 'interrogate-[^)]*' README.md)
36+
if (( $(echo "$interrogate_val >= 90.00" | bc -l) )); then
37+
new_interrogate_badge="interrogate-$interrogate_val%25-brightgreen"
38+
elif (( $(echo "$interrogate_val < 80.00" | bc -l) )); then
39+
new_interrogate_badge="interrogate-$interrogate_val%25-red"
40+
else
41+
new_interrogate_badge="interrogate-$interrogate_val%25-yellow"
42+
fi
43+
sed -i "s/$interrogate_badge/$new_interrogate_badge/g" README.md
44+
- name: Get Coverage values and Update README.md
45+
run: |
46+
coverage run -m unittest discover
47+
coverage_val=$(coverage report | grep "^TOTAL" | grep -o '[0-9]\+%' | grep -o '[0-9]\+')
48+
coverage_badge=$(grep -o "coverage-[^?]*" README.md)
49+
if (( $(echo "$coverage_val >= 90.00" | bc -l) )); then
50+
new_coverage_badge="coverage-$coverage_val%25-brightgreen"
51+
elif (( $(echo "$coverage_val < 80.00" | bc -l) )); then
52+
new_coverage_badge="coverage-$coverage_val%25-red"
53+
else
54+
new_coverage_badge="coverage-$coverage_val%25-yellow"
55+
fi
56+
sed -i "s/$coverage_badge/$new_coverage_badge/g" README.md
57+
- name: Commit changes
58+
uses: EndBug/add-and-commit@v9
59+
with:
60+
default_author: github_actions
61+
message: "ci: update badges [skip actions]"
62+
add: '["README.md"]'
63+
tag:
64+
needs: update_badges
65+
if: ${{github.event.repository.name == 'aind-library-template'}}
66+
uses: AllenNeuralDynamics/aind-github-actions/.github/workflows/tag.yml@main
67+
secrets:
68+
SERVICE_TOKEN: ${{ secrets.SERVICE_TOKEN }}
69+
publish:
70+
needs: tag
71+
if: false
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v3
75+
- name: Pull latest changes
76+
run: git pull origin main
77+
- name: Set up Python 3.8
78+
uses: actions/setup-python@v2
79+
with:
80+
python-version: 3.8
81+
- name: Install dependencies
82+
run: |
83+
pip install --upgrade setuptools wheel twine build
84+
python -m build
85+
twine check dist/*
86+
- name: Publish on PyPI
87+
uses: pypa/gh-action-pypi-publish@release/v1
88+
with:
89+
password: ${{ secrets.AIND_PYPI_TOKEN }}

.github/workflows/test_and_lint.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Lint and run tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
ci:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version: [ '3.8', '3.9', '3.10' ]
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v3
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install -e .[dev]
23+
- name: Run linter checks
24+
run: flake8 . && interrogate --verbose .
25+
- name: Run tests and coverage
26+
run: coverage run -m unittest discover && coverage report

0 commit comments

Comments
 (0)