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

makefile update #34

Merged
merged 3 commits into from
Jul 14, 2023
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
2 changes: 1 addition & 1 deletion .github/.codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
codecov:
notify:
after_n_builds: 3
after_n_builds: 4

comment:
require_changes: true
Expand Down
112 changes: 105 additions & 7 deletions .github/workflows/analysis-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
workflow_dispatch:

env:
NEXTCLOUD_URL: "http://localhost:8080/index.php"
NEXTCLOUD_URL: "http://localhost:8080"
APP_ID: "nc_py_api"
APP_PORT: 9009
APP_VERSION: "1.0.0"
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
mkdir data
php occ maintenance:install --verbose --database=mysql --database-name=nextcloud \
--database-host=127.0.0.1 --database-user=root --database-pass=rootpassword \
--admin-user admin --admin-pass adminpassword
--admin-user admin --admin-pass ${{ env.NC_AUTH_PASS }}
php occ config:system:set loglevel --value=1 --type=integer
php occ config:system:set debug --value=true --type=boolean
php occ config:system:set allow_local_remote_servers --value true
Expand All @@ -120,13 +120,11 @@ jobs:

- name: Checkout AppEcosystemV2
uses: actions/checkout@v3
if: ${{ !startsWith(matrix.nextcloud, '26.') }}
with:
path: apps/app_ecosystem_v2
repository: cloud-py-api/app_ecosystem_v2

- name: Install AppEcosystemV2
if: ${{ !startsWith(matrix.nextcloud, '26.') }}
run: |
patch -p 1 -i apps/app_ecosystem_v2/base_php.patch
php occ app:enable app_ecosystem_v2
Expand Down Expand Up @@ -229,7 +227,7 @@ jobs:
mkdir data
php occ maintenance:install --verbose --database=pgsql --database-name=${{ env.NC_dbname }} \
--database-host=127.0.0.1 --database-user=root --database-pass=rootpassword \
--admin-user admin --admin-pass adminpassword
--admin-user admin --admin-pass ${{ env.NC_AUTH_PASS }}
php occ config:system:set loglevel --value=1
php occ config:system:set debug --value=true --type=boolean
php occ config:system:set allow_local_remote_servers --value true
Expand Down Expand Up @@ -350,7 +348,7 @@ jobs:
mkdir data
php occ maintenance:install --verbose --database=oci --database-name=XE \
--database-host=127.0.0.1 --database-port=1521 --database-user=useroracle --database-pass=userpassword \
--admin-user admin --admin-pass admin
--admin-user admin --admin-pass ${{ env.NC_AUTH_PASS }}
php occ config:system:set loglevel --value=1 --type=integer
php occ config:system:set debug --value=true --type=boolean
php occ config:system:set allow_local_remote_servers --value true
Expand Down Expand Up @@ -460,7 +458,7 @@ jobs:
mkdir data
./occ maintenance:install --verbose --database=mysql --database-name=nextcloud \
--database-host=127.0.0.1 --database-user=root --database-pass=rootpassword \
--admin-user admin --admin-pass adminpassword
--admin-user admin --admin-pass ${{ env.NC_AUTH_PASS }}
./occ config:system:set loglevel --value=0 --type=integer
./occ config:system:set debug --value=true --type=boolean
./occ config:system:set allow_local_remote_servers --value true
Expand Down Expand Up @@ -523,3 +521,103 @@ jobs:
name: nc_log_maria_latest
path: data/nextcloud.log
if-no-files-found: warn

tests-sqlite:
needs: [analysis]
runs-on: ubuntu-22.04
name: ${{ matrix.nextcloud }} • 🐘8.1 • 🐍3.11 • SQLite
strategy:
fail-fast: false
matrix:
nextcloud: [ 'stable26', 'stable27' ]
env:
NEXTCLOUD_URL: "http://localhost:8080/index.php"

steps:
- name: Set up php
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd, curl

- uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Checkout server
uses: actions/checkout@v3
with:
submodules: true
repository: nextcloud/server
ref: ${{ matrix.nextcloud }}

- name: Set up & run Nextcloud
env:
DB_PORT: 4444
run: |
mkdir data
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 \
--database-port=$DB_PORT --database-user=root --database-pass=rootpassword \
--admin-user admin --admin-pass ${{ env.NC_AUTH_PASS }}
./occ config:system:set loglevel --value=0 --type=integer
./occ config:system:set debug --value=true --type=boolean
./occ config:system:set allow_local_remote_servers --value true
php -S localhost:8080 &

- name: Checkout NcPyApi
uses: actions/checkout@v3
with:
path: nc_py_api

- name: Install NcPyApi
working-directory: nc_py_api
run: python3 -m pip -v install ".[dev]"

- name: Checkout AppEcosystemV2
uses: actions/checkout@v3
with:
path: apps/app_ecosystem_v2
repository: cloud-py-api/app_ecosystem_v2

- name: Install AppEcosystemV2
run: |
patch -p 1 -i apps/app_ecosystem_v2/base_php.patch
php occ app:enable app_ecosystem_v2
cd nc_py_api
coverage run --data-file=.coverage.ci_install tests/_install.py &
echo $! > /tmp/_install.pid
cd ..
sleep 5s
php occ app_ecosystem_v2:daemon:register simulate_docker Docker docker-install unix-socket 0 0
php occ app_ecosystem_v2:app:register \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"simulate_docker\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"port\":$APP_PORT,\"system_app\":1}" \
-e --force-scopes
kill -15 $(cat /tmp/_install.pid)
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null

- name: Generate coverage report
working-directory: nc_py_api
run: coverage run --data-file=.coverage.ci -m pytest && coverage combine && coverage xml && coverage html

- name: HTML coverage to artifacts
uses: actions/upload-artifact@v3
with:
name: coverage_sqlite_${{ matrix.nextcloud }}
path: nc_py_api/htmlcov
if-no-files-found: error

- name: Upload report to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: nc_py_api/coverage.xml
fail_ci_if_error: true
verbose: true

- name: Upload NC logs
if: always()
uses: actions/upload-artifact@v3
with:
name: nc_log_sqlite_${{ matrix.nextcloud }}
path: data/nextcloud.log
if-no-files-found: warn
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ prune benchmarks
prune docker
prune docs
prune examples
prune scripts
prune tests
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,19 @@ docs html:
.PHONY: help
help:
@echo "Welcome to NC_PY_API development. Please use \`make <target>\` where <target> is one of"
@echo " doc make HTML docs"
@echo " html make HTML docs"
@echo " docs make HTML docs"
@echo " html make HTML docs"
@echo " "
@echo " Next commands are only for dev environment with nextcloud-docker-dev!"
@echo " register register nc_py_api in host as an application(requires activated venv)"
@echo " this should run from the host you are developing on, not in a container with Nextcloud"
@echo " and only last Nextcloud version(28) is supported, for other versions tests runs on GitHub"
@echo " tests run nc_py_api tests to check that registration was successful"

.PHONY: register
register:
/bin/sh scripts/dev_register.sh

.PHONY: tests
tests:
python3 -m pytest
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Docs](https://github.com/cloud-py-api/nc_py_api/actions/workflows/docs.yml/badge.svg)](https://cloud-py-api.github.io/nc_py_api/)
[![codecov](https://codecov.io/github/cloud-py-api/nc_py_api/branch/main/graph/badge.svg?token=C91PL3FYDQ)](https://codecov.io/github/cloud-py-api/nc_py_api)

![NextcloudVersion](https://img.shields.io/badge/Nextcloud-26%20%7C%2027%20%7C%2028-blue)
![PythonVersion](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)
![impl](https://img.shields.io/pypi/implementation/nc_py_api)
![pypi](https://img.shields.io/pypi/v/nc_py_api.svg)
Expand Down
5 changes: 2 additions & 3 deletions nc_py_api/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ class ServerVersion(TypedDict):

@dataclass
class BasicConfig:
full_nc_url: str
endpoint: str
dav_endpoint: str
dav_url_suffix: str

def __init__(self, **kwargs):
self.full_nc_url = self._get_value("nextcloud_url", **kwargs)
self.endpoint = self.full_nc_url.removesuffix("/index.php").removesuffix("/")
full_nc_url = self._get_value("nextcloud_url", **kwargs)
self.endpoint = full_nc_url.removesuffix("/index.php").removesuffix("/")
self.dav_url_suffix = self._get_value("dav_url_suffix", raise_not_found=False, **kwargs)
if not self.dav_url_suffix:
self.dav_url_suffix = options.DAV_URL_SUFFIX
Expand Down
17 changes: 17 additions & 0 deletions scripts/dev_register.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

echo "creating fake deploy daemon for nextcloud 28 container"
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:daemon:unregister simulate_docker || true
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:daemon:register \
simulate_docker FakeDocker docker-install unix-socket 0 0
echo "registering nc_py_api as an app for nextcloud 28 container"
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:unregister nc_py_api --silent || true
NEXTCLOUD_URL="http://nextcloud.local" APP_PORT=9009 APP_ID="nc_py_api" APP_SECRET="12345" APP_VERSION="1.0.0" \
python3 tests/_install.py &
echo $! > /tmp/_install.pid
sleep 7
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:register \
"{\"appid\":\"nc_py_api\",\"name\":\"NC_Py_API\",\"daemon_config_name\":\"simulate_docker\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"host\":\"host.docker.internal\",\"port\":9009,\"system_app\":1}" \
-e --force-scopes
cat /tmp/_install.pid
kill -15 "$(cat /tmp/_install.pid)"
6 changes: 2 additions & 4 deletions tests/gfixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
from nc_py_api import NextcloudApp, Nextcloud


secret = "tC6vkwPhcppjMykD1r0n9NlI95uJMBYjs5blpIcA1PAdoPDmc5qoAjaBAkyocZ6E" \
"X1T8Pi+T5papEolTLxz3fJSPS8ffC4204YmggxPsbJdCkXHWNPHKWS9B+vTj2SIV"
if not environ.get("CI", False): # For local tests
environ["NC_AUTH_USER"] = "admin"
environ["NC_AUTH_PASS"] = "admin" # "MrtGY-KfY24-iiDyg-cr4n4-GLsNZ"
environ["NEXTCLOUD_URL"] = "http://nextcloud.local/index.php"
environ["NEXTCLOUD_URL"] = "http://nextcloud.local"
environ["APP_ID"] = "nc_py_api"
environ["APP_VERSION"] = "1.0.0"
environ["APP_SECRET"] = secret
environ["APP_SECRET"] = "12345"

if environ.get("SKIP_NC_WO_AE", False):
NC = None
Expand Down