diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7d909e8..5bb45c0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,44 +3,42 @@ name: build on: release: types: - - published + - released + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +defaults: + run: + shell: bash -leo pipefail {0} jobs: build: name: build package runs-on: ubuntu-latest steps: - - uses: actions/checkout@main - - uses: actions/setup-python@main - with: - python-version: '3.x' - - uses: actions/cache@main - with: - path: ${{ env.pythonLocation }} - key: build-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'setup.*') }} - - run: pip wheel . --no-deps -w dist - - uses: actions/upload-artifact@main - with: - name: package - path: dist/ - publish: - name: publish package - needs: [ build ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@main - - uses: actions/setup-python@main - with: - python-version: '3.x' - - uses: actions/cache@main + - uses: mamba-org/setup-micromamba@v1 with: - path: ${{ env.pythonLocation }} - key: build-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'setup.*') }} - - uses: actions/download-artifact@main + condarc: | + channels: + - conda-forge + environment-name: build + create-args: >- + build + cache-downloads: true + cache-environment: true + init-shell: >- + bash + - uses: actions/checkout@v4 + - run: python -m build + - uses: actions/upload-artifact@v4 with: - name: package + name: stormevents path: dist/ - - uses: pypa/gh-action-pypi-publish@master + - if: github.event_name == 'release' && github.event.action == 'released' + uses: pypa/gh-action-pypi-publish@v1.8.11 with: user: __token__ password: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index be81fd4..73949af 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,28 +14,33 @@ on: - '.github/workflows/test*.yml' - 'pyproject.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +defaults: + run: + shell: bash -leo pipefail {0} + jobs: style: - name: check code style runs-on: ubuntu-latest steps: - - uses: actions/checkout@main - - uses: actions/setup-python@main - with: - python-version: '3.x' - - uses: actions/cache@main - id: cache + - uses: mamba-org/setup-micromamba@v1 with: - path: ${{ env.pythonLocation }} - key: style-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'setup.*') }} - - run: pip install flake8 black - # stop the build if there are Python syntax errors or undefined names - - run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - - run: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - run: black . --check + condarc: | + channels: + - conda-forge + environment-name: style + create-args: >- + ruff + cache-downloads: true + cache-environment: true + init-shell: >- + bash + - uses: actions/checkout@v4 + - run: ruff check . test: - needs: [ style ] name: test Python ${{ matrix.python }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: @@ -43,35 +48,44 @@ jobs: os: [ ubuntu-latest, macos-latest ] python: [ '3.9', '3.10' ] steps: - - uses: actions/checkout@main - - uses: actions/setup-python@main + - uses: mamba-org/setup-micromamba@v1 with: - python-version: ${{ matrix.python }} - - uses: actions/cache@main - id: cache - with: - path: ${{ env.pythonLocation }} - key: test-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'setup.*') }} - - run: pip install ".[test]" pytest-xdist - - run: pytest -n auto + condarc: | + channels: + - conda-forge + environment-name: test + create-args: >- + python=${{ matrix.python }} + pytest-xdist + cache-downloads: true + cache-environment: true + init-shell: >- + bash + - uses: actions/checkout@v4 + - run: pip install ".[test]" + - run: pytest -n auto --verbose test_with_coverage: - needs: [ style, test ] name: test with code coverage runs-on: ubuntu-latest steps: - - uses: actions/checkout@main - - uses: actions/setup-python@main - with: - python-version: '3.x' - - uses: actions/cache@main - id: cache + - uses: mamba-org/setup-micromamba@v1 with: - path: ${{ env.pythonLocation }} - key: test-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'setup.*') }} - - run: pip install ".[test]" pytest-cov pytest-xdist - - run: pytest --cov . --cov-report xml:coverage.xml - - run: coverage report -m - - uses: codecov/codecov-action@main + condarc: | + channels: + - conda-forge + environment-name: coverage + create-args: >- + python=${{ matrix.python }} + pytest-xdist + pytest-cov + cache-downloads: true + cache-environment: true + init-shell: >- + bash + - uses: actions/checkout@v4 + - run: pip install ".[test]" + - run: pytest --cov . --cov-report xml:coverage.xml --cov-report term-missing -n auto --verbose + - uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml diff --git a/.github/workflows/test_quick.yml b/.github/workflows/test_quick.yml deleted file mode 100644 index c514370..0000000 --- a/.github/workflows/test_quick.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: quick test - -on: - push: - branches-ignore: - - 'main' - paths: - - '**.py' - - '.github/workflows/test*.yml' - - 'pyproject.toml' - -jobs: - style: - name: check code style - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@main - - uses: actions/setup-python@main - with: - python-version: '3.x' - - uses: actions/cache@main - id: cache - with: - path: ${{ env.pythonLocation }} - key: style-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'setup.*') }} - - run: pip install flake8 black - # stop the build if there are Python syntax errors or undefined names - - run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - - run: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - run: black . --check - test: - needs: [ style ] - name: test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@main - - uses: actions/setup-python@main - with: - python-version: '3.x' - - uses: actions/cache@main - id: cache - with: - path: ${{ env.pythonLocation }} - key: test-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'setup.*') }} - - run: pip install ".[test]" pytest-xdist - - run: pytest -n auto diff --git a/pyproject.toml b/pyproject.toml index ee3afe2..8a08f89 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,8 +25,7 @@ dependencies = [ dynamic = ["version"] [project.optional-dependencies] -test = ['pytest', 'pytest-cov', 'pytest-socket', 'pytest-xdist'] -style = ['black', 'reorder-python-imports'] +test = ['pytest', 'pytest-socket'] docs = ['dunamai', 'm2r2', 'sphinx<7', 'sphinx-rtd-theme', 'toml'] [project.urls]