Added a tab to switch between bash and zsh shell instructions #420
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: | |
| workflow_dispatch: # Manually trigger a workflow run using the GitHub API, GitHub CLI, or the GitHub UI. | |
| push: | |
| pull_request: | |
| permissions: | |
| contents: read # required for code coverage | |
| jobs: | |
| Validate-CITATION-cff: | |
| runs-on: ubuntu-latest | |
| name: Validate CITATION.cff | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v5 | |
| - name: Validate CITATION.cff | |
| id: validate_cff | |
| uses: dieghernan/cff-validator@v4 | |
| with: | |
| citation-path: "CITATION.cff" | |
| - name: Upload cff-validator error artifact if failed to validate | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ failure() && steps.validate_cff.conclusion == 'failure' }} | |
| with: | |
| name: citation-cff-errors | |
| path: citation_cff.md | |
| overwrite: true | |
| if-no-files-found: warn | |
| download-test-model: | |
| name: download-test-model | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python 3.13 | |
| uses: actions/setup-python@v6 | |
| id: python-setup | |
| with: | |
| python-version: 3.13 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| id: setup-uv | |
| with: | |
| # Install a specific version of uv. | |
| version: "0.9.15" | |
| enable-cache: true | |
| restore-cache: true | |
| save-cache: true | |
| prune-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Install the project | |
| run: uv sync --locked --all-extras | |
| - name: check uv cache is working | |
| if: steps.setup-uv.outputs.cache-hit == 'true' | |
| run: echo "uv cache was restored" | |
| - name: Check HF model cache | |
| uses: actions/cache/restore@v4 | |
| id: cache | |
| with: | |
| path: ~/hf_test_model_cache | |
| key: ucrelnlp-pymusas-neural-english-small-bem-${{ runner.os }} | |
| - name: Download HuggingFace WSD Test Model | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| run: uv run tests/model_download.py $HOME/hf_test_model_cache | |
| - name: Saving HuggingFace WSD Test Model | |
| uses: actions/cache/save@v4 | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| with: | |
| path: ~/hf_test_model_cache | |
| key: ucrelnlp-pymusas-neural-english-small-bem-${{ runner.os }} | |
| checks: | |
| name: checks | |
| runs-on: ${{ matrix.os }} | |
| needs: | |
| - download-test-model | |
| strategy: | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| id: python-setup | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| id: setup-uv | |
| with: | |
| # Install a specific version of uv. | |
| version: "0.9.15" | |
| enable-cache: true | |
| restore-cache: true | |
| save-cache: true | |
| prune-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Install the project | |
| run: uv sync --locked --all-extras | |
| - name: check uv cache is working | |
| if: steps.setup-uv.outputs.cache-hit == 'true' | |
| run: echo "uv cache was restored" | |
| - name: isort | |
| run: uv run isort --check-only pymusas tests scripts benchmarks | |
| - name: flake8 Ubuntu and Mac | |
| if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }} | |
| run: | | |
| uv run flake8 --config ./.flake8 pymusas tests scripts benchmarks | |
| - name: flake8 Window | |
| if: ${{ runner.os == 'Windows' }} | |
| run: | | |
| uv run flake8 --config .\.flake8 pymusas tests scripts benchmarks | |
| - name: Cache mypy | |
| uses: actions/cache@v4 | |
| with: | |
| path: ./.mypy_cache | |
| key: ${{ runner.os }}-${{ steps.python-setup.outputs.python-version }}-${{ hashFiles('uv.lock') }} | |
| - name: mypy | |
| run: uv run mypy | |
| - name: Windows create HuggingFace Hub cache directory | |
| if: ${{ runner.os == 'Windows' }} | |
| run: | | |
| mkdir "$HOME\.cache" | |
| mkdir "$HOME\.cache\huggingface" | |
| mkdir "$HOME\.cache\huggingface\hub" | |
| echo "HF_HOME=$HOME\.cache\huggingface" >> $env:GITHUB_ENV | |
| - name: Linux create HuggingFace Hub cache directory | |
| if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }} | |
| run: | | |
| mkdir -p $HOME/.cache/huggingface/hub | |
| echo "HF_HOME=$HOME/.cache/huggingface" >> "$GITHUB_ENV" | |
| - name: Get HF model cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: ~/hf_test_model_cache | |
| key: ucrelnlp-pymusas-neural-english-small-bem-${{ runner.os }} | |
| lookup-only: false | |
| - name: Move cached files | |
| run: mv $HOME/hf_test_model_cache/* $HOME/.cache/huggingface/hub/. | |
| - name: Set pymusas cache home directory for Ubuntu and Mac | |
| if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }} | |
| run: | | |
| echo "PYMUSAS_HOME=$HOME/.cache/doc_test_pymusas" >> "$GITHUB_ENV" | |
| - name: Set pymusas cache home directory for Windows | |
| if: ${{ runner.os == 'Windows' }} | |
| run: | | |
| echo "PYMUSAS_HOME=$HOME\.cache\doc_test_pymusas" >> $env:GITHUB_ENV | |
| - name: Cache Doc Test download files | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.PYMUSAS_HOME }} | |
| key: ${{ runner.os }}-${{ steps.python-setup.outputs.python-version }}-${{ env.PYMUSAS_HOME }} | |
| - name: Code coverage unit testing | |
| run: | | |
| uv run coverage run --append | |
| - name: Code coverage doc testing | |
| run: | | |
| uv run coverage run --append -m pytest --doctest-modules pymusas/ | |
| - name: Build and Code Coverage Functional Tests Ubuntu and Mac | |
| if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }} | |
| run: | | |
| uv run scripts/create_temporary_version.py ./pyproject.toml ./temp_pyproject.toml | |
| uv build | |
| PYMUSAS_VERSION=$(uv run scripts/get_version.py ./pyproject.toml) | |
| uv run --with "dist/pymusas-${PYMUSAS_VERSION}-py3-none-any.whl" \ | |
| --with "pytest<9.0.2" --with "coverage>=6.0.0" --no-project --isolated \ | |
| coverage run --append -m pytest tests/functional_tests | |
| uv run --with "dist/pymusas-${PYMUSAS_VERSION}-py3-none-any.whl[neural]" \ | |
| --with "pytest<9.0.2" --with "coverage>=6.0.0" --no-project --isolated \ | |
| coverage run --append -m pytest tests/functional_tests | |
| uv run --with "dist/pymusas-${PYMUSAS_VERSION}-py3-none-any.whl[neural]" \ | |
| --with "pytest<9.0.2" --with "coverage>=6.0.0" --no-project --isolated \ | |
| coverage run --append -m pytest --doctest-modules pymusas/ | |
| mv ./temp_pyproject.toml ./pyproject.toml | |
| - name: Build and Code Coverage Functional Tests Windows | |
| if: ${{ runner.os == 'Windows' }} | |
| run: | | |
| uv run scripts/create_temporary_version.py ./pyproject.toml ./temp_pyproject.toml | |
| uv build | |
| $PYMUSAS_VERSION = & { uv run scripts/get_version.py ./pyproject.toml } | |
| uv run --with "dist/pymusas-${PYMUSAS_VERSION}-py3-none-any.whl" --with "pytest<9.0.2" --with "coverage>=6.0.0" --no-project --isolated coverage run --append -m pytest tests/functional_tests | |
| uv run --with "dist/pymusas-${PYMUSAS_VERSION}-py3-none-any.whl[neural]" --with "pytest<9.0.2" --with "coverage>=6.0.0" --no-project --isolated coverage run --append -m pytest tests/functional_tests | |
| uv run --with "dist/pymusas-${PYMUSAS_VERSION}-py3-none-any.whl[neural]" --with "pytest<9.0.2" --with "coverage>=6.0.0" --no-project --isolated coverage run --append -m pytest --doctest-modules pymusas/ | |
| rm ./pyproject.toml | |
| mv ./temp_pyproject.toml ./pyproject.toml | |
| - name: Code coverage report | |
| run: | | |
| uv run coverage report | |
| update-binder-requirements: | |
| name: update-binder-requirements | |
| permissions: | |
| contents: write # Reqired to write to the binder-main branch | |
| needs: checks | |
| if: github.ref == 'refs/heads/main' && github.repository == 'UCREL/pymusas' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: update env checkout | |
| uses: actions/checkout@v5 | |
| - name: update env commits | |
| run: | | |
| git branch | |
| git fetch --depth=1 origin binder-main | |
| git checkout -b binder-main origin/binder-main | |
| git checkout main binder/environment.yml | |
| git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git config --global user.name "github-actions[bot]" | |
| if [ $(git diff-index binder-main | wc -l) -gt 0 ]; then git commit -m "update"; git push origin binder-main; fi | |