Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error detecting version and testing workflow #19

Merged
merged 11 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git_archival.txt export-subst
88 changes: 64 additions & 24 deletions .github/workflows/test_package_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,91 +18,131 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3
- run: pip install --upgrade build twine

- name: Build sdist and wheel
run: python -m build
- run: twine check dist/*
run: |
pip install --upgrade build twine
python -m build
twine check dist/*

- name: Upload sdist and wheel artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

- name: Build git archive
run: mkdir archive && git archive -v -o archive/archive.tgz HEAD

- name: Upload git archive artifact
uses: actions/upload-artifact@v4
with:
name: archive
path: archive/

- name: Download test data
env:
BOX_USERNAME: ${{ secrets.BOX_USERNAME }}
BOX_PASSWORD: ${{ secrets.BOX_PASSWORD }}
run: |
python tests/download_test_data.py
tree tests/test_data

- name: Upload test data artifact
uses: actions/upload-artifact@v4
with:
name: test_data
path: tests/test_data/downloaded

test-package:
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
package: ['wheel', 'sdist', 'archive', 'editable']
steps:
- name: Checkout repo
# Used to access the tests. Only install from source if matrix.package == 'editable'.
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download sdist and wheel artifacts
if: matrix.package != 'archive'
if: matrix.package == 'wheel' || matrix.package == 'sdist'
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Download git archive artifact
if: matrix.package == 'archive'
uses: actions/download-artifact@v4
with:
name: archive
path: archive/
- name: Checkout repo
if: matrix.package == 'editable'
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Update pip
run: pip install --upgrade pip

- name: Install wheel
if: matrix.package == 'wheel'
run: pip install dist/*.whl

- name: Install sdist
if: matrix.package == 'sdist'
run: pip install dist/*.tar.gz

- name: Install archive
if: matrix.package == 'archive'
run: pip install archive/archive.tgz

- name: Install editable
if: matrix.package == 'editable'
run: pip install -e .
- name: Install test extras
run: pip install .[test]
- name: Download test data
env:
BOX_USERNAME: ${{ secrets.BOX_USERNAME }}
BOX_PASSWORD: ${{ secrets.BOX_PASSWORD }}
run: |
python tests/download_test_data.py
tree tests/test_data

- name: Download test data artifact
uses: actions/download-artifact@v4
with:
name: test_data
path: tests/test_data/downloaded

- name: Run tests without coverage
if: matrix.package != 'editable'
run: pytest -v jdb_to_nwb
run: |
pip install pytest
pip list
pytest -v

- name: Run tests on editable install with coverage
if: matrix.package == 'editable'
run: pytest --cov=src --cov-report=xml -v jdb_to_nwb
run: |
pip install pytest-cov
pip list
pytest --cov=src --cov-report=xml --cov-report=term -v

- name: Upload coverage reports to Codecov
if: matrix.package == 'editable'
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# pypi-publish:
# name: Upload release to PyPI
# runs-on: ubuntu-latest
Expand All @@ -119,4 +159,4 @@ jobs:
# name: dist
# path: dist/
# - name: Publish package distributions to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# uses: pypa/gh-action-pypi-publish@release/v1
1 change: 1 addition & 0 deletions src/jdb_to_nwb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._version import __version__
18 changes: 10 additions & 8 deletions tests/download_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ def main():
# Create test data directory if it doesn't exist
test_data_dir.mkdir(parents=True, exist_ok=True)

# Read .env file and parse variables into environment variables
with open('.env', 'r') as f:
for line in f:
# Skip empty lines and comments
if line.strip() and not line.startswith('#'):
key, value = line.strip().split('=', 1)
os.environ[key] = value
# Read .env file if present and parse variables into environment variables
env_file_path = ".env"
if os.path.exists(env_file_path):
with open(env_file_path, 'r') as f:
for line in f:
# Skip empty lines and comments
if line.strip() and not line.startswith('#'):
key, value = line.strip().split('=', 1)
os.environ[key] = value

# Get Box credentials
box_username = os.environ.get('BOX_USERNAME')
Expand Down Expand Up @@ -95,4 +97,4 @@ def download_recursively(ftps: FTP_TLS, remote_dir: str, local_dir: Path):
ftps.quit()

if __name__ == "__main__":
main()
main()
Loading