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

Deploy actions updates #43

Merged
merged 14 commits into from
Aug 16, 2023
107 changes: 56 additions & 51 deletions .github/workflows/tests-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,25 @@ jobs:
run: |
php -S 127.0.0.1:8080 &
./occ app_ecosystem_v2:daemon:register docker_local_sock Docker docker-install unix-socket /var/run/docker.sock http://127.0.0.1:8080/index.php
./occ app_ecosystem_v2:app:deploy app_python_skeleton docker_local_sock \
--info-xml https://raw.githubusercontent.com/cloud-py-api/py_app_v2-skeleton/main/appinfo/info.xml
./occ app_ecosystem_v2:app:register app_python_skeleton docker_local_sock
./occ app_ecosystem_v2:app:enable app_python_skeleton
./occ app_ecosystem_v2:app:disable app_python_skeleton
./occ app_ecosystem_v2:app:unregister app_python_skeleton --silent
./occ app_ecosystem_v2:app:deploy skeleton docker_local_sock \
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
./occ app_ecosystem_v2:app:register skeleton docker_local_sock \
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
./occ app_ecosystem_v2:app:enable skeleton
./occ app_ecosystem_v2:app:disable skeleton
./occ app_ecosystem_v2:app:unregister skeleton --silent
./occ app_ecosystem_v2:daemon:unregister docker_local_sock

- name: Check logs
run: |
grep -q 'Hello from app_python_skeleton :)' data/nextcloud.log || error
grep -q 'Bye bye from app_python_skeleton :(' data/nextcloud.log || error
grep -q 'Hello from skeleton :)' data/nextcloud.log || error
grep -q 'Bye bye from skeleton :(' data/nextcloud.log || error

- name: Save container ingo & logs
if: always()
run: |
docker inspect app_python_skeleton | json_pp > container.json
docker logs app_python_skeleton > container.log 2>&1
docker inspect skeleton | json_pp > container.json
docker logs skeleton > container.log 2>&1

- name: Upload Container info
if: always()
Expand Down Expand Up @@ -168,27 +169,28 @@ jobs:
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:daemon:register \
docker_local_sock Docker docker-install unix-socket /var/run/docker.sock http://nextcloud/index.php \
--net=master_bridge
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:deploy app_python_skeleton docker_local_sock \
--info-xml https://raw.githubusercontent.com/cloud-py-api/py_app_v2-skeleton/main/appinfo/info.xml
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:register app_python_skeleton docker_local_sock
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:enable app_python_skeleton
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:disable app_python_skeleton
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:unregister app_python_skeleton --silent
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:deploy skeleton docker_local_sock \
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:register skeleton docker_local_sock \
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:enable skeleton
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:disable skeleton
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:unregister skeleton --silent
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:daemon:unregister docker_local_sock

- name: Copy NC log to host
run: docker cp nextcloud:/var/www/html/data/nextcloud.log nextcloud.log

- name: Check logs
run: |
grep -q 'Hello from app_python_skeleton :)' nextcloud.log || error
grep -q 'Bye bye from app_python_skeleton :(' nextcloud.log || error
grep -q 'Hello from skeleton :)' nextcloud.log || error
grep -q 'Bye bye from skeleton :(' nextcloud.log || error

- name: Save container ingo & logs
if: always()
run: |
docker inspect app_python_skeleton | json_pp > container.json
docker logs app_python_skeleton > container.log 2>&1
docker inspect skeleton | json_pp > container.json
docker logs skeleton > container.log 2>&1

- name: Upload Container info
if: always()
Expand Down Expand Up @@ -245,27 +247,28 @@ jobs:
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:daemon:register \
docker_by_port Docker docker-install https host.docker.internal:8443 http://nextcloud/index.php \
--net=master_bridge --ssl_cert /client/cert.pem --ssl_key /client/key.pem
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:deploy app_python_skeleton docker_by_port \
--info-xml https://raw.githubusercontent.com/cloud-py-api/py_app_v2-skeleton/main/appinfo/info.xml
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:register app_python_skeleton docker_by_port
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:enable app_python_skeleton
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:disable app_python_skeleton
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:unregister app_python_skeleton --silent
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:deploy skeleton docker_by_port \
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:register skeleton docker_by_port \
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:enable skeleton
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:disable skeleton
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:unregister skeleton --silent
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:daemon:unregister docker_by_port

- name: Copy NC log to host
run: docker cp nextcloud:/var/www/html/data/nextcloud.log nextcloud.log

- name: Check logs
run: |
grep -q 'Hello from app_python_skeleton :)' nextcloud.log || error
grep -q 'Bye bye from app_python_skeleton :(' nextcloud.log || error
grep -q 'Hello from skeleton :)' nextcloud.log || error
grep -q 'Bye bye from skeleton :(' nextcloud.log || error

- name: Save container ingo & logs
if: always()
run: |
docker inspect app_python_skeleton | json_pp > container.json
docker logs app_python_skeleton > container.log 2>&1
docker inspect skeleton | json_pp > container.json
docker logs skeleton > container.log 2>&1

- name: Upload Container info
if: always()
Expand Down Expand Up @@ -321,27 +324,28 @@ jobs:
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:daemon:register \
docker_by_port Docker docker-install https host.docker.internal:8443 http://localhost:8080/index.php \
--net=host --hostname=host.docker.internal --ssl_cert /client/cert.pem --ssl_key /client/key.pem
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:deploy app_python_skeleton docker_by_port \
--info-xml https://raw.githubusercontent.com/cloud-py-api/py_app_v2-skeleton/main/appinfo/info.xml
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:register app_python_skeleton docker_by_port
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:enable app_python_skeleton
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:disable app_python_skeleton
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:unregister app_python_skeleton --silent
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:deploy skeleton docker_by_port \
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:register skeleton docker_by_port \
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:enable skeleton
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:disable skeleton
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:app:unregister skeleton --silent
docker exec nextcloud sudo -u www-data php occ app_ecosystem_v2:daemon:unregister docker_by_port

- name: Copy NC log to host
run: docker cp nextcloud:/var/www/html/data/nextcloud.log nextcloud.log

- name: Check logs
run: |
grep -q 'Hello from app_python_skeleton :)' nextcloud.log || error
grep -q 'Bye bye from app_python_skeleton :(' nextcloud.log || error
grep -q 'Hello from skeleton :)' nextcloud.log || error
grep -q 'Bye bye from skeleton :(' nextcloud.log || error

- name: Save container ingo & logs
if: always()
run: |
docker inspect app_python_skeleton | json_pp > container.json
docker logs app_python_skeleton > container.log 2>&1
docker inspect skeleton | json_pp > container.json
docker logs skeleton > container.log 2>&1

- name: Upload Container info
if: always()
Expand Down Expand Up @@ -463,24 +467,25 @@ jobs:
run: |
php -S 127.0.0.1:8080 &
./occ app_ecosystem_v2:daemon:register docker_local_sock Docker docker-install unix-socket /var/run/docker.sock http://127.0.0.1:8080/index.php
./occ app_ecosystem_v2:app:deploy app_python_skeleton docker_local_sock \
--info-xml https://raw.githubusercontent.com/cloud-py-api/py_app_v2-skeleton/main/appinfo/info.xml
./occ app_ecosystem_v2:app:register app_python_skeleton docker_local_sock
./occ app_ecosystem_v2:app:enable app_python_skeleton
./occ app_ecosystem_v2:app:disable app_python_skeleton
./occ app_ecosystem_v2:app:unregister app_python_skeleton --silent
./occ app_ecosystem_v2:app:deploy skeleton docker_local_sock \
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
./occ app_ecosystem_v2:app:register skeleton docker_local_sock \
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
./occ app_ecosystem_v2:app:enable skeleton
./occ app_ecosystem_v2:app:disable skeleton
./occ app_ecosystem_v2:app:unregister skeleton --silent
./occ app_ecosystem_v2:daemon:unregister docker_local_sock

- name: Check logs
run: |
grep -q 'Hello from app_python_skeleton :)' data/nextcloud.log || error
grep -q 'Bye bye from app_python_skeleton :(' data/nextcloud.log || error
grep -q 'Hello from skeleton :)' data/nextcloud.log || error
grep -q 'Bye bye from skeleton :(' data/nextcloud.log || error

- name: Save container ingo & logs
if: always()
run: |
docker inspect app_python_skeleton | json_pp > container.json
docker logs app_python_skeleton > container.log 2>&1
docker inspect skeleton | json_pp > container.json
docker logs skeleton > container.log 2>&1

- name: Check redis keys
run: |
Expand Down Expand Up @@ -510,7 +515,7 @@ jobs:
path: data/nextcloud.log
if-no-files-found: warn

tests-deploy-uccess:
tests-deploy-success:
permissions:
contents: none
runs-on: ubuntu-22.04
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-special.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
sleep 5s
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0
php occ app_ecosystem_v2:app:register nc_py_api manual_install --json-info \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"port\":$APP_PORT,\"protocol\":\"http\",\"system_app\":1}" \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"port\":$APP_PORT,\"scopes\":{\"required\":[2, 10, 11],\"optional\":[30, 31, 32, 33]},\"protocol\":\"http\",\"system_app\":1}" \
-e --force-scopes
kill -15 $(cat /tmp/_install.pid)
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
sleep 5s
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0
php occ app_ecosystem_v2:app:register nc_py_api manual_install --json-info \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"port\":$APP_PORT,\"protocol\":\"http\",\"system_app\":1}" \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"port\":$APP_PORT,\"scopes\":{\"required\":[2, 10, 11],\"optional\":[30, 31, 32, 33]},\"protocol\":\"http\",\"system_app\":1}" \
-e --force-scopes
kill -15 $(cat /tmp/_install.pid)
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
Expand Down
1 change: 1 addition & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<command>OCA\AppEcosystemV2\Command\ExApp\Deploy</command>
<command>OCA\AppEcosystemV2\Command\ExApp\Register</command>
<command>OCA\AppEcosystemV2\Command\ExApp\Unregister</command>
<command>OCA\AppEcosystemV2\Command\ExApp\Update</command>
<command>OCA\AppEcosystemV2\Command\ExApp\Enable</command>
<command>OCA\AppEcosystemV2\Command\ExApp\Disable</command>
<command>OCA\AppEcosystemV2\Command\ExApp\ListExApps</command>
Expand Down
31 changes: 31 additions & 0 deletions docs/api-scopes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
==========
Api Scopes
==========

One of the primary advantages inherent to the AppEcosystem is its clear-cut categorization of the required API groups
essential for the application's operation.
Equally significant is the provision of optional API groups, enabling the application to execute extra functions that
enhance its capabilities, though not obligatory for its core functionality. An example of such a function is sending notifications.

During installation, the Nextcloud administrator retains the authority to regulate the application's access
to any of these optional API function groups.

Both ``optional`` and ``required`` API groups employed by the application are explicitly outlined within
the **info.xml** file. Upon the release of a new application version, adjustments to the API groups can be made.
This grants the flexibility to introduce new API groups or remove outdated ones.

For instance, if the initial version of your application did not necessitate notifications,
but a subsequent version does, you can effortlessly specify the new API groups in the **info.xml** file.

The following API groups are currently supported:

* ``2`` SYSTEM
* ``10`` FILES
* ``11`` FILES_SHARING
* ``30`` USER_INFO
* ``31`` USER_STATUS
* ``32`` NOTIFICATIONS
* ``33`` WEATHER_STATUS

These groups are identified numerically, as opposed to using names. As time progresses,
the list will steadily expand, comprehensively encompassing all potential APIs provided by Nextcloud.
8 changes: 8 additions & 0 deletions docs/deploy/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ It has the same structure as Nextcloud appinfo/info.xml file, but with some addi
<image>cloud-py-api/py_app_v2-skeleton</image>
<image-tag>latest</image-tag>
</docker-install>
<scopes>
<required>
<value>2</value>
</required>
<optional>
<value>32</value>
</optional>
</scopes>
<protocol>http</protocol>
<system>0</system>
</ex-app>
Expand Down
5 changes: 3 additions & 2 deletions docs/development/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ and actually forwarded to the container:
Dev changes to Nextcloud server
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The only changes to Nextcloud server are in ``base.php`` file.
Until these changes not implemented in server, they can be applied by patch (``base_php.patch`` in project root directory).
The only changes to Nextcloud server are in ``base.php`` file,
required only for Nextcloud 26, as **Nextcloud 27.1+** already comes with these changes.

.. code-block:: php

Expand All @@ -71,3 +71,4 @@ And down below ``tryAppEcosystemV2Login`` method is added:
return $appEcosystemV2Service->validateExAppRequestToNC($request);
}

.. note:: Patch itself are in the project root directory with ``base_php.patch`` name.
6 changes: 3 additions & 3 deletions docs/definitions.rst → docs/glossary.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
===========
Definitions
===========
========
Glossary
========

AppEcosystemV2 brings out the following terms frequently used in the code:

Expand Down
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Welcome to the amazing docs that we will write for AppEcosystemV2!
.. toctree::
:maxdepth: 2

definitions.rst
api-scopes.rst
glossary.rst
development/index.rst
deploy/index.rst
authentication
Expand Down
3 changes: 3 additions & 0 deletions lib/Command/Daemon/RegisterDaemon.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ protected function configure() {
$this->addOption('ssl_cert', null, InputOption::VALUE_REQUIRED, 'SSL cert for daemon connection (local absolute path)');
$this->addOption('ssl_cert_password', null, InputOption::VALUE_REQUIRED, 'SSL cert password for daemon connection(optional)');

$this->addOption('gpu', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Docker containers gpu device mapping (will be forwarded to all created containers)', []);

$this->addUsage('local_docker "Docker local" "docker-install" "unix-socket" "/var/run/docker.sock" "http://nextcloud.local" --net=nextcloud');
}

Expand All @@ -61,6 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'ssl_key_password' => $input->getOption('ssl_key_password'),
'ssl_cert' => $input->getOption('ssl_cert'),
'ssl_cert_password' => $input->getOption('ssl_cert_password'),
'gpus' => $input->getOption('gpu'),
];

$daemonConfig = $this->daemonConfigService->registerDaemonConfig([
Expand Down
Loading