Skip to content

Commit 4a9be43

Browse files
Initial commit
0 parents  commit 4a9be43

30 files changed

Lines changed: 2727 additions & 0 deletions

.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: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
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/${REPO_NAME}/" CITATION.cff
35+
sed -i "s/^version:.*/version: \"v0.0.0\"/" CITATION.cff
36+
sed -i "s/^date-released:.*/date-release: $current_date/" CITATION.cff
37+
sed -i "s/aind_library_template/${pkg_name}/" docs/source/conf.py
38+
sed -i "s/aind-library-template/${REPO_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: Set up uv
44+
uses: astral-sh/setup-uv@v7
45+
- name: Reset version and lockfile
46+
run: |
47+
uv version 0.0.0
48+
uv lock
49+
- name: Commit changes
50+
uses: EndBug/add-and-commit@v9
51+
with:
52+
default_author: github_actions
53+
message: "ci: version bump [skip actions]"
54+
add: '["pyproject.toml", "uv.lock", "README.md", "CITATION.cff", "src/*", "docs/source/conf.py"]'
55+
remove: '["-r src/aind_library_template", "tests/test_message_handler.py"]'
56+
- name: Add first tag
57+
run: |
58+
git tag v0.0.0
59+
git push origin v0.0.0
60+
- name: Disable workflow
61+
run: |
62+
gh workflow disable -R $GITHUB_REPOSITORY "${{ github.workflow }}"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Link Issue to Milestone Parent
2+
3+
on:
4+
issues:
5+
types: [milestoned]
6+
7+
jobs:
8+
link-issue:
9+
if: github.event.issue.milestone != null
10+
uses: AllenNeuralDynamics/.github/.github/workflows/util-link-issues-by-milestone.yml@main
11+
with:
12+
issue-number: ${{ github.event.issue.number }}
13+
issue-id: ${{ github.event.issue.id }}
14+
milestone-description: ${{ github.event.issue.milestone.description }}
15+
secrets:
16+
service-token: ${{ secrets.SERVICE_TOKEN }}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Tag and publish
2+
on:
3+
push:
4+
branches:
5+
- main
6+
# Remove line 67 to enable automated semantic version bumps.
7+
# Requires that svc-aindscicomp be added to the repo with "write" role.
8+
9+
# Change line 73 from "if: false" to "if: true" to enable PyPI publishing.
10+
# Requires that the repo has been added as a Trusted Publisher in the PyPI.
11+
# Please submit a request to Scientific Computing to add the Trusted Publisher.
12+
jobs:
13+
update_badges:
14+
runs-on: ubuntu-latest
15+
continue-on-error: true
16+
steps:
17+
- uses: actions/checkout@v6
18+
with:
19+
ref: ${{ env.DEFAULT_BRANCH }}
20+
fetch-depth: 0
21+
token: ${{ secrets.SERVICE_TOKEN }}
22+
- name: Set up Python 3.10
23+
uses: astral-sh/setup-uv@v7
24+
with:
25+
python-version: '3.10'
26+
- name: Install dependencies
27+
run: uv sync
28+
- name: Get Python version and Update README.md
29+
run: |
30+
python_version=$(grep "requires-python" pyproject.toml | grep -o ">=[^\"]*")
31+
python_badge=$(grep '^\!\[Python\]' README.md | sed -n 's/.*\(python-[^)]*\).*/\1/p')
32+
new_python_badge="python-$python_version-blue?logo=python"
33+
sed -i "s/$python_badge/$new_python_badge/g" README.md
34+
- name: Get interrogate values and Update README.md
35+
run: |
36+
interrogate_val=$(uv run interrogate . | grep -o 'actual: [0-9]*\.[0-9]*' | awk '{print $2}')
37+
interrogate_badge=$(grep '^\!\[Interrogate\]' README.md | sed -n 's/.*\(interrogate-[^)]*\).*/\1/p')
38+
if (( $(echo "$interrogate_val >= 90.00" | bc -l) )); then
39+
new_interrogate_badge="interrogate-$interrogate_val%25-brightgreen"
40+
elif (( $(echo "$interrogate_val < 80.00" | bc -l) )); then
41+
new_interrogate_badge="interrogate-$interrogate_val%25-red"
42+
else
43+
new_interrogate_badge="interrogate-$interrogate_val%25-yellow"
44+
fi
45+
sed -i "s/$interrogate_badge/$new_interrogate_badge/g" README.md
46+
- name: Get Coverage values and Update README.md
47+
run: |
48+
uv run coverage run -m unittest discover
49+
coverage_val=$(uv run coverage report | grep "^TOTAL" | grep -o '[0-9]\+%' | grep -o '[0-9]\+')
50+
coverage_badge=$(grep '^\!\[Coverage\]' README.md | sed -n 's/.*\(coverage-[^)]*\).*/\1/p')
51+
if (( $(echo "$coverage_val >= 90.00" | bc -l) )); then
52+
new_coverage_badge="coverage-$coverage_val%25-brightgreen"
53+
elif (( $(echo "$coverage_val < 80.00" | bc -l) )); then
54+
new_coverage_badge="coverage-$coverage_val%25-red"
55+
else
56+
new_coverage_badge="coverage-$coverage_val%25-yellow"
57+
fi
58+
sed -i "s/$coverage_badge/$new_coverage_badge/g" README.md
59+
- name: Commit changes
60+
uses: EndBug/add-and-commit@v9
61+
with:
62+
default_author: github_actions
63+
message: "ci: update badges [skip actions]"
64+
add: '["README.md"]'
65+
tag:
66+
needs: update_badges
67+
if: ${{github.event.repository.name == 'aind-library-template'}}
68+
uses: AllenNeuralDynamics/.github/.github/workflows/release-bump-version-uv.yml@main
69+
secrets:
70+
repo-token: ${{ secrets.SERVICE_TOKEN }}
71+
publish:
72+
needs: tag
73+
if: false
74+
runs-on: ubuntu-latest
75+
permissions:
76+
contents: read
77+
# IMPORTANT: this permission is mandatory for Trusted Publishing
78+
id-token: write
79+
steps:
80+
- uses: actions/checkout@v6
81+
- name: Pull latest changes
82+
run: git pull origin main
83+
- name: Set up Python 3.10
84+
uses: astral-sh/setup-uv@v7
85+
with:
86+
python-version: '3.10'
87+
- name: Build and validate package
88+
run: |
89+
uv build
90+
uvx twine check dist/*
91+
- name: Publish on PyPI
92+
uses: pypa/gh-action-pypi-publish@release/v1
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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@v6
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: astral-sh/setup-uv@v7
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install dependencies
21+
run: uv sync
22+
- name: Run linter checks
23+
run: uv run flake8 . && uv run interrogate --verbose .
24+
- name: Run tests and coverage
25+
run: uv run coverage run -m unittest discover && uv run coverage report

0 commit comments

Comments
 (0)