Fix Ruff (#645) #260
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: Test | |
on: | |
push: | |
branches: ["*"] | |
pull_request: | |
branches: [main] | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
task: | |
type: choice | |
options: [tests, release] | |
default: tests | |
description: Only run tests or release a new version to PyPI after tests pass. | |
jobs: | |
test: | |
strategy: | |
max-parallel: 20 | |
matrix: | |
config: | |
- os: ubuntu-latest | |
python: "3.12" | |
- os: macos-latest | |
python: "3.10" | |
runs-on: ${{ matrix.config.os }} | |
env: | |
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: "python" | |
PMG_MAPI_KEY: ${{ secrets.PMG_MAPI_KEY }} | |
DGLBACKEND: "pytorch" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
enable-cache: true | |
cache-dependency-glob: "uv.lock" | |
python-version: ${{ matrix.config.python }} | |
- name: Virtual env | |
run: uv venv --python ${{ matrix.config.python }} | |
- name: Install latest DGL for Linux | |
if: matrix.config.os == 'ubuntu-latest' | |
run: uv pip install dgl==2.4.0 -f https://data.dgl.ai/wheels/torch-2.4/repo.html | |
- name: Install dependencies | |
run: | | |
uv pip install -e . | |
uv pip install pytest pytest-cov | |
- name: pytest | |
run: | | |
uv run python -c "import dgl; print(dgl.__version__)" | |
uv run python -c "import torch; print(torch.__version__)" | |
uv run pytest --cov=matgl tests --color=yes | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v4 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
release: | |
if: github.event_name == 'release' || inputs.task == 'release' | |
needs: test | |
runs-on: ubuntu-latest | |
permissions: | |
# For pypi trusted publishing | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install latest DGL | |
if: matrix.config.os == 'ubuntu-latest' | |
run: | | |
pip install dgl -f https://data.dgl.ai/wheels/torch-2.4/repo.html | |
- name: Build | |
run: | | |
pip install build | |
python -m build | |
- name: Publish to PyPi | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
skip-existing: true | |
verbose: true |