Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Device autoupdate test and device service #29

Merged
merged 14 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
161 changes: 80 additions & 81 deletions .github/workflows/generate-monorepo-manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,84 +47,83 @@ jobs:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4
name: Set up - Checkout lib/py_monorepo_manager
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.WORKFLOW_TOKEN }}

# Cache the installation of Poetry itself, e.g. the next step. This prevents the workflow
# from installing Poetry every time, which can be slow. Note the use of the Poetry version
# number in the cache key, and the "-0" suffix: this allows you to invalidate the cache
# manually if/when you want to upgrade Poetry, or if something goes wrong. This could be
# mildly cleaner by using an environment variable, but I don't really care.
- name: Set up - Cache Poetry 1.7.1
uses: actions/cache@v4
with:
path: ~/.local
key: python-3.11-poetry-1.7.1

# If you wanted to use multiple Python versions, you'd have specify a matrix in the job and
# reference the matrix python version here.
- uses: actions/setup-python@v5
name: Set up - Install Python 3.11
with:
python-version: 3.11

# Install Poetry. You could do this manually, or there are several actions that do this.
# `snok/install-poetry` seems to be minimal yet complete, and really just calls out to
# Poetry's default install script, which feels correct. I pin the Poetry version here
# because Poetry does occasionally change APIs between versions and I don't want my
# actions to break if it does.
#
# The key configuration value here is `virtualenvs-in-project: true`: this creates the
# venv as a `.venv` in your testing directory, which allows the next step to easily
# cache it.
- name: Set up - Install Poetry 1.7.1
uses: snok/install-poetry@v1
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true

# Cache your dependencies (i.e. all the stuff in your `pyproject.toml`). Note the cache
# key: if you're using multiple Python versions, or multiple OSes, you'd need to include
# them in the cache key. I'm not, so it can be simple and just depend on the poetry.lock.
- name: Set up - Cache lib/py_monorepo_manager dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: ./lib/py_monorepo_manager/.venv
key: py_monorepo_manager-${{ hashFiles('./lib/py_monorepo_manager/poetry.lock', './lib/py_dev_dependencies/**/*.py', './lib/py_dev_dependencies/**/*.sql', './lib/py_dev_dependencies/poetry.lock')}}-3.11-1.7.1

# Install dependencies. `--no-root` means "install all dependencies but not the project
# itself", which is what you want to avoid caching _your_ code. The `if` statement
# ensures this only runs on a cache miss.
- name: Set up - Install lib/py_monorepo_manager dependencies
run: poetry install --no-interaction --no-root --all-extras
working-directory: ./lib/py_monorepo_manager

- name: generate files
# always run poetry install to ensure the entrypoint is up to date
run: poetry install && poetry run monorepo_manager all
working-directory: ./lib/py_monorepo_manager

- name: Add add new workflow files
run: git add ./.github/workflows/*

- name: Add add new library files
run: git add ./lib/*

- name: Add add new service files
run: git add ./services/*

- name: Add add new script files
run: git add ./scripts/*

- uses: actions-js/push@master
name: Push changes
with:
github_token: ${{ secrets.WORKFLOW_TOKEN }}
branch: ${{ github.head_ref }}
message: "Update monorepo boilerplate"
- uses: actions/checkout@v4
name: Set up - Checkout lib/py_monorepo_manager
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.WORKFLOW_TOKEN }}

# Cache the installation of Poetry itself, e.g. the next step. This prevents the workflow
# from installing Poetry every time, which can be slow. Note the use of the Poetry version
# number in the cache key, and the "-0" suffix: this allows you to invalidate the cache
# manually if/when you want to upgrade Poetry, or if something goes wrong. This could be
# mildly cleaner by using an environment variable, but I don't really care.
- name: Set up - Cache Poetry 1.7.1
uses: actions/cache@v4
with:
path: ~/.local
key: python-3.11-poetry-1.7.1

# If you wanted to use multiple Python versions, you'd have specify a matrix in the job and
# reference the matrix python version here.
- uses: actions/setup-python@v5
name: Set up - Install Python 3.11
with:
python-version: 3.11

# Install Poetry. You could do this manually, or there are several actions that do this.
# `snok/install-poetry` seems to be minimal yet complete, and really just calls out to
# Poetry's default install script, which feels correct. I pin the Poetry version here
# because Poetry does occasionally change APIs between versions and I don't want my
# actions to break if it does.
#
# The key configuration value here is `virtualenvs-in-project: true`: this creates the
# venv as a `.venv` in your testing directory, which allows the next step to easily
# cache it.
- name: Set up - Install Poetry 1.7.1
uses: snok/install-poetry@v1
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true

# Cache your dependencies (i.e. all the stuff in your `pyproject.toml`). Note the cache
# key: if you're using multiple Python versions, or multiple OSes, you'd need to include
# them in the cache key. I'm not, so it can be simple and just depend on the poetry.lock.
- name: Set up - Cache lib/py_monorepo_manager dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: ./lib/py_monorepo_manager/.venv
key: py_monorepo_manager-${{ hashFiles('./lib/py_monorepo_manager/poetry.lock', './lib/py_dev_dependencies/**/*.py', './lib/py_dev_dependencies/**/*.sql', './lib/py_dev_dependencies/poetry.lock')}}-3.11-1.7.1

# Install dependencies. `--no-root` means "install all dependencies but not the project
# itself", which is what you want to avoid caching _your_ code. The `if` statement
# ensures this only runs on a cache miss.
- name: Set up - Install lib/py_monorepo_manager dependencies
run: poetry install --no-interaction --no-root --all-extras
working-directory: ./lib/py_monorepo_manager

- name: generate files
# always run poetry install to ensure the entrypoint is up to date
run: poetry install && poetry run monorepo_manager all
working-directory: ./lib/py_monorepo_manager

- name: Add add new workflow files
run: git add ./.github/workflows/*

- name: Add add new library files
run: git add ./lib/*

- name: Add add new service files
run: git add ./services/*

- name: Add add new script files
run: git add ./scripts/*

- uses: actions-js/push@master
name: Push changes
with:
github_token: ${{ secrets.WORKFLOW_TOKEN }}
branch: ${{ github.head_ref }}
message: "Update monorepo boilerplate"
20 changes: 19 additions & 1 deletion .github/workflows/test-lib-py_carlos_database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
- .github/workflows/test-lib-py_carlos_database.yml
- lib/py_carlos_database/**
- lib/py_dev_dependencies/**
- lib/py_edge_interface/**


workflow_dispatch:
Expand Down Expand Up @@ -94,7 +95,7 @@ jobs:
uses: actions/cache@v4
with:
path: ./lib/py_carlos_database/.venv
key: py_carlos_database-${{ hashFiles('./lib/py_carlos_database/poetry.lock', './lib/py_dev_dependencies/**/*.py', './lib/py_dev_dependencies/**/*.sql', './lib/py_dev_dependencies/poetry.lock')}}-3.11-1.7.1
key: py_carlos_database-${{ hashFiles('./lib/py_carlos_database/poetry.lock', './lib/py_dev_dependencies/**/*.py', './lib/py_edge_interface/**/*.py', './lib/py_dev_dependencies/**/*.sql', './lib/py_edge_interface/**/*.sql', './lib/py_dev_dependencies/poetry.lock', './lib/py_edge_interface/poetry.lock')}}-3.11-1.7.1

# Install dependencies. `--no-root` means "install all dependencies but not the project
# itself", which is what you want to avoid caching _your_ code. The `if` statement
Expand Down Expand Up @@ -147,3 +148,20 @@ jobs:
message: "update lib/py_carlos_database"
coauthor_email: ${{ github.event.pull_request.user.login }}@users.noreply.github.com
coauthor_name: ${{ github.event.pull_request.user.login }}

- name: Set up - Get changed files for CHANGELOG.md
if: ${{ !cancelled() }}
id: detect-changed-files
uses: tj-actions/changed-files@v42
with:
files_yaml: |
pyproject_toml:
- lib/py_carlos_database/pyproject.toml
python_files:
- lib/py_carlos_database/carlos/**/*.py
- name: Test - Version bump
# This step will fail if there are python files changed but the version in pyproject.toml is not updated
if: (steps.detect-changed-files.outputs.python_files_any_changed == 'true') && (steps.detect-changed-files.outputs.pyproject_toml_any_changed == 'false') && !cancelled()
run: |
echo "No changes in pyproject.toml but there are changes in python files. Please update the version in pyproject.toml if the code changes. Otherwise the automatic update of the carlos device may fail."
exit 1
17 changes: 17 additions & 0 deletions .github/workflows/test-lib-py_dev_dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,20 @@ jobs:
message: "update lib/py_dev_dependencies"
coauthor_email: ${{ github.event.pull_request.user.login }}@users.noreply.github.com
coauthor_name: ${{ github.event.pull_request.user.login }}

- name: Set up - Get changed files for CHANGELOG.md
if: ${{ !cancelled() }}
id: detect-changed-files
uses: tj-actions/changed-files@v42
with:
files_yaml: |
pyproject_toml:
- lib/py_dev_dependencies/pyproject.toml
python_files:
- lib/py_dev_dependencies/devtools/**/*.py
- name: Test - Version bump
# This step will fail if there are python files changed but the version in pyproject.toml is not updated
if: (steps.detect-changed-files.outputs.python_files_any_changed == 'true') && (steps.detect-changed-files.outputs.pyproject_toml_any_changed == 'false') && !cancelled()
run: |
echo "No changes in pyproject.toml but there are changes in python files. Please update the version in pyproject.toml if the code changes. Otherwise the automatic update of the carlos device may fail."
exit 1
17 changes: 17 additions & 0 deletions .github/workflows/test-lib-py_edge_device.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,20 @@ jobs:
message: "update lib/py_edge_device"
coauthor_email: ${{ github.event.pull_request.user.login }}@users.noreply.github.com
coauthor_name: ${{ github.event.pull_request.user.login }}

- name: Set up - Get changed files for CHANGELOG.md
if: ${{ !cancelled() }}
id: detect-changed-files
uses: tj-actions/changed-files@v42
with:
files_yaml: |
pyproject_toml:
- lib/py_edge_device/pyproject.toml
python_files:
- lib/py_edge_device/carlos/**/*.py
- name: Test - Version bump
# This step will fail if there are python files changed but the version in pyproject.toml is not updated
if: (steps.detect-changed-files.outputs.python_files_any_changed == 'true') && (steps.detect-changed-files.outputs.pyproject_toml_any_changed == 'false') && !cancelled()
run: |
echo "No changes in pyproject.toml but there are changes in python files. Please update the version in pyproject.toml if the code changes. Otherwise the automatic update of the carlos device may fail."
exit 1
17 changes: 17 additions & 0 deletions .github/workflows/test-lib-py_edge_interface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,20 @@ jobs:
message: "update lib/py_edge_interface"
coauthor_email: ${{ github.event.pull_request.user.login }}@users.noreply.github.com
coauthor_name: ${{ github.event.pull_request.user.login }}

- name: Set up - Get changed files for CHANGELOG.md
if: ${{ !cancelled() }}
id: detect-changed-files
uses: tj-actions/changed-files@v42
with:
files_yaml: |
pyproject_toml:
- lib/py_edge_interface/pyproject.toml
python_files:
- lib/py_edge_interface/carlos/**/*.py
- name: Test - Version bump
# This step will fail if there are python files changed but the version in pyproject.toml is not updated
if: (steps.detect-changed-files.outputs.python_files_any_changed == 'true') && (steps.detect-changed-files.outputs.pyproject_toml_any_changed == 'false') && !cancelled()
run: |
echo "No changes in pyproject.toml but there are changes in python files. Please update the version in pyproject.toml if the code changes. Otherwise the automatic update of the carlos device may fail."
exit 1
20 changes: 19 additions & 1 deletion .github/workflows/test-lib-py_edge_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
- .github/workflows/test-lib-py_edge_server.yml
- lib/py_edge_server/**
- lib/py_edge_interface/**
- lib/py_carlos_database/**
- lib/py_dev_dependencies/**
- lib/py_edge_device/**

Expand Down Expand Up @@ -96,7 +97,7 @@ jobs:
uses: actions/cache@v4
with:
path: ./lib/py_edge_server/.venv
key: py_edge_server-${{ hashFiles('./lib/py_edge_server/poetry.lock', './lib/py_edge_interface/**/*.py', './lib/py_dev_dependencies/**/*.py', './lib/py_edge_device/**/*.py', './lib/py_edge_interface/**/*.sql', './lib/py_dev_dependencies/**/*.sql', './lib/py_edge_device/**/*.sql', './lib/py_edge_interface/poetry.lock', './lib/py_dev_dependencies/poetry.lock', './lib/py_edge_device/poetry.lock')}}-3.11-1.7.1
key: py_edge_server-${{ hashFiles('./lib/py_edge_server/poetry.lock', './lib/py_edge_interface/**/*.py', './lib/py_carlos_database/**/*.py', './lib/py_dev_dependencies/**/*.py', './lib/py_edge_device/**/*.py', './lib/py_edge_interface/**/*.sql', './lib/py_carlos_database/**/*.sql', './lib/py_dev_dependencies/**/*.sql', './lib/py_edge_device/**/*.sql', './lib/py_edge_interface/poetry.lock', './lib/py_carlos_database/poetry.lock', './lib/py_dev_dependencies/poetry.lock', './lib/py_edge_device/poetry.lock')}}-3.11-1.7.1

# Install dependencies. `--no-root` means "install all dependencies but not the project
# itself", which is what you want to avoid caching _your_ code. The `if` statement
Expand Down Expand Up @@ -149,3 +150,20 @@ jobs:
message: "update lib/py_edge_server"
coauthor_email: ${{ github.event.pull_request.user.login }}@users.noreply.github.com
coauthor_name: ${{ github.event.pull_request.user.login }}

- name: Set up - Get changed files for CHANGELOG.md
if: ${{ !cancelled() }}
id: detect-changed-files
uses: tj-actions/changed-files@v42
with:
files_yaml: |
pyproject_toml:
- lib/py_edge_server/pyproject.toml
python_files:
- lib/py_edge_server/carlos/**/*.py
- name: Test - Version bump
# This step will fail if there are python files changed but the version in pyproject.toml is not updated
if: (steps.detect-changed-files.outputs.python_files_any_changed == 'true') && (steps.detect-changed-files.outputs.pyproject_toml_any_changed == 'false') && !cancelled()
run: |
echo "No changes in pyproject.toml but there are changes in python files. Please update the version in pyproject.toml if the code changes. Otherwise the automatic update of the carlos device may fail."
exit 1
17 changes: 17 additions & 0 deletions .github/workflows/test-lib-py_monorepo_manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,20 @@ jobs:
message: "update lib/py_monorepo_manager"
coauthor_email: ${{ github.event.pull_request.user.login }}@users.noreply.github.com
coauthor_name: ${{ github.event.pull_request.user.login }}

- name: Set up - Get changed files for CHANGELOG.md
if: ${{ !cancelled() }}
id: detect-changed-files
uses: tj-actions/changed-files@v42
with:
files_yaml: |
pyproject_toml:
- lib/py_monorepo_manager/pyproject.toml
python_files:
- lib/py_monorepo_manager/monorepo_manager/**/*.py
- name: Test - Version bump
# This step will fail if there are python files changed but the version in pyproject.toml is not updated
if: (steps.detect-changed-files.outputs.python_files_any_changed == 'true') && (steps.detect-changed-files.outputs.pyproject_toml_any_changed == 'false') && !cancelled()
run: |
echo "No changes in pyproject.toml but there are changes in python files. Please update the version in pyproject.toml if the code changes. Otherwise the automatic update of the carlos device may fail."
exit 1
17 changes: 17 additions & 0 deletions .github/workflows/test-services-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,20 @@ jobs:
message: "update services/api"
coauthor_email: ${{ github.event.pull_request.user.login }}@users.noreply.github.com
coauthor_name: ${{ github.event.pull_request.user.login }}

- name: Set up - Get changed files for CHANGELOG.md
if: ${{ !cancelled() }}
id: detect-changed-files
uses: tj-actions/changed-files@v42
with:
files_yaml: |
pyproject_toml:
- services/api/pyproject.toml
python_files:
- services/api/carlos/**/*.py
- name: Test - Version bump
# This step will fail if there are python files changed but the version in pyproject.toml is not updated
if: (steps.detect-changed-files.outputs.python_files_any_changed == 'true') && (steps.detect-changed-files.outputs.pyproject_toml_any_changed == 'false') && !cancelled()
run: |
echo "No changes in pyproject.toml but there are changes in python files. Please update the version in pyproject.toml if the code changes. Otherwise the automatic update of the carlos device may fail."
exit 1
17 changes: 17 additions & 0 deletions .github/workflows/test-services-device.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,20 @@ jobs:
message: "update services/device"
coauthor_email: ${{ github.event.pull_request.user.login }}@users.noreply.github.com
coauthor_name: ${{ github.event.pull_request.user.login }}

- name: Set up - Get changed files for CHANGELOG.md
if: ${{ !cancelled() }}
id: detect-changed-files
uses: tj-actions/changed-files@v42
with:
files_yaml: |
pyproject_toml:
- services/device/pyproject.toml
python_files:
- services/device/device/**/*.py
- name: Test - Version bump
# This step will fail if there are python files changed but the version in pyproject.toml is not updated
if: (steps.detect-changed-files.outputs.python_files_any_changed == 'true') && (steps.detect-changed-files.outputs.pyproject_toml_any_changed == 'false') && !cancelled()
run: |
echo "No changes in pyproject.toml but there are changes in python files. Please update the version in pyproject.toml if the code changes. Otherwise the automatic update of the carlos device may fail."
exit 1
7 changes: 7 additions & 0 deletions .monorepo_manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ services/api:
language: python
services/device:
language: python
makefile:
config:
- poetry run python -m device.cli config create
config-show:
- poetry run python -m device.cli config show
run:
- poetry run python -m device.cli run
services/frontend:
language: javascript
services/nginx:
Expand Down
Loading
Loading