Skip to content

Commit

Permalink
Feat/auto-release (#94)
Browse files Browse the repository at this point in the history
Split GitHub actions in two for auto relese:
- On TestPyPI
- On PyPI
  • Loading branch information
VincentAuriau authored May 31, 2024
1 parent e265ebe commit 3b8020f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
7 changes: 2 additions & 5 deletions .github/actions/publish/action.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: "PyPI Poetry Publish"
: # from https://github.com/code-specialist/pypi-poetry-publish/blob/main/action.yaml
description: "Opinionated GitHub action to fully automate publishing packages to any PyPI registry - using Poetry and GitHub releases"
branding:
icon: "package"
color: "blue"
description: "GitHub action to automate publishing packages to PyPI - from code-specialist."


inputs:
ACCESS_TOKEN:
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/release_pypi.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
name: Build and publish choice-learn
name: Build and publish choice-learn on PyPI

on:
release:
types: [ published ]
workflow_run:
workflows: [Build and publish choice-learn on TestPyPI]
types:
- completed
workflow_dispatch:

jobs:
test-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Wait for publish on TestPyPI
uses: lewagon/[email protected]
with:
ref: main
check-name: 'publish to PyPI'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 20

- name: Install Python, choice-learn & run tests
uses: actions/setup-python@v5
Expand All @@ -31,6 +26,7 @@ jobs:
- name: publish to PyPI
uses: ./.github/actions/publish
with:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKAGE_DIRECTORY: "./choice_learn/"
PYTHON_VERSION: "3.9"
PUBLISH_REGISTRY_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/release_test_pypi.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and publish choice-learn
name: Build and publish choice-learn on TestPyPI

on:
release:
Expand All @@ -9,13 +9,15 @@ jobs:
publish-service-client-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Publish choice-learn on TestPyPI
uses: ./.github/actions/publish
with:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKAGE_DIRECTORY: "./choice_learn/"
PYTHON_VERSION: "3.9"
PUBLISH_REGISTRY_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}
PUBLISH_REGISTRY_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }}
PUBLISH_REGISTRY: "https://test.pypi.org/simple/"
UPDATE_CODE_VERSION: TEST_PYPI_USERNAME
PUBLISH_REGISTRY: "https://test.pypi.org/legacy/"
UPDATE_CODE_VERSION: true
PUSH_BRANCH: release_${{ github.event.release.tag_name }}
2 changes: 1 addition & 1 deletion choice_learn/models/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(
axis=-1,
epsilon=1e-35,
name="exact_categorical_crossentropy",
reduction=tf.keras.losses.Reduction.AUTO,
reduction="sum_over_batch_size",
)
self.callbacks = tf.keras.callbacks.CallbackList(callbacks, add_history=True, model=None)
self.callbacks.set_model(self)
Expand Down
2 changes: 1 addition & 1 deletion choice_learn/tf_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def __init__(
axis=-1,
epsilon=1e-35,
name="exact_categorical_crossentropy",
reduction=tf.keras.losses.Reduction.AUTO,
reduction="sum_over_batch_size",
):
"""Initialize function.
Expand Down
13 changes: 8 additions & 5 deletions tests/manual_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ def run_module(file):
file : str
.py file
"""
sub_file = file.replace(".py", "")
module = importlib.import_module(sub_file, package="__name__")
sub_file = str(file).replace(".py", "").replace("/", ".")[6:]
__import__(sub_file)
module = importlib.import_module(sub_file, package="./")
for i in dir(module):
item = getattr(module, i)
if callable(item) and item.startswith("test_"):
if callable(item) and item.__name__.startswith("test_"):
item()


if __name__ == "__main__":
for file in Path.glob("./**/*.py"):
run_module(file)
directory = Path("./tests/")
for file in directory.glob("./**/*.py"):
if "manual_run" not in str(file):
run_module(file)

0 comments on commit 3b8020f

Please sign in to comment.