Merge branch 'test' of https://github.com/csi-greifflab/embedairr int… #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Test Branch to TestPyPI (Trusted Publishing) | |
| on: | |
| push: | |
| branches: [ test ] | |
| workflow_dispatch: # Allows manual triggering | |
| jobs: | |
| build-and-publish-test: | |
| runs-on: ubuntu-latest | |
| environment: testpypi # GitHub environment for publishing | |
| permissions: | |
| id-token: write # Required for trusted publishing | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Install build dependencies | |
| run: | | |
| python3 -m pip install --upgrade pip | |
| pip install build | |
| - name: Update version for test branch | |
| run: | | |
| # Get current timestamp for unique version | |
| TIMESTAMP=$(date +%Y%m%d%H%M%S) | |
| # Get current version and package name from __init__.py | |
| CURRENT_VERSION=$(python3 -c "import sys; sys.path.insert(0, 'src'); from pepe import __version__; print(__version__)") | |
| PACKAGE_NAME=$(python3 -c "import sys; sys.path.insert(0, 'src'); from pepe import __package_name__; print(__package_name__)") | |
| MODULE_NAME=$(python3 -c "import sys; sys.path.insert(0, 'src'); from pepe import __module_name__; print(__module_name__)") | |
| # Create test version by replacing -dev with .dev and adding timestamp | |
| TEST_VERSION=$(echo $CURRENT_VERSION | sed "s/-dev/.dev${TIMESTAMP}/") | |
| # Update version in __init__.py | |
| sed -i "s/__version__ = \"$CURRENT_VERSION\"/__version__ = \"$TEST_VERSION\"/" src/pepe/__init__.py | |
| echo "Updated version from $CURRENT_VERSION to $TEST_VERSION" | |
| echo "Package name: $PACKAGE_NAME" | |
| echo "Module name: $MODULE_NAME" | |
| grep "__version__" src/pepe/__init__.py | |
| - name: Build package | |
| run: python3 -m build | |
| - name: Publish to TestPyPI (Trusted Publishing) | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| verbose: true | |
| - name: Output installation command | |
| run: | | |
| # Get package name from __init__.py | |
| PACKAGE_NAME=$(python3 -c "import sys; sys.path.insert(0, 'src'); from pepe import __package_name__; print(__package_name__)") | |
| echo "Package published to TestPyPI!" | |
| echo "To install the test version, run:" | |
| echo "pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple \"$PACKAGE_NAME\"" | |
| - name: Wait for package availability | |
| run: | | |
| echo "Waiting for package to be available on TestPyPI..." | |
| sleep 30 | |
| - name: Test installation and functionality | |
| run: | | |
| # Get package and module names from __init__.py | |
| PACKAGE_NAME=$(python3 -c "import sys; sys.path.insert(0, 'src'); from pepe import __package_name__; print(__package_name__)") | |
| MODULE_NAME=$(python3 -c "import sys; sys.path.insert(0, 'src'); from pepe import __module_name__; print(__module_name__)") | |
| # Create a fresh virtual environment for testing | |
| python3 -m venv test_env | |
| source test_env/bin/activate | |
| # Install the package from TestPyPI | |
| pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple "$PACKAGE_NAME" | |
| # Verify installation | |
| pip list | grep -i pepe | |
| # Test basic import | |
| python3 -c "import $MODULE_NAME; print('Package imported successfully')" | |
| # Run the test script | |
| echo "Running test script..." | |
| chmod +x src/tests/test_run.sh | |
| bash src/tests/test_run.sh | |
| # Check if test output was created | |
| if [ -d "src/tests/test_files/test_output" ]; then | |
| echo "✅ Test completed successfully - output directory created" | |
| ls -la src/tests/test_files/test_output/ | |
| else | |
| echo "❌ Test failed - no output directory found" | |
| exit 1 | |
| fi | |
| # Clean up | |
| deactivate | |
| rm -rf test_env | |
| echo "✅ Package verification completed successfully!" |