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

Caching adjustments. Refactoring, use service layers with caching #14

Merged
merged 29 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f08aa4d
Caching adjustments. Refactoring, use service layer with cache for ot…
andrey18106 Jul 17, 2023
aea71cd
fix missing return
andrey18106 Jul 18, 2023
79adf39
Added lint, psalm, fixes. last_response_time->last_check_time
andrey18106 Jul 18, 2023
2bf9acc
updated jobs matrix
andrey18106 Jul 18, 2023
d73fac6
ci fixes
andrey18106 Jul 18, 2023
e044ad0
ci fixes
andrey18106 Jul 18, 2023
a0f176a
ci fixes
andrey18106 Jul 18, 2023
3c7a941
exApp caching fixes
andrey18106 Jul 18, 2023
f502e36
delete query fixes
andrey18106 Jul 18, 2023
9d74779
Added container healthcheck. Updated daemon list command
andrey18106 Jul 19, 2023
b66aa93
Minor caches fixes
andrey18106 Jul 19, 2023
5be6b59
Added job with redis
andrey18106 Jul 19, 2023
62bf6f5
Added php redis module
andrey18106 Jul 19, 2023
c708477
fix redis config setup
andrey18106 Jul 19, 2023
e64b61e
fix redis service host
andrey18106 Jul 19, 2023
8dc4793
fix check of redis keys
andrey18106 Jul 19, 2023
af8e5d8
php-cs fixes
andrey18106 Jul 19, 2023
1ba6df2
fix redis service name
andrey18106 Jul 19, 2023
ac6d4a5
last_response_time -> last_check_time (nc_py_api getExApps)
andrey18106 Jul 20, 2023
b0f3adb
fix xml file loading
andrey18106 Jul 20, 2023
8bf9d4d
Refactoring. Removed unused parts
andrey18106 Jul 20, 2023
cb64c63
minor fixes
andrey18106 Jul 20, 2023
bf3a311
file action fix
andrey18106 Jul 21, 2023
0233af6
cs fix
andrey18106 Jul 21, 2023
125acee
fix unregister file action
andrey18106 Jul 21, 2023
cd0cdf8
added return not_found status
andrey18106 Jul 21, 2023
f2ef0fd
fix psalm
andrey18106 Jul 21, 2023
723f08d
fix ocs not_found
andrey18106 Jul 21, 2023
1337107
to return `OCSNotFoundException` in `unregisterFileActionMenu`
bigcat88 Jul 22, 2023
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
140 changes: 140 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Lint

on:
pull_request:
paths:
- 'appinfo/*.*'
- 'lib/**'
# - 'src/**'
- 'templates/*.*'
push:
paths:
- 'appinfo/*.*'
- 'lib/*.*'
# - 'src/*.*'
- 'templates/*.*'
workflow_dispatch:

jobs:
xml-lint:
runs-on: ubuntu-22.04
name: info.xml lint

steps:
- uses: actions/checkout@v3

- name: Download xml appinfo schema
run: wget https://raw.githubusercontent.com/nextcloud/appstore/master/nextcloudappstore/api/v1/release/info.xsd

- name: Lint appinfo/info.xml
uses: ChristophWurst/[email protected]
with:
xml-file: ./appinfo/info.xml
xml-schema-file: ./info.xsd

php-lint:
runs-on: ubuntu-22.04
name: php-lint
strategy:
matrix:
php-versions: ["8.1"]

steps:
- uses: actions/checkout@v3

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none

- name: Lint
run: composer run lint

php-cs:
runs-on: ubuntu-22.04
name: php-cs
strategy:
matrix:
php-versions: ["8.1"]

steps:
- uses: actions/checkout@v3

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none

- name: Install dependencies
run: composer i

- name: Lint
run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )

php-psalm-analysis:
runs-on: ubuntu-22.04
strategy:
matrix:
php-versions: ["8.1"]
name: php-psalm-analysis

steps:
- uses: actions/checkout@v3
- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none

- name: Install dependencies
run: composer i

- name: Run coding standards check
run: composer run psalm

php-security-analysis:
runs-on: ubuntu-22.04
name: security analysis
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Psalm
uses: docker://vimeo/psalm-github-actions:4.30.0
with:
security_analysis: true
composer_ignore_platform_reqs: false
report_file: results.sarif

- name: Upload Security Analysis results to GitHub
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif

# js-eslint:
# runs-on: ubuntu-22.04
# name: eslint
#
# steps:
# - uses: actions/checkout@v3
# - name: Install dependencies
# run: npm ci
#
# - name: ESLint
# run: npm run lint

# stylelint:
# runs-on: ubuntu-22.04
#
# name: stylelint
#
# steps:
# - uses: actions/checkout@v3
# - name: Install dependencies
# run: npm ci
#
# - name: Lint
# run: npm run stylelint
144 changes: 144 additions & 0 deletions .github/workflows/tests-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -361,3 +361,147 @@ jobs:
name: nc_docker_app_host_by_hostname_nextcloud.log
path: nextcloud.log
if-no-files-found: warn

nc-host-app-docker-redis:
runs-on: ubuntu-22.04
name: NC In Host(Redis) • ${{ matrix.server-version }} • 🐘${{ matrix.php-version }}
strategy:
fail-fast: false
matrix:
php-version: [ '8.1' ]
server-version: [ 'stable27' ]
include:
- server-version: "master"
php-version: "8.2"

services:
postgres:
image: ghcr.io/nextcloud/continuous-integration-postgres-14:latest
ports:
- 4444:5432/tcp
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: rootpassword
POSTGRES_DB: nextcloud
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--name redis
ports:
- 6379:6379

steps:
- name: Set app env
run: echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV

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

- name: Checkout AppEcosystemV2
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
path: apps/${{ env.APP_NAME }}

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@4bd44f22a98a19e0950cbad5f31095157cc9621b # v2
with:
php-version: ${{ matrix.php-versions }}
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, pgsql, pdo_pgsql, redis
coverage: none
ini-file: development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check composer file existence
id: check_composer
uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
with:
files: apps/${{ env.APP_NAME }}/composer.json

- name: Set up dependencies
if: steps.check_composer.outputs.files_exists == 'true'
working-directory: apps/${{ env.APP_NAME }}
run: composer i

- name: Set up Nextcloud
env:
DB_PORT: 4444
REDIS_HOST: localhost
REDIS_PORT: 6379
run: |
mkdir data
./occ maintenance:install --verbose --database=pgsql --database-name=nextcloud --database-host=127.0.0.1 \
--database-port=$DB_PORT --database-user=root --database-pass=rootpassword \
--admin-user admin --admin-pass admin
./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

./occ config:system:set memcache.local --value "\\OC\\Memcache\\Redis"
./occ config:system:set memcache.distributed --value "\\OC\\Memcache\\Redis"
./occ config:system:set memcache.locking --value "\\OC\\Memcache\\Redis"
./occ config:system:set redis host --value ${{ env.REDIS_HOST }}
./occ config:system:set redis port --value ${{ env.REDIS_PORT }}

./occ app:enable --force ${{ env.APP_NAME }}
patch -p 1 -i apps/${{ env.APP_NAME }}/base_php.patch

- name: Test deploy
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: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

- 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

- name: Check redis keys
run: |
docker exec redis redis-cli keys '*app_ecosystem_v2*' || error

- name: Upload Container info
if: always()
uses: actions/upload-artifact@v3
with:
name: nc_host_app_docker_redis_${{ matrix.server-version }}_${{ matrix.php-version }}_container.json
path: container.json
if-no-files-found: warn

- name: Upload Container logs
if: always()
uses: actions/upload-artifact@v3
with:
name: nc_host_app_docker_redis_${{ matrix.server-version }}_${{ matrix.php-version }}_container.log
path: container.log
if-no-files-found: warn

- name: Upload NC logs
if: always()
uses: actions/upload-artifact@v3
with:
name: nc_host_app_docker_redis_${{ matrix.server-version }}_${{ matrix.php-version }}_nextcloud.log
path: data/nextcloud.log
if-no-files-found: warn
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ node_modules
vendor
_build
certs
.php-cs-fixer.cache
18 changes: 18 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

require_once './vendor/autoload.php';

use Nextcloud\CodingStandard\Config;

$config = new Config();
$config
->getFinder()
->ignoreVCSIgnored(true)
->notPath('build')
->notPath('l10n')
->notPath('src')
->notPath('vendor')
->in(__DIR__);
return $config;
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dock-sock27:
dock-sock26:
@echo "creating daemon for nextcloud 'stable26' container"
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:daemon:unregister docker_dev || true
docker exec master-stable6-1 sudo -u www-data php occ app_ecosystem_v2:daemon:register \
docker exec master-stable26-1 sudo -u www-data php occ app_ecosystem_v2:daemon:register \
docker_dev Docker docker-install unix-socket /var/run/docker.sock http://stable26/index.php --net=master_default

.PHONY: dock2port
Expand Down
Loading