From 7815aa4ba900c099971e0d6b57f1f8ea1f2b11f4 Mon Sep 17 00:00:00 2001 From: Guillaume Koch <39165367+gkoch78@users.noreply.github.com> Date: Mon, 10 Jul 2023 14:51:43 -0700 Subject: [PATCH] Feature release pipeline (#1) * Create .gitignore * project bootstrap * Create release.yaml * Update release.yaml * Update release.yaml * Update release.yaml * triggers * Update release.yaml * Update release.yaml * Update release.yaml * Update release.yaml * Update release.yaml * Update release.yaml * Update release.yaml * Update release.yaml * Update release.yaml * Update release.yaml * adjust packaged files * update --- .github/workflows/release.yaml | 53 ++++++++++++++++++++++++++++++++++ .gitignore | 8 +++++ council_ai/__init__.py | 2 ++ dev-requirements.txt | 1 + pyproject.toml | 42 +++++++++++++++++++++++++++ requirements.txt | 0 tests/unit/hello.py | 10 +++++++ 7 files changed, 116 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 .gitignore create mode 100644 council_ai/__init__.py create mode 100644 dev-requirements.txt create mode 100644 pyproject.toml create mode 100644 requirements.txt create mode 100644 tests/unit/hello.py diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..f129261e --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,53 @@ +name: release + +# Workflow Triggers +on: + # On a PullRequest against main + pull_request: + branches: [ "main" ] + types: ["closed", "synchronize"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + COUNCIL_DRAFT: ${{ github.event.pull_request.merged == false }} + COUNCIL_LATEST: ${{ github.event.pull_request.merged == true }} + +jobs: + release: +# Pull Request object schema: https://docs.github.com/en/graphql/reference/objects#pullrequest + if: | + ${{ contains(github.event.pull_request.labels.*.name, 'release') }} + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: checkout + uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.9" + - name: Installing dev requirements + run: pip3 install -r dev-requirements.txt + - name: Packaging + run: hatch build + - name: Version + id: hatch-version + run: | + echo version=$(hatch version) >> $GITHUB_OUTPUT + - name: Git Release + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + artifacts: "dist/*" + draft: ${{ env.COUNCIL_DRAFT }} + generateReleaseNotes: true + makeLatest: ${{ env.COUNCIL_LATEST }} + tag: v${{ steps.hatch-version.outputs.version }} + updateOnlyUnreleased: true + + - name: env var + run: export + if: always() diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..7f4f80b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +## Jetbrains +.idea + +## Macos +.DS_Store + +## Python +dist diff --git a/council_ai/__init__.py b/council_ai/__init__.py new file mode 100644 index 00000000..ec75fdaf --- /dev/null +++ b/council_ai/__init__.py @@ -0,0 +1,2 @@ +def hello_word(name: str = "") -> str: + return f"Hello {name or 'World'}!" diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 00000000..1e4cbe97 --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1 @@ +hatch==1.7.0 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..eb6b4341 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,42 @@ +[build-system] +requires = ["hatchling", "hatch-requirements-txt"] +build-backend = "hatchling.build" + +[project] +name = "council-ai" +version = "0.0.1" +description = "to do" +requires-python = ">=3.9" + +dynamic = ["dependencies"] + +[tool.hatch.build] +exclude = [ + ".github", + "*-requirements.txt", + "tests", + "venv", +] + +package = ['council_ai'] + +[tool.hatch.metadata.hooks.requirements_txt] +files = ["requirements.txt"] + +[tool.black] +line-length = 120 + +[tool.pytest.ini_options] +log_cli = true +log_cli_level = "DEBUG" +log_cli_format="[%(asctime)s %(levelname)s %(threadName)s %(name)s:%(funcName)s:%(lineno)s] %(message)s" +log_cli_date_format="%Y-%m-%d %H:%M:%S%z" + +[tool.ruff] +exclude = ["__init__.py", "docs"] +line-length = 120 + +[tool.mypy] +exclude = "(?x)(venv|docs)" +mypy_path= "./stubs" +explicit_package_bases = "true" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/hello.py b/tests/unit/hello.py new file mode 100644 index 00000000..bc4c0092 --- /dev/null +++ b/tests/unit/hello.py @@ -0,0 +1,10 @@ +import unittest +import council_ai + + +class TestHello(unittest.TestCase): + def test_hello(self): + self.assertEqual("Hello World!", council_ai.hello_word()) + + def test_hello_council(self): + self.assertEqual("Hello Council!", council_ai.hello_word("Council"))