simplify and update doc environment (#372) #809
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: mesmer CI-CD | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
linting: | |
runs-on: "ubuntu-latest" | |
strategy: | |
matrix: | |
python-version: ["3.10"] | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Create conda environment | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-name: mesmer-linting | |
environment-file: environment.yml | |
create-args: >- | |
python=${{ matrix.python-version }} | |
- name: Install mesmer | |
run: | | |
python -m pip install --no-deps -e . | |
- name: Conda info | |
run: | | |
conda info -a | |
conda list | |
- name: Import mesmer | |
run: | | |
python -c "import mesmer" | |
- name: isort | |
run: isort --check mesmer examples tests setup.py | |
- name: black | |
if: always() | |
run: black --check mesmer examples tests setup.py docs/source/conf.py | |
- name: flake8 | |
if: always() | |
run: flake8 mesmer examples tests setup.py | |
test: | |
name: py${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: ["ubuntu-latest"] | |
python-version: ["3.9", "3.11", "3.12"] | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set environment variables | |
run: | | |
echo "CONDA_ENV_FILE=environment.yml" >> $GITHUB_ENV | |
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV | |
- name: Create conda environment | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-name: mesmer-tests | |
cache-downloads: true | |
cache-downloads-key: "${{runner.os}}-${{runner.arch}}-py${{matrix.python-version}}" | |
micromamba-version: 'latest' | |
environment-file: ${{ env.CONDA_ENV_FILE }} | |
create-args: >- | |
python=${{ matrix.python-version }} | |
- name: Install mesmer | |
run: | | |
python -m pip install --no-deps -e . | |
- name: Conda info | |
run: | | |
conda info -a | |
- name: Conda list | |
run: conda list | |
- name: Test installation | |
run: python scripts/test_install.py | |
- name: Run tests | |
run: python -u -m pytest | |
-r a -v | |
--all | |
--cov=mesmer | |
--cov-report=xml | |
- name: Upload code coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ./coverage.xml | |
flags: unittests | |
env_vars: RUNNER_OS,PYTHON_VERSION | |
name: codecov-umbrella | |
fail_ci_if_error: false | |
deploy-pypi: | |
needs: [linting,test] | |
if: | | |
startsWith(github.ref, 'refs/tags/v') | |
&& (github.ref == 'refs/heads/main') | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.9] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip wheel twine | |
- name: Create package | |
run: python setup.py sdist bdist_wheel --universal | |
- name: Publish package to PyPI | |
uses: pypa/gh-action-pypi-publish@master | |
with: | |
user: __token__ | |
password: ${{ secrets.pypi_password }} |