diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 4725eb32a..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,54 +0,0 @@ -# PHP CircleCI 2.0 configuration file -# -# Check https://circleci.com/docs/2.0/language-php/ for more details -# -version: 2 -jobs: - build: - docker: - # Specify the version you desire here - - image: cimg/php:8.2.5 - - # Specify service dependencies here if necessary - # CircleCI maintains a library of pre-built images - # documented at https://circleci.com/docs/2.0/circleci-images/ - # Using the RAM variation mitigates I/O contention - # for database intensive operations. - # - image: circleci/mysql:5.7-ram - # - # - image: redis:2.8.19 - - steps: - - checkout - - - run: sudo apt update && sudo apt install zlib1g-dev libsqlite3-dev - - # Download and cache dependencies - - # composer cache - - restore_cache: - keys: - # "composer.lock" can be used if it is committed to the repo - - v2-dependencies-{{ checksum "composer.json" }} - # fallback to using the latest cache if no exact match is found - - v2-dependencies- - - - run: composer install -n --prefer-dist - - - save_cache: - key: composer-v2-{{ checksum "composer.lock" }} - paths: - - vendor - - - run: cp .env.testing .env - - run: php artisan config:cache - - run: php artisan route:clear - - run: php artisan storage:link - - run: php artisan key:generate - - # run tests with phpunit or codecept - - run: ./vendor/bin/phpunit - - store_test_results: - path: tests/_output - - store_artifacts: - path: tests/_output diff --git a/.editorconfig b/.editorconfig index eff249956..dffbcc342 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,27 +1,25 @@ root = true [*] -indent_style = space -indent_size = 4 -end_of_line = lf charset = utf-8 -trim_trailing_whitespace = true +end_of_line = lf +indent_size = 4 +indent_style = space insert_final_newline = true +trim_trailing_whitespace = true [*.{yml,yaml}] -indent_style = space indent_size = 2 [*.{sh,envsh,env,env*}] -indent_style = space indent_size = 4 # ShellCheck config -shell_variant = bash # like -ln=bash binary_next_line = true # like -bn -switch_case_indent = true # like -ci -space_redirects = false # like -sr -keep_padding = false # like -kp function_next_line = true # like -fn +keep_padding = false # like -kp never_split = true # like -ns +shell_variant = bash # like -ln=bash simplify = true +space_redirects = false # like -sr +switch_case_indent = true # like -ci diff --git a/.gitattributes b/.gitattributes index 25c1b1b65..ada52797d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,8 +1,14 @@ -* text=auto -*.css linguist-vendored -*.scss linguist-vendored -*.js linguist-vendored +* text=auto eol=lf + +*.blade.php diff=html +*.css diff=css +*.html diff=html +*.md diff=markdown +*.php diff=php + +/.github export-ignore CHANGELOG.md export-ignore +.styleci.yml export-ignore # Collapse diffs for generated files: public/**/*.js text -diff diff --git a/.github/workflows/db.yml b/.github/workflows/db.yml new file mode 100644 index 000000000..bd98a1c60 --- /dev/null +++ b/.github/workflows/db.yml @@ -0,0 +1,250 @@ +--- +name: Database + +on: + # See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch + workflow_dispatch: + + # See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push + push: + + # See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request + pull_request: + types: + - opened + - reopened + - synchronize + +env: + EXTRA_PHP_EXTENSIONS: intl bcmath zip pcntl exif curl gd pdo_pgsql pdo_mysql pdo_sqlite + DOCKER_PHP_EXTENSION_INSTALLER_VERSION: 2.2.2 + COMPOSER_VERSION: 2.7.1 + +jobs: + migrations-mysql: + name: MySQL / MariaDB + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + # See: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs + matrix: + php_version: + - 8.3 + db_version: + - mariadb:latest + - mariadb:11 + - mariadb:10 + + - mysql:latest + - mysql:8.3 + - mysql:8.0 + + container: + image: php:${{ matrix.php_version }}-cli + + services: + db: + image: ${{ matrix.db_version }} + env: + MARIADB_ROOT_PASSWORD: password + MARIADB_PASSWORD: password + MARIADB_USER: pixelfed + MARIADB_DATABASE: pixelfed + + MYSQL_ROOT_PASSWORD: "password" + MYSQL_USER: "pixelfed" + MYSQL_PASSWORD: "password" + MYSQL_DATABASE: "pixelfed" + ports: + - 33306:3306 + + redis: + image: redis:7.2 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + # See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-and-the-default-behavior + concurrency: + group: db-migrations-${{ github.ref }}-${{ matrix.php_version }}-${{matrix.db_version}} + cancel-in-progress: true + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Download mlocati/docker-php-extension-installer + uses: robinraju/release-downloader@v1.9 + with: + repository: mlocati/docker-php-extension-installer + tag: ${{env.DOCKER_PHP_EXTENSION_INSTALLER_VERSION}} + fileName: install-php-extensions + + - name: Download composer + uses: robinraju/release-downloader@v1.9 + with: + repository: composer/composer + tag: ${{env.COMPOSER_VERSION}} + fileName: composer.phar + + - name: Download jippi/dottie + uses: robinraju/release-downloader@v1.9 + with: + repository: jippi/dottie + latest: true + fileName: "*_amd64.deb" + + - name: Install dottie + run: | + dpkg -i *.deb + rm -f *.deb + dottie -v + + - name: Install PHP extensions + run: | + chmod +x install-php-extensions + ./install-php-extensions ${{env.EXTRA_PHP_EXTENSIONS}} + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: vendor/ + key: composer-${{matrix.php_version}}-${{ hashFiles('composer.lock') }} + + - name: Install composer dependencies + run: php composer.phar install -n --prefer-dist + + - name: Setup Environment + run: | + cp .env.testing .env + + dottie set DB_CONNECTION=mysql + dottie set DB_HOST=db + dottie set DB_PORT=3306 + dottie set DB_DATABASE=pixelfed + dottie set DB_USERNAME=pixelfed + dottie set DB_PASSWORD=password + + dottie set REDIS_HOST=redis + + - run: php artisan config:cache + - run: php artisan route:clear + - run: php artisan storage:link + - run: php artisan key:generate + + - run: php artisan migrate --force + + migrations-postgresql: + name: PostgreSQL + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + # See: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs + matrix: + php_version: + - 8.3 + db_version: + - postgres:16 + - postgres:15 + - postgres:14 + + container: + image: php:${{ matrix.php_version }}-cli + + services: + db: + image: ${{ matrix.db_version }} + env: + POSTGRES_USER: "pixelfed" + POSTGRES_PASSWORD: "password" + POSTGRES_DB: "pixelfed" + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + redis: + image: redis:7.2 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + # See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-and-the-default-behavior + concurrency: + group: db-migrations-${{ github.ref }}-${{ matrix.php_version }}-${{matrix.db_version}} + cancel-in-progress: true + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Download mlocati/docker-php-extension-installer + uses: robinraju/release-downloader@v1.9 + with: + repository: mlocati/docker-php-extension-installer + tag: ${{env.DOCKER_PHP_EXTENSION_INSTALLER_VERSION}} + fileName: install-php-extensions + + - name: Download composer + uses: robinraju/release-downloader@v1.9 + with: + repository: composer/composer + tag: ${{env.COMPOSER_VERSION}} + fileName: composer.phar + + - name: Download jippi/dottie + uses: robinraju/release-downloader@v1.9 + with: + repository: jippi/dottie + latest: true + fileName: "*_amd64.deb" + + - name: Install dottie + run: | + dpkg -i *.deb + rm -f *.deb + dottie -v + + - name: Install PHP extensions + run: | + chmod +x install-php-extensions + ./install-php-extensions ${{env.EXTRA_PHP_EXTENSIONS}} + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: vendor/ + key: composer-${{matrix.php_version}}-${{ hashFiles('composer.lock') }} + + - name: Install composer dependencies + run: php composer.phar install -n --prefer-dist + + - name: Setup Environment + run: | + cp .env.testing .env + + dottie set DB_CONNECTION=pgsql + dottie set DB_HOST=db + dottie set DB_PORT=5432 + dottie set DB_DATABASE=pixelfed + dottie set DB_USERNAME=pixelfed + dottie set DB_PASSWORD=password + dottie set REDIS_HOST=redis + + - run: php artisan config:cache + - run: php artisan route:clear + - run: php artisan storage:link + - run: php artisan key:generate + + - run: php artisan migrate --force diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 000000000..195bfc394 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,92 @@ +--- +name: PHP + +on: + # See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch + workflow_dispatch: + + # See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push + push: + + # See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request + pull_request: + types: + - opened + - reopened + - synchronize + +env: + EXTRA_PHP_EXTENSIONS: intl bcmath zip pcntl exif curl gd pdo_pgsql pdo_mysql pdo_sqlite + DOCKER_PHP_EXTENSION_INSTALLER_VERSION: 2.2.2 + COMPOSER_VERSION: 2.7.1 + +jobs: + test: + name: PHPUnit Tests + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + # See: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs + matrix: + php_version: + - 8.2 + - 8.3 + + container: + image: php:${{ matrix.php_version }}-cli + + # See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-and-the-default-behavior + concurrency: + group: php-test-${{ github.ref }}-${{ matrix.php_version }} + cancel-in-progress: false + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + # NOTE: we lint PHP files before composer to avoid wasting time + # linting everything in vendor/ + - name: Lint PHP files + run: find . -name '*.php' -exec php --syntax-check {} \; > /dev/null + + - name: Download mlocati/docker-php-extension-installer + uses: robinraju/release-downloader@v1.9 + with: + repository: mlocati/docker-php-extension-installer + tag: ${{env.DOCKER_PHP_EXTENSION_INSTALLER_VERSION}} + fileName: install-php-extensions + + - name: Download composer + uses: robinraju/release-downloader@v1.9 + with: + repository: composer/composer + tag: ${{env.COMPOSER_VERSION}} + fileName: composer.phar + + - name: Install PHP extensions + run: | + chmod +x install-php-extensions + ./install-php-extensions ${{env.EXTRA_PHP_EXTENSIONS}} + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: vendor/ + key: composer-${{matrix.php_version}}-${{ hashFiles('composer.lock') }} + + - name: Install composer dependencies + run: php composer.phar install --no-interaction --prefer-dist + + - name: Setup Environment + run: | + cp .env.testing .env + + - run: php artisan config:cache + - run: php artisan route:clear + - run: php artisan storage:link + - run: php artisan key:generate + + - name: Run tests + run: ./vendor/bin/phpunit diff --git a/composer.json b/composer.json index a1adcf9e9..8f22063ad 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ "laravel/passport": "^11.0", "laravel/tinker": "^2.0", "laravel/ui": "^4.2", + "lcobucci/clock": "^3.2", "league/flysystem-aws-s3-v3": "^3.0", "league/iso3166": "^2.1|^4.0", "pbmedia/laravel-ffmpeg": "^8.0", diff --git a/composer.lock b/composer.lock index df57a6b03..0e25a8ebc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e166bdd0755f5304899546c97d9b7d4c", + "content-hash": "e45c8d752c80aa64dc705adc1c30029c", "packages": [ { "name": "aws/aws-crt-php", @@ -3225,34 +3225,34 @@ }, { "name": "lcobucci/clock", - "version": "3.0.0", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/lcobucci/clock.git", - "reference": "039ef98c6b57b101d10bd11d8fdfda12cbd996dc" + "reference": "6f28b826ea01306b07980cb8320ab30b966cd715" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lcobucci/clock/zipball/039ef98c6b57b101d10bd11d8fdfda12cbd996dc", - "reference": "039ef98c6b57b101d10bd11d8fdfda12cbd996dc", + "url": "https://api.github.com/repos/lcobucci/clock/zipball/6f28b826ea01306b07980cb8320ab30b966cd715", + "reference": "6f28b826ea01306b07980cb8320ab30b966cd715", "shasum": "" }, "require": { - "php": "~8.1.0 || ~8.2.0", + "php": "~8.2.0 || ~8.3.0", "psr/clock": "^1.0" }, "provide": { "psr/clock-implementation": "1.0" }, "require-dev": { - "infection/infection": "^0.26", - "lcobucci/coding-standard": "^9.0", - "phpstan/extension-installer": "^1.2", - "phpstan/phpstan": "^1.9.4", - "phpstan/phpstan-deprecation-rules": "^1.1.1", - "phpstan/phpstan-phpunit": "^1.3.2", - "phpstan/phpstan-strict-rules": "^1.4.4", - "phpunit/phpunit": "^9.5.27" + "infection/infection": "^0.27", + "lcobucci/coding-standard": "^11.0.0", + "phpstan/extension-installer": "^1.3.1", + "phpstan/phpstan": "^1.10.25", + "phpstan/phpstan-deprecation-rules": "^1.1.3", + "phpstan/phpstan-phpunit": "^1.3.13", + "phpstan/phpstan-strict-rules": "^1.5.1", + "phpunit/phpunit": "^10.2.3" }, "type": "library", "autoload": { @@ -3273,7 +3273,7 @@ "description": "Yet another clock abstraction", "support": { "issues": "https://github.com/lcobucci/clock/issues", - "source": "https://github.com/lcobucci/clock/tree/3.0.0" + "source": "https://github.com/lcobucci/clock/tree/3.2.0" }, "funding": [ { @@ -3285,7 +3285,7 @@ "type": "patreon" } ], - "time": "2022-12-19T15:00:24+00:00" + "time": "2023-11-17T17:00:27+00:00" }, { "name": "lcobucci/jwt",