Miscellaneous hardening models #261
This file contains 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: python | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
release: | |
types: | |
- published | |
permissions: | |
contents: read # Required when overriding permissions | |
pull-requests: write # For posting coverage report | |
checks: write | |
# Newer commits should cancel old runs | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
black: | |
name: Formatting Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: psf/black@stable | |
with: | |
options: "--check -v" | |
src: "python/neml2 python/tests" | |
build-test: | |
name: Build and test Python bindings | |
needs: black | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-12] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: jwlawson/actions-setup-cmake@v2 | |
with: | |
cmake-version: "3.28" | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.8" | |
- name: Install Python dependencies | |
run: pip install -r requirements.txt | |
- name: Install PyTorch | |
run: pip install torch==2.2.2 | |
- run: pip install -v . | |
- run: pytest --junitxml=pytest.xml python/tests | |
- name: Publish Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: matrix.os == 'ubuntu-latest' | |
with: | |
files: pytest.xml | |
check_name: Python Binding Test Results (${{ matrix.os }}) | |
- name: Publish Test Results | |
uses: EnricoMi/publish-unit-test-result-action/composite@v2 | |
if: matrix.os == 'macos-12' | |
with: | |
files: pytest.xml | |
check_name: Python Binding Test Results (${{ matrix.os }}) | |
sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build SDist | |
run: pipx run build --sdist | |
- name: Upload SDist | |
uses: actions/upload-artifact@v4 | |
if: github.event_name == 'release' && github.event.action == 'published' | |
with: | |
name: package-sdist | |
path: dist/*.tar.gz | |
PyPI: | |
needs: sdist | |
environment: pypi | |
permissions: | |
id-token: write | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: package-sdist | |
path: dist | |
merge-multiple: true | |
- uses: pypa/gh-action-pypi-publish@release/v1 |