Skip to content

Commit

Permalink
Merge pull request #21 from WattRex/mn_manager
Browse files Browse the repository at this point in the history
Add new workflow to mn_manager to publish on Test Pypi
  • Loading branch information
mariuscrsn authored Dec 14, 2023
2 parents 4406eee + 26af708 commit 2759cab
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 10 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/deploy_development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This workflow deploy system tools to development environment

name: deploy DEVELOPMENT

on:
push:
branches: [ "mn_manager" ]

pull_request_review:
types:
- submitted

jobs:

build-package-on-push:
if: ${{ github.event_name == 'push'}}
name: Build package ${{ vars.MN_MANAGER_PACKAGE_NAME }}
uses: WattRex/System-Tools/.github/workflows/build_python_package.yml@develop
with:
package-name: ${{ vars.MN_MANAGER_PACKAGE_NAME }}
package-path: mn_manager
source-path: mn_manager/src/wattrex_mn_manager
python-version: "3.10"
is-test-package: false

build-package-on-pull-request:
if: ${{ github.event_name == 'pull_request_review' && github.event.review.state == 'approved' && github.event.pull_request.head.ref == 'mn_manager'}}
name: Build package ${{ vars.MN_MANAGER_PACKAGE_NAME }}
uses: WattRex/System-Tools/.github/workflows/build_python_package.yml@develop
with:
package-name: ${{ vars.MN_MANAGER_PACKAGE_NAME }}
package-path: mn_manager
source-path: mn_manager/src/wattrex_mn_manager
python-version: "3.10"
is-test-package: false

publish-package:
name: Publish package ${{ vars.MN_MANAGER_PACKAGE_NAME }} to Test PyPi
needs: build-package-on-pull-request
runs-on: ubuntu-latest
environment: development
permissions:
id-token: write

steps:
- name: Download a single artifact
uses: actions/download-artifact@v3
with:
name: ${{ vars.MN_MANAGER_PACKAGE_NAME }}
path: ${{ vars.MN_MANAGER_PACKAGE_NAME }}/dist/

- name: Publish package to Test PyPI
uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e #realse/v1.8.10
with:
verbose: true
repository-url: https://test.pypi.org/legacy/
packages-dir: "${{ vars.MN_MANAGER_PACKAGE_NAME }}/dist/"
44 changes: 44 additions & 0 deletions .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow deploy system tools to production environment

name: deploy PRODUCTION

on:
pull_request_review:
types:
- submitted

jobs:

build-package-on-pull-request:
if: ${{ github.event_name == 'pull_request_review' && github.event.review.state == 'approved' && github.event.pull_request.head.ref == 'develop' && github.event.pull_request.base.ref == 'master' }}
name: Build package ${{ vars.MN_MANAGER_PACKAGE_NAME }}
uses: WattRex/System-Tools/.github/workflows/build_python_package.yml@develop
with:
package-name: ${{ vars.MN_MANAGER_PACKAGE_NAME }}
package-path: mn_manager
source-path: mn_manager/src/wattrex_mn_manager
python-version: "3.10"
is-test-package: false

publish-package:
name: Publish package ${{ vars.MN_MANAGER_PACKAGE_NAME }} to PyPi
needs: build-package-on-pull-request
runs-on: ubuntu-latest
environment: production
permissions:
id-token: write

steps:
- name: Download a single artifact
uses: actions/download-artifact@v3
with:
name: ${{ vars.MN_MANAGER_PACKAGE_NAME }}
path: ${{ vars.MN_MANAGER_PACKAGE_NAME }}/dist/

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@f8c70e705ffc13c3b4d1221169b84f12a75d6ca8
with:
verbose: true
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: "${{ vars.MN_MANAGER_PACKAGE_NAME }}/dist/"
20 changes: 10 additions & 10 deletions .github/workflows/publish-mn-manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

name: Master node manager QA and deploy to Pypi

on:
push:
branches: [ "mn_manager" ]

pull_request_review:
types: [submitted]
review:
pull_request:
base:
ref: [ "mn_manager" ]
# on:
# push:
# branches: [ "mn_manager" ]

# pull_request_review:
# types: [submitted]
# review:
# pull_request:
# base:
# ref: [ "mn_manager" ]

jobs:

Expand Down
9 changes: 9 additions & 0 deletions devops/config_params_example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---

system_shared_tool:
DEFAULT_CHAN_NUM_MSG: 300
DEFAULT_IPC_MSG_SIZE: 600
DEFAULT_CHAN_TIMEOUT: 3

wattrex_driver_db:
DEFAULT_CRED_FILEPATH: '~/Battery-Experiments-Manager/devops/mn_manager/.cred.yaml'
22 changes: 22 additions & 0 deletions devops/mn_manager/Dockerfile.mn_manager
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM python:3.9

LABEL org.opencontainers.image.authors="[email protected]" \
org.opencontainers.image.title="Battery-Experiments-Manager" \
org.opencontainers.image.description="A python service to manage master node communicatin externaly through mqtt" \
org.opencontainers.image.url="https://github.com/WattRex/Battery-Experiments-Manager" \
org.opencontainers.image.source="https://github.com/WattRex/Battery-Experiments-Manager" \
org.opencontainers.image.licenses="GPL-3.0"

ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code

ADD ./devops/config_params_example.yaml.yaml ./devops/config_params.yaml
ENV CONFIG_FILE_PATH=/code/devops/config_params.yaml

ARG CACHE=1
RUN pip install --upgrade pip
RUN pip install --upgrade wattrex-mn-manager
ADD ./devops/mn_manager/run.py /code/devops/mn_manager/run.py

CMD ["python", "./devops/mn_manager/run.py"]

0 comments on commit 2759cab

Please sign in to comment.