From cc463e110bdb702f4a00df0968fb729cb01d66eb Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Fri, 2 Feb 2024 09:47:54 -0500 Subject: [PATCH 1/8] update workflow environments --- .github/workflows/build.yml | 42 ++++++----------- .github/workflows/test.yml | 80 ++++++++++++++++++-------------- .github/workflows/test_quick.yml | 47 ------------------- pyproject.toml | 3 +- 4 files changed, 60 insertions(+), 112 deletions(-) delete mode 100644 .github/workflows/test_quick.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7d909e8..c14d379 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,35 +10,23 @@ jobs: name: build package runs-on: ubuntu-latest steps: - - uses: actions/checkout@main - - uses: actions/setup-python@main + - uses: mamba-org/setup-micromamba@v1 with: - python-version: '3.x' - - uses: actions/cache@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: build + - uses: actions/upload-artifact@v4 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 - with: - path: ${{ env.pythonLocation }} - key: build-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'setup.*') }} - - uses: actions/download-artifact@main - with: - name: package + name: stormevents path: dist/ - uses: pypa/gh-action-pypi-publish@master with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index be81fd4..4bad72e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,24 +16,22 @@ on: jobs: style: - name: check code style runs-on: ubuntu-latest steps: - - uses: actions/checkout@main - - uses: actions/setup-python@main + - uses: mamba-org/setup-micromamba@v1 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 + 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 }} @@ -43,35 +41,45 @@ jobs: os: [ ubuntu-latest, macos-latest ] python: [ '3.9', '3.10' ] steps: - - uses: actions/checkout@main - - uses: actions/setup-python@main - with: - python-version: ${{ matrix.python }} - - 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-xdist + 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 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 + - 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] From e39569bac7c0c6ad2a73f0162573b1e5dc96e644 Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Fri, 2 Feb 2024 09:50:42 -0500 Subject: [PATCH 2/8] no dependencies --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4bad72e..f46492d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,6 @@ jobs: - uses: actions/checkout@v4 - run: ruff check . test: - needs: [ style ] name: test Python ${{ matrix.python }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: @@ -58,7 +57,6 @@ jobs: - run: pip install ".[test]" - run: pytest -n auto test_with_coverage: - needs: [ style, test ] name: test with code coverage runs-on: ubuntu-latest steps: From c561e2f776cacf1f847d085726597245cac8bfc4 Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Fri, 2 Feb 2024 09:51:49 -0500 Subject: [PATCH 3/8] concurrency --- .github/workflows/build.yml | 4 ++++ .github/workflows/test.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c14d379..2b76cee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,10 @@ on: types: - published +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: name: build package diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f46492d..3fdff60 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,6 +14,10 @@ on: - '.github/workflows/test*.yml' - 'pyproject.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: style: runs-on: ubuntu-latest From 4ec3f0330b6fe6e8d2f983e172de6ca37697689e Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Fri, 2 Feb 2024 09:53:06 -0500 Subject: [PATCH 4/8] shell --- .github/workflows/build.yml | 4 ++++ .github/workflows/test.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2b76cee..86754b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,10 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +defaults: + run: + shell: bash -leo pipefail {0} + jobs: build: name: build package diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3fdff60..8b8422d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,10 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +defaults: + run: + shell: bash -leo pipefail {0} + jobs: style: runs-on: ubuntu-latest From c432ac3753eef71e9cf6316e6d790bccbbb0db89 Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Fri, 2 Feb 2024 09:55:49 -0500 Subject: [PATCH 5/8] build on pull request --- .github/workflows/build.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 86754b5..662ecce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,8 @@ name: build on: release: types: - - published + - released + pull_request: concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -36,7 +37,8 @@ jobs: with: 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@master with: user: __token__ password: ${{ secrets.PYPI_TOKEN }} From e573fc6871f177369c8f4947320669b0d1260b00 Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Fri, 2 Feb 2024 09:57:36 -0500 Subject: [PATCH 6/8] version --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 662ecce..d0bd2ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,7 +38,7 @@ jobs: name: stormevents path: dist/ - if: github.event_name == 'release' && github.event.action == 'released' - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@v1.8.11 with: user: __token__ password: ${{ secrets.PYPI_TOKEN }} From db256c283f57287de3f04d67126bf2bee27bfc4a Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Fri, 2 Feb 2024 09:59:14 -0500 Subject: [PATCH 7/8] fix build --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d0bd2ef..5bb45c0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ jobs: init-shell: >- bash - uses: actions/checkout@v4 - - run: build + - run: python -m build - uses: actions/upload-artifact@v4 with: name: stormevents From cf439c8bc8499905625b774881ac7c866506713f Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Fri, 2 Feb 2024 10:03:00 -0500 Subject: [PATCH 8/8] verbose pytest --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8b8422d..73949af 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,7 +63,7 @@ jobs: bash - uses: actions/checkout@v4 - run: pip install ".[test]" - - run: pytest -n auto + - run: pytest -n auto --verbose test_with_coverage: name: test with code coverage runs-on: ubuntu-latest @@ -84,7 +84,7 @@ jobs: bash - uses: actions/checkout@v4 - run: pip install ".[test]" - - run: pytest --cov . --cov-report xml:coverage.xml --cov-report term-missing -n auto + - 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 }}