Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 89 additions & 41 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ name: CI-CD

# only run on pushes to main or pull requests
on:
push:
# push to any branch *
branches: ["*"]
# push:
# push to any branch *
# branches: ["*"]
pull_request:
branches: [main, development]

branches: ["*"]

jobs:
################################################################################################
Expand Down Expand Up @@ -69,6 +68,30 @@ jobs:
verbose: true
name: codecov-umbrella

################################################################################################
# Ruff: Run ruff linter
################################################################################################
Ruff:
runs-on: ubuntu-latest
env:
PIXI_ENV: "dev"
strategy:
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
- name: Install Pixi
uses: prefix-dev/setup-pixi@v0.8.1
with:
environments: ${{ env.PIXI_ENV }}
pixi-version: v0.33.0
cache: true
locked: false

- name: Run Ruff
run: pixi run lint

################################################################################################
# Semantic-Release: Run semantic-release to automate versioning and publishing
################################################################################################
Expand All @@ -80,7 +103,7 @@ jobs:
issues: write
pull-requests: write

needs: [Unit-Tests]
needs: [Unit-Tests, Ruff]

# if pulling to main, deploy to PyPI
if: github.ref == 'refs/heads/main'
Expand Down Expand Up @@ -119,54 +142,79 @@ jobs:
environments: ${{ env.PIXI_ENV }}
pixi-version: v0.33.0
cache: true
locked: false
locked: false
# cache-key: pixi-ENV_${{ env.PIXI_ENV }}-

- name: Print Semver
env:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pixi run semver

- name: Run semantic-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: release
run: pixi run release

- name: Test Outputs of semantic release step
run: |
echo "${{ steps.release.outputs.released }}"
echo "${{ steps.release.outputs.version }}"
echo "${{ steps.release.outputs.tag }}"

################################################################################################
###############################################################################################
# Publish-To-PyPi & Test-PyPi-Installation: Publish to PyPI and test installation
################################################################################################
# Publish-To-PyPi:
# needs: Semantic-Release
# env:
# PIXI_ENV: "publish"
# # if: needs.Semantic-Release.outputs.released == 'true'
# strategy:
# matrix:
# os: [ubuntu-latest]

# runs-on: ${{ matrix.os }}
# steps:
# - name: Checkout the code with tag ${{ needs.Semantic-Release.outputs.tag }}
# uses: actions/checkout@v4
# with:
# ref: ${{ needs.Semantic-Release.outputs.tag }}

# - name: Install Pixi
# uses: prefix-dev/setup-pixi@v0.8.1
# with:
# environments: ${{ env.PIXI_ENV }}
# pixi-version: v0.33.0
# # cache-key: pixi-ENV_${{ env.PIXI_ENV }}-
# cache: true
# locked: false # wont be the same because of the tag

# - name: Test Build
# run: |
# pixi run -e ${{ env.PIXI_ENV }} build
###############################################################################################
Publish-To-Test-PyPi:
needs: Semantic-Release
env:
PIXI_ENV: "publish"
if: needs.Semantic-Release.outputs.released == 'true'
strategy:
matrix:
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}
steps:
- name: Checkout the code with tag ${{ needs.Semantic-Release.outputs.tag }}
uses: actions/checkout@v4
with:
ref: ${{ needs.Semantic-Release.outputs.tag }}

- name: Install Pixi
uses: prefix-dev/setup-pixi@v0.8.1
with:
environments: ${{ env.PIXI_ENV }}
pixi-version: v0.33.0
cache: true
locked: false # wont be the same because of the tag

- name: Publish to TestPyPI
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: |
pixi run -e ${{ env.PIXI_ENV }} publish-test

Test-TestPypi-Installation:
needs: [Semantic-Release, Publish-To-Test-PyPi]
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.12"]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout the code with tag ${{ needs.Semantic-Release.outputs.tag }}
uses: actions/checkout@v4
with:
ref: ${{ needs.Semantic-Release.outputs.tag }}

- name: setup python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install using TestPyPI
run: |
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ readii
15 changes: 8 additions & 7 deletions config/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ extend-exclude = [

extend-include = []

include = [
"src/readii/loaders.py"
]

[lint]
select = [
Expand All @@ -24,20 +27,18 @@ select = [
"W", # flake8
"C", # mccabe
"I", # isort
"N", # pep8-naming
"D", # pydocstyle
# "N", # pep8-naming
"ANN", # flake8-annotations
"BLE", # flake8-blind-except
"B", # flake8-bugbear
"A", # flake8-builtins
"G", # flake8-logging-format
# "G", # flake8-logging-format
"ERA", # eradicate
"RUF", # Ruff-specific rules
"TCH", # flake8-type-checking
]
ignore = ["ANN101"]
unfixable = [
"ERA", # Don't remove commented-out code
]


[lint.per-file-ignores]
Expand All @@ -57,10 +58,10 @@ relative-imports-order = "closest-to-furthest"


[lint.pydocstyle]
convention = "google"
convention = "numpy"


[format]
quote-style = "single"
quote-style = "double"
docstring-code-format = true
docstring-code-line-length = 20
16 changes: 1 addition & 15 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 24 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ myst-nb = "*"
sphinx-autoapi = "*"
sphinx-rtd-theme = "*"


# TODO::add tasks to build documentation

############################################## STYLE ###############################################
Expand All @@ -80,11 +79,18 @@ sphinx-rtd-theme = "*"
ruff = ">=0.4.4"
pre-commit = ">=3.7.1,<3.8"

# TODO::add tasks to run style checks
# as of 10-21-2024, `ruff check` has 152 errors
[tool.pixi.feature.style.tasks]
[tool.pixi.feature.style.tasks.lint]
cmd = "ruff check --config=config/ruff.toml"
inputs = ["src", "config/ruff.toml"]
description = "Run ruff linter"

#################################### RELEASE & BUILD ###############################################
[tool.pixi.feature.style.tasks.format]
cmd = "ruff format --config=config/ruff.toml"
inputs = ["src", "config/ruff.toml"]
description = "Run ruff formatter, use `--diff` to see changes only"

#################################### RELEASE & BUILD ###############################################

[tool.pixi.feature.build.dependencies]
hatch = "*"
Expand All @@ -93,7 +99,6 @@ hatch = "*"
build-backend = "hatchling.build"
requires = ["hatchling"]


[tool.pixi.feature.build.tasks]
# Builds the package
build = { cmd = [
Expand All @@ -106,10 +111,21 @@ build = { cmd = [
"pyproject.toml",
], outputs = [
"dist/*",
], env = { HATCH_CONFIG = "config/hatch.toml" } }

], env = { HATCH_CONFIG = "config/hatch.toml" }, description = "Build the package" }

publish-test = { cmd = [
"hatch",
"publish",
"--yes",
"--repo",
"test",
], inputs = [
"dist/*",
], depends-on = [
"build",
], env = { HATCH_CONFIG = "config/hatch.toml" }, description = "Publish to test PyPI" }

# Publishes the package to the TEST-PYPI repository, depends on the build task
[tool.pixi.feature.release.dependencies]
python-semantic-release = "*"

Expand All @@ -128,4 +144,4 @@ remove_dist = false # don't remove dists
patch_without_tag = true # patch release by default

[tool.semantic_release.branches.main]
match = "*"
match = "*"
Loading
Loading