CI #2463
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: CI | |
| on: | |
| # GitHub has started calling new repo's first branch "main" https://github.com/github/renaming | |
| # The cookiecutter uses the "--initial-branch" flag when it runs git-init | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - "main" | |
| pull_request: | |
| branches: | |
| - "main" | |
| schedule: | |
| # Weekly tests run on main by default: | |
| # Scheduled workflows run on the latest commit on the default or base branch. | |
| # (from https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule) | |
| - cron: "0 0 * * 0" | |
| concurrency: | |
| group: "${{ github.workflow }}-${{ github.ref }}" | |
| cancel-in-progress: true | |
| defaults: | |
| run: | |
| shell: bash -l {0} | |
| jobs: | |
| test: | |
| name: Test on ${{ matrix.os }}, Python ${{ matrix.python-version }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| include: | |
| - os: ubuntu-latest | |
| n_procs: auto | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Additional info about the build | |
| run: | | |
| uname -a | |
| df -h | |
| ulimit -a | |
| # More info on options: https://github.com/marketplace/actions/provision-with-micromamba | |
| - uses: mamba-org/setup-micromamba@v1 | |
| with: | |
| environment-file: devtools/conda-envs/test_env.yaml | |
| cache-environment: true | |
| cache-downloads: true | |
| create-args: >- | |
| python=${{ matrix.python-version }} | |
| if : matrix.os == 'ubuntu-latest' | |
| - uses: mamba-org/setup-micromamba@v1 | |
| with: | |
| environment-file: devtools/conda-envs/test_env_mac.yaml | |
| cache-environment: true | |
| cache-downloads: true | |
| create-args: >- | |
| python=${{ matrix.python-version }} | |
| if: matrix.os != 'ubuntu-latest' | |
| - name: Install package | |
| # conda setup requires this special shell | |
| run: | | |
| python -m pip install . --no-deps | |
| python -m pip install -e ./modelforge-curate --no-deps | |
| micromamba list | |
| # this will figure out what datasets we will use in our tests | |
| # and save them to a file so we can hash this file to see if the cache needs updating | |
| # this will save "downloaded_datasets.txt" in the modelforge testing cache folder | |
| - name: Identify test systems | |
| run: | | |
| echo "figuring out what test datasets are needed" | |
| python modelforge/tests/list_test_datasets.py | |
| - name: Cache Test Dataset | |
| id: cache-dataset | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/modelforge_testing_dataset_cache | |
| # include the hash of the downloaded_datasets.txt to ensure if that changes we update the cache | |
| key: modelforge-dataset-cache--${{ hashFiles('$HOME/.cache/modelforge_testing_dataset_cache/downloaded_datasets.txt') }} | |
| restore-keys: modelforge-dataset-cache | |
| # since the underlying code itself will not redownload if files are present | |
| # I think regardless of the state we should just run the script | |
| # that may be the best way to ensure if we change the training datasets new will be generated | |
| # since these are determined from accessing data in a few different spots | |
| - name: Load datasets from cache | |
| if: steps.cache-dataset.outputs.cache-hit == 'true' | |
| run: | | |
| echo "using previously cached test datasets" | |
| python modelforge/tests/fetch_test_datasets.py | |
| - name: Download datasets to cache | |
| if: steps.cache-dataset.outputs.cache-hit != 'true' | |
| run: | | |
| echo "downloading test datasets" | |
| python modelforge/tests/fetch_test_datasets.py | |
| - name: Run tests | |
| # conda setup requires this special shell | |
| run: | | |
| pytest -n 4 --dist loadgroup -v --cov=modelforge --cov-report=xml --color=yes --durations=50 modelforge/tests/ | |
| # pytest -n ${{matrix.n_procs}} --dist loadgroup -v --cov=modelforge --cov-report=xml --color=yes --durations=50 modelforge/tests/ | |
| - name: CodeCov | |
| uses: codecov/codecov-action@v4 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| if: ${{ github.event != 'schedule' }} # Don't upload results on scheduled runs | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| file: ./coverage.xml | |
| flags: unittests | |
| name: codecov-${{ matrix.os }}-py${{ matrix.python-version }} |