Skip to content

Commit

Permalink
Modernize repo and package (#65)
Browse files Browse the repository at this point in the history
* Move environment files to the 'envs' directory

Relocated 'environment.yaml' and 'requirements.txt' to a dedicated 'envs/'
directory for better organization. This change improves project structure and
simplifies environment file management.

* Add Dependabot config to monitor Actions versions

Introduce a Dependabot configuration file to automate version checks for GitHub
Actions. The setup schedules weekly checks and ensures actions are kept
up to date via pull requests. This improves maintenance and security by
automating dependency updates.

* Add GHA workflow for auto-assigning issues/PRs

This workflow triggers on issue or PR creation and reopening events. It uses a
shared workflow from UBC-MOAD/gha-workflows/.

* Add GHA CodeQL analysis workflow

This commit introduces a GitHub Actions workflow to run CodeQL analysis. It
helps identify potential security vulnerabilities in Python code with scheduled
weekly scans and branch-specific triggers.

* Add test environment and GHA pytest workflow

Create a new conda environment file for testing and coverage analysis,
specifying required dependencies for testing the SOG-Bloomcast-Ensemble package.
Add a GitHub Actions workflow to automate running pytest with coverage checks
and reporting. The workflow uses a reusable workflow from UBC-MOAD/gha-workflows.

* Update test env to install SOG package from GitHub

Updated the test environment file to include installation of the SOG package in
editable mode via a GitHub URL. This ensures the latest SOG code is pulled
directly from the repository, alongside the existing SOG-Bloomcast-Ensemble
package.

* Rename dev env file and update dev env name

Renamed `environment.yml` to `environment-dev.yaml` and updated the environment
name to `bloomcast-dev` for clarity and consistency. Adjusted setup instructions
to reflect these changes, aligning the naming convention with
development-specific purposes.

* Add pre-commit to manage code style & repo QA

Initial hooks:

* Code formatting by black
* Trim trailing whitespace
* Ensure that files are either empty, or end with one newline
* Confirm that YAML files have parsable syntax
* Confirm that TOML files have parsable syntax
* Prevent files larger than 500 kB from being committed

* Code style gardening by pre-commit

* Add pytest-cov and pytest-randomly to dev env

Updated environment-dev.yaml to include pytest-cov for test coverage monitoring
and pytest-randomly for randomized test execution. These additions aim to
improve testing comprehensiveness and robustness.

* Pin versions of sphinx and optional extensions

As recommended for reproducible builds on readthedocs:
https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
and to ensure that our docs build works with readthedocs changes to default
project dependencies:
https://blog.readthedocs.com/defaulting-latest-build-tools/

* Switch to pyproject.toml for build configuration

Replaced setup.py with pyproject.toml to modernize the project's build system and
comply with PEP 518 standards. Updated references in the codebase to use the new
configuration format. This change simplifies dependency management and aligns the
project with current Python packaging practices.

* Chg to Hatch for project build system and pkg management

Updated `pyproject.toml` to replace Setuptools with Hatchling as the build
system. Added Hatch to the dev environment dependencies in `environment-dev.yaml`
for package management and consistency. Removed Setuptools-specific
configurations and aligned the project with Hatch's requirements.

* Refactor metadata handling and update project config

Centralize package metadata in `pyproject.toml` and `bloomcast/__about__.py`,
removing legacy `__pkg_metadata__.py`. Updated Sphinx configuration to
dynamically fetch metadata, modernizing the documentation setup. Adjusted authors
list and introduced version automation with Hatch.

* Update pkgs & versions used in recent dev env

* Rename project and package to "bloomcast"

Updated the project name and package references in pyproject.toml to address
CI test import failures.

* Move coverage config from .coveragerc to pyproject.toml

Transitioned the coverage settings to pyproject.toml for a cleaner and
centralized configuration. Removed the redundant .coveragerc file as its
contents are now fully integrated into the project’s primary configuration file.

* Add pytest configuration to pyproject.toml

Include pytest minimum version and the `tests/` path in pyproject.toml. This is
done to avoid collection of the dependency `env/src/sogcommand/SOGcommand/tests/`
directory in the GHA pytest-with-coverage workflow.
  • Loading branch information
douglatornell authored Feb 15, 2025
1 parent f69712f commit ffaa1c1
Show file tree
Hide file tree
Showing 38 changed files with 2,571 additions and 2,119 deletions.
9 changes: 0 additions & 9 deletions .coveragerc

This file was deleted.

13 changes: 13 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Dependabot config to enable checking for version updates on actions
# and open pull requests to apply those updates
# refs:
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
18 changes: 18 additions & 0 deletions .github/workflows/assign-issue-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Assign Issue/PR

on:
issues:
types:
- reopened
- opened
pull_request:
types:
- reopened
- opened

jobs:
auto_assign:
permissions:
issues: write
pull-requests: write
uses: UBC-MOAD/gha-workflows/.github/workflows/auto-assign.yaml@main
22 changes: 22 additions & 0 deletions .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "CodeQL"

on:
push:
branches: [ '*' ]
schedule:
- cron: '01 12 * * 0'

jobs:
analyze:
name: Analyze
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
uses: UBC-MOAD/gha-workflows/.github/workflows/codeql-analysis.yaml@main
with:
language: ${{ matrix.language }}
25 changes: 25 additions & 0 deletions .github/workflows/pytest-with-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: pytest-with-coverage

on:
push:
branches: [ '*' ]
# Enable workflow to be triggered from GitHub CLI, browser, or via API
# primarily for testing conda env solution for new Python versions
workflow_dispatch:

jobs:
pytest-with-coverage:
permissions:
contents: read
pull-requests: write
strategy:
fail-fast: false
matrix:
python-version: [ '3.12' ]
uses: UBC-MOAD/gha-workflows/.github/workflows/pytest-with-coverage.yaml@main
with:
python-version: ${{ matrix.python-version }}
conda-env-file: envs/environment-test.yaml
conda-env-name: bloomcast-test
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -313,5 +313,3 @@ flycheck_*.el

# network security
/network-security.data


21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Git pre-commit hooks config file
# Only takes effect if you have pre-commit installed in the env,
# and after you run `pre-commit install`
#
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
# Out-of-the-box hooks from the pre-commit org
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
# Code formatting with black
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
23 changes: 7 additions & 16 deletions __pkg_metadata__.py → bloomcast/__about__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
# Copyright 2011-2021 Doug Latornell and The University of British Columbia

# Copyright 2011– present by Doug Latornell, Susan Allen, and The University of British Columbia
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Python packaging metadata for SoG-bloomcast.
"""


__all__ = [
'PROJECT', 'DESCRIPTION', 'VERSION', 'DEV_STATUS',
]
# SPDX-License-Identifier: Apache-2.0


PROJECT = 'SoG-bloomcast'
DESCRIPTION = 'Strait of Georgia spring diatom bloom predictor'
VERSION = '3.1'
DEV_STATUS = '5 - Production'
__version__ = "3.1" # pragma: no cover
1 change: 0 additions & 1 deletion bloomcast/__pkg_metadata__.py

This file was deleted.

Loading

0 comments on commit ffaa1c1

Please sign in to comment.