From 43d94cd6ed1a90e0157135ec30832bb0ccbd4327 Mon Sep 17 00:00:00 2001 From: Gagan Deep Date: Wed, 18 Dec 2024 15:27:27 +0530 Subject: [PATCH 1/3] [deps] Bumped version to 1.2.0a --- CHANGES.rst | 5 +++++ openwisp_utils/__init__.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index c7c9c190..6e1b7799 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,11 @@ Changelog ========= +Version 1.2.0 [Unreleased] +-------------------------- + +Work in progress. + Version 1.1.1 [2024-11-20] -------------------------- diff --git a/openwisp_utils/__init__.py b/openwisp_utils/__init__.py index 5327dc4c..60e34a65 100644 --- a/openwisp_utils/__init__.py +++ b/openwisp_utils/__init__.py @@ -1,4 +1,4 @@ -VERSION = (1, 1, 1, 'final') +VERSION = (1, 2, 0, 'alpha') __version__ = VERSION # alias From 94a20f24a60f0c042c8dc0ff8a8f8ee4041934d2 Mon Sep 17 00:00:00 2001 From: Gagan Deep Date: Wed, 18 Dec 2024 15:28:31 +0530 Subject: [PATCH 2/3] [ci] Added GitHub workflow to replicate commits to version branch Created re-usable workflow for replication commits from the master branch to version branch. --- .github/workflows/reusable-version-branch.yml | 51 +++++++++++++++++ .github/workflows/version-branch.yml | 12 ++++ docs/developer/index.rst | 1 + docs/developer/reusable-workflows.rst | 57 +++++++++++++++++++ 4 files changed, 121 insertions(+) create mode 100644 .github/workflows/reusable-version-branch.yml create mode 100644 .github/workflows/version-branch.yml create mode 100644 docs/developer/reusable-workflows.rst diff --git a/.github/workflows/reusable-version-branch.yml b/.github/workflows/reusable-version-branch.yml new file mode 100644 index 00000000..7abd0da6 --- /dev/null +++ b/.github/workflows/reusable-version-branch.yml @@ -0,0 +1,51 @@ +name: Replicate Commits to Version Branch + +on: + workflow_call: + inputs: + module_name: + description: 'The name of the module' + required: true + type: string + +jobs: + replicate: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + + - name: Get version + id: get_version + run: | + VERSION=$(python -c " + from ${{ inputs.module_name }} import VERSION + print(f'{VERSION[0]}.{VERSION[1]}') + ") + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - name: Configure Git + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Rebase changes onto version branch + run: | + if git ls-remote --heads origin $VERSION | grep -sw $VERSION; then + git fetch origin --unshallow + git checkout -b $VERSION origin/$VERSION + git rebase origin/master + else + git checkout -b $VERSION + fi + git push origin $VERSION diff --git a/.github/workflows/version-branch.yml b/.github/workflows/version-branch.yml new file mode 100644 index 00000000..086db401 --- /dev/null +++ b/.github/workflows/version-branch.yml @@ -0,0 +1,12 @@ +name: Replicate Commits to Version Branch + +on: + push: + branches: + - master + +jobs: + version-branch: + uses: openwisp/openwisp-utils/.github/workflows/reusable-version-branch.yml@master + with: + module_name: openwisp_utils diff --git a/docs/developer/index.rst b/docs/developer/index.rst index e3e53c4d..95859cfa 100644 --- a/docs/developer/index.rst +++ b/docs/developer/index.rst @@ -16,6 +16,7 @@ Developer Docs ./admin-utilities.rst ./test-utilities.rst ./other-utilities.rst + ./reusable-workflows.rst Other useful resources: diff --git a/docs/developer/reusable-workflows.rst b/docs/developer/reusable-workflows.rst new file mode 100644 index 00000000..cd709b9b --- /dev/null +++ b/docs/developer/reusable-workflows.rst @@ -0,0 +1,57 @@ +Re-usable GitHub Workflows +========================== + +Replicate Commits to Version Branch +----------------------------------- + +This re-usable workflow replicates commits from the ``master`` branch to a +version branch. The version branch name is derived from the version of the +Python package specified in the workflow. + +Version branches are essential during development to ensure that each +OpenWISP module depends on compatible versions of its OpenWISP +dependencies. Without version branches, modules depending on the +``master`` branch of other modules may encounter errors, as the ``master`` +branch could include future changes that are incompatible with previous +versions. This makes it impossible to build a specific commit reliably +after such changes. + +To address this, we use version branches so that each module can depend on +a compatible version of its dependencies during development. Managing +these version branches manually is time-consuming, which is why this +re-usable GitHub workflow automates the process of keeping version +branches synchronized with the ``master`` branch. + +You can invoke this workflow from another workflow using the following +example: + +.. code-block:: yaml + + name: Replicate Commits to Version Branch + + on: + push: + branches: + - master + + jobs: + version-branch: + uses: openwisp/openwisp-utils/.github/workflows/reusable-version-branch.yml@master + with: + # The name of the Python package (required) + module_name: openwisp_utils + +.. note:: + + If the ``master`` branch is force-pushed, this workflow will fail due + to conflicts. To resolve this, you must manually synchronize the + version branch with the ``master`` branch. You can use the following + commands to perform this synchronization: + + .. code-block:: bash + + VERSION= # e.g. 1.2 + git fetch origin + git checkout $VERSION + git reset --hard origin/master + git push origin $VERSION --force-with-lease From d34c97cd86458e78b5563bc1f765fe78e63812f2 Mon Sep 17 00:00:00 2001 From: Gagan Deep Date: Thu, 19 Dec 2024 20:36:34 +0530 Subject: [PATCH 3/3] [ci] Updated replicate workflow to allow installing package --- .github/workflows/reusable-version-branch.yml | 12 +++++++++++- docs/developer/reusable-workflows.rst | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-version-branch.yml b/.github/workflows/reusable-version-branch.yml index 7abd0da6..be60ded4 100644 --- a/.github/workflows/reusable-version-branch.yml +++ b/.github/workflows/reusable-version-branch.yml @@ -7,6 +7,11 @@ on: description: 'The name of the module' required: true type: string + install_package: + description: 'Whether to install the package' + required: false + type: boolean + default: false jobs: replicate: @@ -19,12 +24,17 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.x' + python-version: '3.10' - name: Install dependencies run: | python -m pip install --upgrade pip + - name: Install package if required + if: ${{ inputs.install_package }} + run: | + pip install . + - name: Get version id: get_version run: | diff --git a/docs/developer/reusable-workflows.rst b/docs/developer/reusable-workflows.rst index cd709b9b..322592e9 100644 --- a/docs/developer/reusable-workflows.rst +++ b/docs/developer/reusable-workflows.rst @@ -40,6 +40,8 @@ example: with: # The name of the Python package (required) module_name: openwisp_utils + # Whether to install the Python package. Defaults to false. + install_package: true .. note::