summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg <supahgreg@users.noreply.github.com>2025-10-11 16:30:42 -0500
committerGitHub <noreply@github.com>2025-10-11 16:30:42 -0500
commit5fb013d268c65f16a535ecc924f1480f07b4f011 (patch)
tree5fb6d8efebb4b664c59180f61e975289bbab9388
parent73e6ade27f9751d3892693be9e11946462e10ed5 (diff)
parent7ad6c3ec641d0b89d072dc9b32202aebb8ecaf8d (diff)
Merge pull request #40 from tt-rss/project-cleanup
Project cleanup, PHPUnit config tweaks
-rw-r--r--.docker/phpdoc/Dockerfile5
-rw-r--r--.docker/phpdoc/redirects.conf2
-rw-r--r--.gitignore2
-rw-r--r--.gitlab-ci.yml266
-rw-r--r--.vscode/launch.json24
-rw-r--r--.vscode/tasks.json46
-rw-r--r--CONTRIBUTING.md8
-rw-r--r--classes/UrlHelper.php10
-rw-r--r--phpunit.xml21
-rwxr-xr-xutils/autoMergeRequest.sh35
-rwxr-xr-xutils/phpstan-watcher.sh23
-rwxr-xr-xutils/phpunit-integration.sh7
-rwxr-xr-xutils/phpunit.sh7
13 files changed, 24 insertions, 432 deletions
diff --git a/.docker/phpdoc/Dockerfile b/.docker/phpdoc/Dockerfile
deleted file mode 100644
index 3d86c300c..000000000
--- a/.docker/phpdoc/Dockerfile
+++ /dev/null
@@ -1,5 +0,0 @@
-ARG PROXY_REGISTRY
-FROM ${PROXY_REGISTRY}nginxinc/nginx-unprivileged:1-alpine
-
-COPY ./phpdoc /usr/share/nginx/html/ttrss-docs
-COPY .docker/phpdoc/redirects.conf /etc/nginx/conf.d/
diff --git a/.docker/phpdoc/redirects.conf b/.docker/phpdoc/redirects.conf
deleted file mode 100644
index 1f1ed3118..000000000
--- a/.docker/phpdoc/redirects.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-port_in_redirect off;
-absolute_redirect off;
diff --git a/.gitignore b/.gitignore
index 9a0c6e9f0..249cb8c71 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,6 @@ Thumbs.db
/lock/*
/.vscode/settings.json
/vendor/**/.git
-/.phpunit.result.cache
+/.phpunit.cache
/.phpstan-tmp
/.tools/
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
deleted file mode 100644
index b7cd4d44a..000000000
--- a/.gitlab-ci.yml
+++ /dev/null
@@ -1,266 +0,0 @@
-stages:
- - lint
- - build
- - push
- - test
- - publish
-
-variables:
- ESLINT_PATHS: js plugins
- REGISTRY_PROJECT: cthulhoo
- IMAGE_TAR_FPM: image-fpm.tar
- IMAGE_TAR_WEB: image-web.tar
-
-include:
- - project: 'ci/ci-templates'
- ref: master
- file: .ci-build-docker-kaniko.yml
- - project: 'ci/ci-templates'
- ref: master
- file: .ci-registry-push.yml
- - project: 'ci/ci-templates'
- ref: master
- file: .ci-lint-common.yml
- - project: 'ci/ci-templates'
- ref: master
- file: .ci-update-helm-imagetag.yml
-
-phpunit:
- extends: .phpunit
- variables:
- PHPUNIT_ARGS: --exclude integration --coverage-filter classes --coverage-filter include
-
-eslint:
- extends: .eslint
-
-phpstan:
- extends: .phpstan
-
-ttrss-fpm-pgsql-static:build:
- extends: .build-docker-kaniko-no-push
- variables:
- DOCKERFILE: ${CI_PROJECT_DIR}/.docker/app/Dockerfile
- IMAGE_TAR: ${IMAGE_TAR_FPM}
-
-ttrss-fpm-pgsql-static:push-commit-only-gitlab:
- extends: .crane-image-registry-push-commit-only-gitlab
- variables:
- IMAGE_TAR: ${IMAGE_TAR_FPM}
- needs:
- - job: ttrss-fpm-pgsql-static:build
-
-ttrss-web-nginx:build:
- extends: .build-docker-kaniko-no-push
- variables:
- DOCKERFILE: ${CI_PROJECT_DIR}/.docker/web-nginx/Dockerfile
- IMAGE_TAR: ${IMAGE_TAR_WEB}
-
-ttrss-web-nginx:push-commit-only-gitlab:
- extends: .crane-image-registry-push-commit-only-gitlab
- variables:
- IMAGE_TAR: ${IMAGE_TAR_WEB}
- needs:
- - job: ttrss-web-nginx:build
-
-phpdoc:build:
- image: ${PHP_IMAGE}
- stage: publish
- rules:
- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- script:
- - php84 /phpDocumentor.phar -d classes -d include -t phpdoc --visibility=public
- artifacts:
- paths:
- - phpdoc
-
-phpdoc:publish:
- extends: .build-docker-kaniko
- stage: publish
- needs:
- - job: phpdoc:build
- rules:
- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $REGISTRY_USER != null && $REGISTRY_PASSWORD != null
- variables:
- DOCKERFILE: ${CI_PROJECT_DIR}/.docker/phpdoc/Dockerfile
- NAME: ttrss-phpdoc
- VERSION: latest
-
-phpunit-integration:
- image: ${PHP_IMAGE}
- variables:
- POSTGRES_DB: postgres
- POSTGRES_USER: postgres
- POSTGRES_PASSWORD: password
- TTRSS_DB_HOST: db
- TTRSS_DB_USER: ${POSTGRES_USER}
- TTRSS_DB_NAME: ${POSTGRES_DB}
- TTRSS_DB_PASS: ${POSTGRES_PASSWORD}
- FF_NETWORK_PER_BUILD: "true"
- APP_WEB_ROOT: /builds/shared-root
- APP_INSTALL_BASE_DIR: ${APP_WEB_ROOT}
- APP_BASE: "/tt-rss"
- APP_FASTCGI_PASS: app:9000 # skip resolver
- AUTO_CREATE_USER: test
- AUTO_CREATE_USER_PASS: 'test'
- AUTO_CREATE_USER_ACCESS_LEVEL: '10'
- AUTO_CREATE_USER_ENABLE_API: 'true'
- APP_URL: http://web-nginx/tt-rss
- API_URL: ${APP_URL}/api/
- HEALTHCHECK_URL: ${APP_URL}/public.php?op=healthcheck
- __URLHELPER_ALLOW_LOOPBACK: 'true'
- services:
- - &svc_db
- name: registry.fakecake.org/docker.io/postgres:15-alpine
- alias: db
- - &svc_app
- name: ${CI_REGISTRY}/${CI_PROJECT_PATH}/ttrss-fpm-pgsql-static:${CI_COMMIT_SHORT_SHA}
- alias: app
- - &svc_web
- name: ${CI_REGISTRY}/${CI_PROJECT_PATH}/ttrss-web-nginx:${CI_COMMIT_SHORT_SHA}
- alias: web-nginx
- rules:
- - if: $CI_COMMIT_BRANCH
- needs:
- - job: ttrss-fpm-pgsql-static:push-commit-only-gitlab
- - job: ttrss-web-nginx:push-commit-only-gitlab
- before_script:
- # wait for everything to start
- - |
- for a in `seq 1 15`; do
- curl -fs ${HEALTHCHECK_URL} && break
- sleep 5
- done
- script:
- - cp tests/integration/feed.xml ${APP_WEB_ROOT}/${APP_BASE}/
- - php84 vendor/bin/phpunit --group integration --do-not-cache-result --log-junit phpunit-report.xml --coverage-cobertura phpunit-coverage.xml --coverage-text --colors=never
- artifacts:
- when: always
- reports:
- junit: phpunit-report.xml
- coverage_report:
- coverage_format: cobertura
- path: phpunit-coverage.xml
- coverage: '/^\s*Lines:\s*\d+.\d+\%/'
-
-phpunit-integration:root-location:
- variables:
- APP_WEB_ROOT: /builds/shared-root/tt-rss
- APP_INSTALL_BASE_DIR: /builds/shared-root
- APP_BASE: ""
- APP_URL: http://web-nginx
- extends: phpunit-integration
-
-selenium:
- extends: phpunit-integration
- image: ${SELENIUM_IMAGE}
- variables:
- SELENIUM_GRID_ENDPOINT: http://selenium:4444/wd/hub
- services:
- - *svc_db
- - *svc_app
- - *svc_web
- - name: registry.fakecake.org/docker.io/selenium/standalone-chrome:4.32.0-20250515
- alias: selenium
- script:
- - |
- for i in `seq 1 10`; do
- echo attempt $i...
- python3 tests/integration/selenium_test.py && break
- sleep 10
- done
- artifacts:
- when: always
- reports:
- junit: selenium-report.xml
-
-ttrss-fpm-pgsql-static:publish:
- stage: publish
- extends: .crane-image-registry-push-master
- variables:
- IMAGE_TAR: ${IMAGE_TAR_FPM}
- needs:
- - job: ttrss-fpm-pgsql-static:build
- - job: phpunit-integration
- - job: selenium
-
-ttrss-fpm-pgsql-static:publish-docker-hub:
- stage: publish
- extends: .crane-image-registry-push-master-docker-hub
- variables:
- IMAGE_TAR: ${IMAGE_TAR_FPM}
- needs:
- - job: ttrss-fpm-pgsql-static:build
- - job: phpunit-integration
- - job: selenium
-
-ttrss-fpm-pgsql-static:publish-gitlab:
- stage: publish
- extends: .crane-image-registry-push-master-gitlab
- variables:
- IMAGE_TAR: ${IMAGE_TAR_FPM}
- needs:
- - job: ttrss-fpm-pgsql-static:build
- - job: phpunit-integration
- - job: selenium
-
-ttrss-web-nginx:publish:
- stage: publish
- extends: .crane-image-registry-push-master
- variables:
- IMAGE_TAR: ${IMAGE_TAR_WEB}
- needs:
- - job: ttrss-web-nginx:build
- - job: phpunit-integration
- - job: selenium
-
-ttrss-web-nginx:publish-docker-hub:
- stage: publish
- extends: .crane-image-registry-push-master-docker-hub
- variables:
- IMAGE_TAR: ${IMAGE_TAR_WEB}
- needs:
- - job: ttrss-web-nginx:build
- - job: phpunit-integration
- - job: selenium
-
-ttrss-web-nginx:publish-gitlab:
- stage: publish
- extends: .crane-image-registry-push-master-gitlab
- variables:
- IMAGE_TAR: ${IMAGE_TAR_WEB}
- needs:
- - job: ttrss-web-nginx:build
- - job: phpunit-integration
- - job: selenium
-
-update-demo:
- stage: publish
- extends: .update-helm-imagetag
- variables:
- CHART_REPO: gitlab.fakecake.org/git/helm-charts/tt-rss.git
- CHART_VALUES: values-demo.yaml
- ACCESS_TOKEN: ${DEMO_HELM_TOKEN}
- rules:
- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $DEMO_HELM_TOKEN != null
-
-update-prod:
- stage: publish
- extends: .update-helm-imagetag
- variables:
- CHART_REPO: gitlab.fakecake.org/git/helm-charts/tt-rss-prod.git
- CHART_VALUES: values-prod.yaml
- ACCESS_TOKEN: ${PROD_HELM_TOKEN}
- rules:
- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $PROD_HELM_TOKEN != null
-
-# https://about.gitlab.com/blog/how-to-automatically-create-a-new-mr-on-gitlab-with-gitlab-ci/
-weblate-integration-auto-mr:
- image: ${INFRA_IMAGE}
- stage: publish
- rules:
- - if: $CI_COMMIT_BRANCH == "weblate-integration" && $AUTO_MR_TOKEN != null
- script:
- - HOST=${CI_PROJECT_URL} CI_PROJECT_ID=${CI_PROJECT_ID}
- CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME}
- GITLAB_USER_ID=${GITLAB_USER_ID}
- PRIVATE_TOKEN=${AUTO_MR_TOKEN} ./utils/autoMergeRequest.sh
diff --git a/.vscode/launch.json b/.vscode/launch.json
deleted file mode 100644
index b3911320d..000000000
--- a/.vscode/launch.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "version": "0.2.0",
- "configurations": [
- {
- "name": "Listen for XDebug",
- "type": "php",
- "request": "launch",
- "pathMappings": {
- "/var/www/html/tt-rss": "${workspaceRoot}",
- },
- "port": 9000
- },
- {
- "name": "Launch Chrome",
- "request": "launch",
- "type": "chrome",
- "pathMapping": {
- "/tt-rss/": "${workspaceFolder}"
- },
- "urlFilter": "*/tt-rss/*",
- "runtimeExecutable": "chrome.exe",
- }
- ]
-}
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
deleted file mode 100644
index bd6a7790f..000000000
--- a/.vscode/tasks.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
- "version": "2.0.0",
- "tasks": [
- {
- "type": "shell",
- "label": "phpstan (watcher)",
- "isBackground": true,
- "problemMatcher": {
- "fileLocation": [
- "relative",
- "${workspaceRoot}"
- ],
- "owner": "phpstan-watcher",
- "pattern": {
- "regexp": "^/app/(.*?):([0-9\\?]*):(.*)$",
- "file": 1,
- "line": 2,
- "message": 3
- },
- "background": {
- "activeOnStart": true,
- "beginsPattern": "Using configuration file",
- "endsPattern": "All done"
- }
- },
- "command": "chmod +x ${workspaceRoot}/utils/phpstan-watcher.sh && ${workspaceRoot}/utils/phpstan-watcher.sh"
- },
- {
- "type": "shell",
- "label": "phpunit",
- "command": "chmod +x ${workspaceRoot}/utils/phpunit.sh && ${workspaceRoot}/utils/phpunit.sh",
- "problemMatcher": []
- },
- {
- "type": "gulp",
- "task": "default",
- "problemMatcher": [],
- "label": "gulp: default",
- "options": {
- "env": {
- "PATH": "${workspaceRoot}/node_modules/.bin:$PATH"
- }
- }
- }
- ]
-}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 03a8303db..2ff6f5788 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,5 +1,3 @@
-Contributions (code, translations, reporting issues, etc.) are welcome.
-
-> [!NOTE]
-> The original tt-rss project handled translations via Weblate.
-> It's yet to be determined how this project will handle things.
+* Contributions (code, translations, reporting issues, etc.) are welcome.
+* Development and issue tracking primarily happens in https://github.com/tt-rss/tt-rss .
+* Help translate tt-rss into your own language using [Weblate](https://hosted.weblate.org/engage/tt-rss/).
diff --git a/classes/UrlHelper.php b/classes/UrlHelper.php
index 7e793be46..53030299d 100644
--- a/classes/UrlHelper.php
+++ b/classes/UrlHelper.php
@@ -223,11 +223,12 @@ class UrlHelper {
}
/**
+ * @todo the multiple-argument approach has been deprecated for a long time, and should be removed
+ * @todo validate options
+ *
* @param array<string, bool|int|string>|string $options
* @return false|string false if something went wrong, otherwise string contents
*/
- // TODO: max_size currently only works for CURL transfers
- // TODO: multiple-argument way is deprecated, first parameter is a hash now
public static function fetch(array|string $options /* previously: 0: $url , 1: $type = false, 2: $login = false, 3: $pass = false,
4: $post_query = false, 5: $timeout = false, 6: $timestamp = 0, 7: $useragent = false, 8: $encoding = false,
9: $auth_type = "basic" */): false|string {
@@ -281,10 +282,9 @@ class UrlHelper {
$http_referrer = $options["http_referrer"] ?? false;
$encoding = $options["encoding"] ?? false;
- $url = ltrim($url, ' ');
- $url = str_replace(' ', '%20', $url);
+ $url = str_replace(' ', '%20', ltrim($url ?? '', ' '));
- Debug::log("[UrlHelper] fetching: $url", Debug::LOG_EXTENDED);
+ Debug::log("[UrlHelper] handling URL: $url", Debug::LOG_EXTENDED);
$url = self::validate($url, true);
diff --git a/phpunit.xml b/phpunit.xml
index 20a3e63ea..c4163695f 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,14 +1,23 @@
-<phpunit
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.0/phpunit.xsd"
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.4/phpunit.xsd"
bootstrap="tests/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
beStrictAboutOutputDuringTests="true"
+ displayDetailsOnPhpunitDeprecations="true"
+ failOnPhpunitDeprecation="true"
failOnRisky="true"
failOnWarning="true">
- <testsuite name="tt-rss">
- <directory>tests</directory>
- </testsuite>
+ <testsuites>
+ <testsuite name="default">
+ <directory>tests</directory>
+ </testsuite>
+ </testsuites>
+ <source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
+ <include>
+ <directory>classes</directory>
+ </include>
+ </source>
</phpunit>
diff --git a/utils/autoMergeRequest.sh b/utils/autoMergeRequest.sh
deleted file mode 100755
index bd33db0ca..000000000
--- a/utils/autoMergeRequest.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env bash
-# Extract the host where the server is running, and add the URL to the APIs
-[[ $HOST =~ ^https?://[^/]+ ]] && HOST="${BASH_REMATCH[0]}/api/v4/projects/"
-
-# Look which is the default branch
-TARGET_BRANCH=`curl --silent "${HOST}${CI_PROJECT_ID}" --header "PRIVATE-TOKEN:${PRIVATE_TOKEN}" | python3 -c "import sys, json; print(json.load(sys.stdin)['default_branch'])"`;
-
-# The description of our new MR, we want to remove the branch after the MR has
-# been closed
-BODY="{
- \"id\": ${CI_PROJECT_ID},
- \"source_branch\": \"${CI_COMMIT_REF_NAME}\",
- \"target_branch\": \"${TARGET_BRANCH}\",
- \"remove_source_branch\": true,
- \"title\": \"WIP: ${CI_COMMIT_REF_NAME}\",
- \"assignee_id\":\"${GITLAB_USER_ID}\"
-}";
-
-# Require a list of all the merge request and take a look if there is already
-# one with the same source branch
-LISTMR=`curl --silent "${HOST}${CI_PROJECT_ID}/merge_requests?state=opened" --header "PRIVATE-TOKEN:${PRIVATE_TOKEN}"`;
-COUNTBRANCHES=`echo ${LISTMR} | grep -o "\"source_branch\":\"${CI_COMMIT_REF_NAME}\"" | wc -l`;
-
-# No MR found, let's create a new one
-if [ ${COUNTBRANCHES} -eq "0" ]; then
- curl -X POST "${HOST}${CI_PROJECT_ID}/merge_requests" \
- --header "PRIVATE-TOKEN:${PRIVATE_TOKEN}" \
- --header "Content-Type: application/json" \
- --data "${BODY}";
-
- echo "Opened a new merge request: WIP: ${CI_COMMIT_REF_NAME} and assigned to you";
- exit;
-fi
-
-echo "No new merge request opened";
diff --git a/utils/phpstan-watcher.sh b/utils/phpstan-watcher.sh
deleted file mode 100755
index 84554e68d..000000000
--- a/utils/phpstan-watcher.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-export PHP_IMAGE=registry.fakecake.org/infra/php8.4-alpine3.22
-
-docker run --rm -v $(pwd):/app -v /tmp/phpstan:/tmp/phpstan \
- --workdir /app ${PHP_IMAGE} \
- php84 -d memory_limit=-1 ./vendor/bin/phpstan --memory-limit=2G --error-format=raw analyze .
-
-echo All done, RC=$?.
-
-while true; do
- inotifywait . -e close_write -r -t 300 | grep -q .php && \
- (
- MODIFIED=$(git ls-files -m | grep .php)
-
- docker run --rm -v $(pwd):/app -v /tmp/phpstan:/tmp/phpstan \
- --workdir /app ${PHP_IMAGE} \
- php84 -d memory_limit=-1 ./vendor/bin/phpstan --memory-limit=2G --error-format=raw analyze .
-
- echo All done, RC=$?.
- )
- sleep 1
-done
diff --git a/utils/phpunit-integration.sh b/utils/phpunit-integration.sh
deleted file mode 100755
index 7ce458cf8..000000000
--- a/utils/phpunit-integration.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-export PHP_IMAGE=registry.fakecake.org/infra/php8.3-alpine3.20
-
-docker run --rm -v $(pwd):/app -e API_URL=${API_URL} \
- --workdir /app ${PHP_IMAGE} \
- php83 -d memory_limit=-1 ./vendor/bin/phpunit --group integration
diff --git a/utils/phpunit.sh b/utils/phpunit.sh
deleted file mode 100755
index 667ff92f5..000000000
--- a/utils/phpunit.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-export PHP_IMAGE=registry.fakecake.org/infra/php8.3-alpine3.20
-
-docker run --rm -v $(pwd):/app \
- --workdir /app ${PHP_IMAGE} \
- php83 -d memory_limit=-1 ./vendor/bin/phpunit --exclude integration