Skip to content

Commit 40ecc59

Browse files
authored
Initial commit
0 parents  commit 40ecc59

28 files changed

+1362
-0
lines changed

.flake8

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[flake8]
2+
exclude =
3+
.git,
4+
__pycache__,
5+
build,
6+
.venv,
7+
venv,
8+
.conda
9+
max-complexity = 10
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.
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/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "pip"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
- package-ecosystem: "github-actions"
13+
directory: "/"
14+
schedule:
15+
interval: "weekly"

.github/workflows/init.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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@v4
20+
- name: Rename package
21+
run: |
22+
current_date=$(date '+%Y-%m-%d')
23+
pkg_name=$(echo "${REPO_NAME}" | tr - _)
24+
current_description='description = "Prints messages to stdout. Simple boilerplate for libraries."'
25+
new_description='description = "Generated from aind-library-template"'
26+
readme_description='Template for a minimal, basic repository for an AIND library.'
27+
new_readme_description='Generated from aind-library-template'
28+
echo "Package Name ${pkg_name}"
29+
mkdir src/${pkg_name}
30+
touch src/${pkg_name}/__init__.py
31+
echo '"""Init package"""' >> src/${pkg_name}/__init__.py
32+
echo '__version__ = "0.0.0"' >> src/${pkg_name}/__init__.py
33+
sed -i "s/aind_library_template/${pkg_name}/" pyproject.toml
34+
sed -i "s/aind-library-template/${REPO_NAME}/" pyproject.toml
35+
sed -i "s/aind-library-template/${REPO_NAME}/" CITATION.cff
36+
sed -i "s/^version:.*/version: \"v0.0.0\"/" CITATION.cff
37+
sed -i "s/^date-released:.*/date-release: $current_date/" CITATION.cff
38+
sed -i "s/aind_library_template/${pkg_name}/" docs/source/conf.py
39+
sed -i "s/${current_description}/${new_description}/" pyproject.toml
40+
sed -i "/pandas/d" pyproject.toml
41+
sed -i "s/aind-library-template/${REPO_NAME}/" README.md
42+
sed -i "s/${readme_description}/${new_readme_description}/" README.md
43+
- name: Commit changes
44+
uses: EndBug/add-and-commit@v9
45+
with:
46+
default_author: github_actions
47+
message: "ci: version bump [skip actions]"
48+
add: '["pyproject.toml", "README.md", "CITATION.cff", "src/*", "docs/source/conf.py"]'
49+
remove: '["-r src/aind_library_template", "tests/test_message_handler.py"]'
50+
- name: Add first tag
51+
run: |
52+
git tag v0.0.0
53+
git push origin v0.0.0
54+
- name: Disable workflow
55+
run: |
56+
gh workflow disable -R $GITHUB_REPOSITORY "${{ github.workflow }}"
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 65 to enable automated semantic version bumps.
7+
# Change line 71 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@v4
15+
with:
16+
ref: ${{ env.DEFAULT_BRANCH }}
17+
fetch-depth: 0
18+
token: ${{ secrets.SERVICE_TOKEN }}
19+
- name: Set up Python 3.10
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.10'
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install -e . --group 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 '^\!\[Python\]' README.md | sed -n 's/.*\(python-[^)]*\).*/\1/p')
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 '^\!\[Interrogate\]' README.md | sed -n 's/.*\(interrogate-[^)]*\).*/\1/p')
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 '^\!\[Coverage\]' README.md | sed -n 's/.*\(coverage-[^)]*\).*/\1/p')
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@v4
75+
- name: Pull latest changes
76+
run: git pull origin main
77+
- name: Set up Python 3.10
78+
uses: actions/setup-python@v5
79+
with:
80+
python-version: '3.10'
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 }}
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.10', '3.11', '3.12' ]
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install -e . --group dev --no-cache-dir
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)