From 3e5eb9c7b98f514c91f4f45ff9ae84dc61941c5b Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Mon, 26 Aug 2024 13:12:58 -0600 Subject: [PATCH 1/6] Drop analysis helper - No longer needed The scripts folder was moved to the SnowExDB repository and was the only user of this helper. --- snowexsql/analysis.py | 27 --------------------------- tests/test_analysis.py | 15 --------------- 2 files changed, 42 deletions(-) delete mode 100644 snowexsql/analysis.py delete mode 100644 tests/test_analysis.py diff --git a/snowexsql/analysis.py b/snowexsql/analysis.py deleted file mode 100644 index a9e5f67..0000000 --- a/snowexsql/analysis.py +++ /dev/null @@ -1,27 +0,0 @@ -import numpy as np - - -def get_stats(data, logger=None): - """ - Calculate and report the typical stats on an numpy array. - - Args: - data: Numpy array or Pandas Dataframe - logger: Use a logger to report stats - Return: - result: Dictionary containing statistics - """ - - results = {} - - for stat in ['mean', 'min', 'max', 'std']: - fn = getattr(np, 'nan' + stat) - results[stat] = fn(data) - msg = '\t{} = {}'.format(stat, results[stat]) - - if logger is not None: - logger.info(msg) - else: - print(msg) - - return results diff --git a/tests/test_analysis.py b/tests/test_analysis.py deleted file mode 100644 index d6ca0c1..0000000 --- a/tests/test_analysis.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from snowexsql.analysis import * - - -def test_get_stats(): - """ - Tests the get stats function - """ - arr = np.array([[1,2],[1,2]]) - received = get_stats(arr) - expected = {'mean':1.5, 'std': 0.5, 'min': 1, 'max':2} - - for s,v in expected.items(): - assert v == expected[s] From 42b7dc91a777dd483c8ce3e94c8446253451e5c1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 17:47:09 +0000 Subject: [PATCH 2/6] Bump the actions group across 1 directory with 4 updates Bumps the actions group with 4 updates in the / directory: [actions/checkout](https://github.com/actions/checkout), [actions/setup-python](https://github.com/actions/setup-python), [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) and [schneegans/dynamic-badges-action](https://github.com/schneegans/dynamic-badges-action). Updates `actions/checkout` from 2 to 4 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v4) Updates `actions/setup-python` from 2 to 5 - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v2...v5) Updates `pypa/gh-action-pypi-publish` from 1.9.0 to 1.10.1 - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.9.0...v1.10.1) Updates `schneegans/dynamic-badges-action` from 1.0.0 to 1.7.0 - [Release notes](https://github.com/schneegans/dynamic-badges-action/releases) - [Changelog](https://github.com/Schneegans/dynamic-badges-action/blob/master/changelog.md) - [Commits](https://github.com/schneegans/dynamic-badges-action/compare/v1.0.0...v1.7.0) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions - dependency-name: schneegans/dynamic-badges-action dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions ... Signed-off-by: dependabot[bot] --- .github/workflows/cd.yml | 6 +++--- .github/workflows/main.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 3b14efa..a86735b 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -36,7 +36,7 @@ jobs: permissions: id-token: write steps: - - uses: actions/setup-python@v5.1.1 + - uses: actions/setup-python@v5 name: Install Python with: python-version: "3.10" @@ -49,7 +49,7 @@ jobs: ls -ltrh ls -ltrh dist - name: Publish to Test PyPI - uses: pypa/gh-action-pypi-publish@v1.9.0 + uses: pypa/gh-action-pypi-publish@v1.10.1 with: repository-url: https://test.pypi.org/legacy/ verbose: true @@ -98,5 +98,5 @@ jobs: name: artifact path: dist - - uses: pypa/gh-action-pypi-publish@v1.9.0 + - uses: pypa/gh-action-pypi-publish@v1.10.1 if: startsWith(github.ref, 'refs/tags') diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 668c11b..cb47a71 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,9 +36,9 @@ jobs: - /home/runner/work/:/home/runner/work/ steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -79,7 +79,7 @@ jobs: - if: ${{ matrix.python-version == '3.9'}} name: Create the Badge - uses: schneegans/dynamic-badges-action@v1.0.0 + uses: schneegans/dynamic-badges-action@v1.7.0 with: auth: ${{ secrets.GIST_SECRET }} gistID: 2034019acc40a963bd02d2fcbb31c5a9 From 6b37e731eeab1cdf513a2e3f6f01addb53e357f9 Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Thu, 12 Sep 2024 14:26:20 -0600 Subject: [PATCH 3/6] Actions - Switch to use CodeCov to check test coverage Change the workflow to get test coverage and use the CodeCov service. This also separates the step into a dedicated CI action and independent of the Python 3.9 test runs. Upgrading the pytest and pytest-cov package to always use the latest. --- .github/workflows/ci.yaml | 43 ++++++++++++++++++++++++++++++++++++++ .github/workflows/main.yml | 39 +--------------------------------- pyproject.toml | 6 ++---- 3 files changed, 46 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..b625146 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,43 @@ +name: Code Quality +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] +jobs: + run: + runs-on: ubuntu-latest + services: + postgis: + image: kartoza/postgis:14-3.2 + env: + POSTGRES_PASSWORD: db_builder + POSTGRES_USER: builder + POSTGRES_DB: test + TZ: 'UTC' + PGTZ: 'UTC' + POSTGIS_GDAL_ENABLED_DRIVERS: 'ENABLE_ALL' + POSTGIS_ENABLE_OUTDB_RASTERS: 'True' + ports: + - 5432:5432 + volumes: + - /home/runner/work/:/home/runner/work/ + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install dependencies + run: python3 -m pip install -e ".[dev]" + - name: Run tests and collect coverage + run: pytest --cov snowexsql --cov-report=xml + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + verbose: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 668c11b..0348201 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,5 @@ -name: snowexsql testing +name: Pytest # Controls when the action will run. on: @@ -46,44 +46,7 @@ jobs: sudo apt-get update sudo apt-get install -y postgis gdal-bin python3 -m pip install --upgrade pip - python3 -m pip install pytest coverage python3 -m pip install -e ".[dev]" - name: Test with pytest run: | pytest -s - - # Run coverage only once - - if: ${{ matrix.python-version == '3.9'}} - name: Get Coverage for badge - run: | - # Run coverage save the results - coverage run --source snowexsql -m pytest - SUMMARY=`coverage report -m | grep TOTAL` - - # Save results as ENV var - COVERAGE=$(python -c "print('$SUMMARY'.split(' ')[-1])") - echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV - - # var REF = 'refs/pull/27/merge.json'; - REF=${{ github.ref }} - # console.log('github.ref: ' + REF); - echo "github.ref: $REF" - # var PATHS = REF.split('/'); - IFS='/' read -ra PATHS <<< "$REF" - # var BRANCH_NAME = PATHS[1] + PATHS[2]; - BRANCH_NAME="${PATHS[1]}_${PATHS[2]}" - # console.log(BRANCH_NAME); // 'pull_27' - echo $BRANCH_NAME - # process.env.BRANCH = 'pull_27'; - echo "BRANCH=$(echo ${BRANCH_NAME})" >> $GITHUB_ENV - - - if: ${{ matrix.python-version == '3.9'}} - name: Create the Badge - uses: schneegans/dynamic-badges-action@v1.0.0 - with: - auth: ${{ secrets.GIST_SECRET }} - gistID: 2034019acc40a963bd02d2fcbb31c5a9 - filename: snowexsql__${{ env.BRANCH }}.json - label: Coverage - message: ${{ env.COVERAGE }} - color: green \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 346bd19..0397155 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,10 +28,8 @@ dependencies = [ [project.optional-dependencies] dev = [ - "pip==23.3", - "coverage==5.5", - "pytest==6.2.4", - "pytest-cov==2.12.1", + "pytest", + "pytest-cov", "sphinx-autobuild<=2024.5", ] docs = [ From aab1406754fe376ce2410b40cb1439d97e30cdda Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Thu, 12 Sep 2024 14:28:52 -0600 Subject: [PATCH 4/6] GH templates - Remove PR template (for now) Remove the bare bones version that only had the code coverage badge (which wasn't working). This will be re-introduced later. --- .github/PULL_REQUEST_TEMPLATE.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b36438d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1 +0,0 @@ -![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/micahjohnson150/2034019acc40a963bd02d2fcbb31c5a9/raw/snowexsql__pull_##.json) From edb724e0313df5e95490dcd43c1573dc0e623bfd Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Thu, 12 Sep 2024 14:36:40 -0600 Subject: [PATCH 5/6] README - Add CodeCoverage badge [skip ci] --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 5cb8102..89256ed 100644 --- a/README.rst +++ b/README.rst @@ -14,8 +14,8 @@ Welcome to snowexsql :target: https://pypi.org/project/snowexsql/ :alt: Code Coverage -.. image:: https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/micahjohnson150/2034019acc40a963bd02d2fcbb31c5a9/raw/snowexsql__heads_master.json - :alt: Code Coverage +.. image:: https://codecov.io/gh/SnowEx/snowexsql/graph/badge.svg?token=B27OKGBOTR + :target: https://codecov.io/gh/SnowEx/snowexsql About ----- From d8328b23606fe68ab7fb7740fe9d140d4019eab4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 19:46:36 +0000 Subject: [PATCH 6/6] Bump actions/setup-python in the actions group across 1 directory Bumps the actions group with 1 update in the / directory: [actions/setup-python](https://github.com/actions/setup-python). Updates `actions/setup-python` from 4 to 5 - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b625146..f6ab52e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,7 +28,7 @@ jobs: with: fetch-depth: 0 - name: Set up Python 3.10 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.10' - name: Install dependencies