Fixed error in getting annotations when resources list is empty #416
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: Automated Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main, fix/*, hotfix/*, release/*, develop] | |
| # Security: Add minimal permissions | |
| permissions: | |
| contents: read | |
| actions: write # required for actions/upload-artifact | |
| env: | |
| PYTORCH_VERSION: ">=2.0" | |
| TORCHVISION_VERSION: ">=0.15" | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| # Fail fast to save CI resources | |
| fail-fast: true | |
| matrix: | |
| os: ${{ github.event_name == 'pull_request' && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest", "macos-latest", "windows-latest"]') }} | |
| python-version: ${{ github.event_name == 'pull_request' && fromJSON('["3.10"]') || fromJSON('["3.10", "3.12"]') }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| # Fetch more history for better caching | |
| fetch-depth: 2 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: "pip" | |
| cache-dependency-path: | | |
| **/pyproject.toml | |
| **/requirements*.txt | |
| **/setup.py | |
| # Improved caching strategy | |
| - name: Cache dependencies and PyTorch | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/pip | |
| ~/.cache/torch | |
| key: deps-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml', '**/requirements*.txt', '**/setup.py') }}-pytorch-${{ env.PYTORCH_VERSION }} | |
| restore-keys: | | |
| deps-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml', '**/requirements*.txt', '**/setup.py') }}- | |
| deps-${{ runner.os }}-py${{ matrix.python-version }}- | |
| - name: Install dependencies | |
| # Install PyTorch CPU version for faster installation and testing | |
| run: | | |
| python -m pip install --upgrade pip wheel setuptools | |
| pip install "torch${{ env.PYTORCH_VERSION }}" "torchvision${{ env.TORCHVISION_VERSION }}" --index-url https://download.pytorch.org/whl/cpu | |
| pip install .[dev] | |
| timeout-minutes: 10 | |
| env: | |
| PYTHONIOENCODING: utf-8 | |
| - name: Run tests with pytest | |
| run: | | |
| pytest tests --junitxml=junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}.xml --cov=datamint --cov-report=html --tb=short -v | |
| timeout-minutes: 45 | |
| env: | |
| PYTHONIOENCODING: utf-8 | |
| - name: Test datamint-config CLI | |
| run: datamint-config --api-key testapikey | |
| timeout-minutes: 1 | |
| env: | |
| PYTHONIOENCODING: utf-8 | |
| - name: Upload pytest test results | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }} | |
| path: junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}.xml | |
| retention-days: 30 | |
| - name: Upload coverage report | |
| if: always() && matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: htmlcov/ | |
| retention-days: 30 |