diff --git a/.azure/azure.sig b/.azure/azure.sig deleted file mode 100644 index 5c80cc42370..00000000000 --- a/.azure/azure.sig +++ /dev/null @@ -1,16 +0,0 @@ ------BEGIN PGP SIGNATURE----- - -iQIzBAABCgAdFiEEuNgCced4O/05ANeg4OezJU6ORAcFAmAb4BcACgkQ4OezJU6O -RAe/Vg/9Gb60hFnTkJZrjjVOcpssiPSbFwAdsv7BMS6ED1ifksVdg/TVAqZoJR1r -Ys/ZJfUBNqo1rKPdqtgyDyJLjFBXVcG2TKAIeGWivg/nybZAwSXuAKELXqOC608p -VDSGT/yuIufPXbrNva9o4zkZ0ASV47FarWaO3c5SQIZDlLwzkm/exPhHLZWiQdc0 -Clbwx13KjWC2cFrcxnwU1m83meXwp7m+swvt86ojrO1q+LcjFitzqMJcmsf5k3dK -8sBjGzHSUTbrJnnYoqnJi5OIFBjLZYcmKT3ZWJAbD//iRwyzE7saJDs3/p8IBQFd -wcfvULZdiMf+a76Vu0TpisN6gn8iTornONtMM7ZspIMP88SuYr16sokKg0OV/I8A -A9aHxRp7rhic2rTCVEsjDQ+A2gZMqW097o4rJp/QSdudsrPsCIXWo1MP3ZsNxaFj -+rWHBDXobbfWMzv6PJJAcj4b6886AfEj5c3/spfNYku46ZYMx4Hhj6CQ2IHEv8zM -9NOCfsIzUkvc9xNOGDTLNDDvjsM1j17YO+7cIYNMoRg2ivRAZ2AGSfJhT5QtUYDz -PlERcki7d4QIu/3VVJpCTj5W88rE7UuFqJo/Cvmi2P0h/iCEDwElM7AmAVFjcMTF -yoKKSBM7MQ3MLEXvSenB2cuMhttyIxfX1wq6cHru1TyxR/MhITY= -=mxjv ------END PGP SIGNATURE----- diff --git a/.azure/job-analyzers.yml b/.azure/job-analyzers.yml deleted file mode 100644 index 01dba88a933..00000000000 --- a/.azure/job-analyzers.yml +++ /dev/null @@ -1,20 +0,0 @@ -jobs: - - job: psalm - pool: - vmImage: 'ubuntu-latest' - steps: - - template: step-prepare-environment.yml - - template: step-composer-install.yml - - - script: vendor/bin/psalm - displayName: Run psalm - - - job: phpstan - pool: - vmImage: 'ubuntu-latest' - steps: - - template: step-prepare-environment.yml - - template: step-composer-install.yml - - - script: vendor/bin/phpstan analyse - displayName: Run phpstan diff --git a/.azure/job-build.yml b/.azure/job-build.yml deleted file mode 100644 index ab9865a3b34..00000000000 --- a/.azure/job-build.yml +++ /dev/null @@ -1,24 +0,0 @@ -jobs: -- job: build - pool: - vmImage: 'ubuntu-latest' - steps: - - template: step-prepare-environment.yml - - template: step-composer-install.yml - - - template: step-cache-yarn.yml - - - script: yarn inst - displayName: 'yarn install' - - # Update js and css assets eventually - - script: yarn lint:all - displayName: 'Check js and vue lint' - - bash: | - source scripts/ci/fixsecrets.sh - scripts/ci/update-assets.sh - displayName: 'Update assets' - env: - ASSETS_USERNAME: $(ASSETS_USERNAME) - ASSETS_EMAIL: $(ASSETS_EMAIL) - ASSETS_GITHUB_TOKEN: $(ASSETS_GITHUB_TOKEN) diff --git a/.azure/job-reporting.yml b/.azure/job-reporting.yml deleted file mode 100644 index 7febf0c1eee..00000000000 --- a/.azure/job-reporting.yml +++ /dev/null @@ -1,24 +0,0 @@ -jobs: -- job: reporting - dependsOn: - - tests - - tests_browser - pool: - vmImage: 'ubuntu-latest' - steps: - - template: step-prepare-environment.yml - - template: step-composer-install.yml - - - task: DownloadPipelineArtifact@2 - inputs: - path: $(System.DefaultWorkingDirectory)/results - - bash: | - pushd ${SYSTEM_DEFAULTWORKINGDIRECTORY}/results - for f in $(ls); do cp -rf $f/* .; rm -rf $f; done - - - bash: | - yarn global add junit-merge - $(yarn global bin)/junit-merge --recursive --dir results/junit --out results/results.xml - displayName: 'Merge junit files' - - - template: step-runsonar.yml diff --git a/.azure/job-test-browser.yml b/.azure/job-test-browser.yml deleted file mode 100644 index d0021aaca39..00000000000 --- a/.azure/job-test-browser.yml +++ /dev/null @@ -1,20 +0,0 @@ -jobs: -- job: tests_browser - pool: - vmImage: 'ubuntu-latest' - steps: - - template: step-prepare-environment.yml - - template: step-composer-install.yml - - template: step-prepare-db.yml - - template: step-seed-test-db.yml - - - template: step-test-browser.yml - - - bash: | - vendor/bin/phpcov merge --clover=results/coverage0.xml results/coverage/ - rm -rf results/coverage - displayName: 'Fix coverage' - - - template: step-publish-results.yml - parameters: - artifact: results0 diff --git a/.azure/job-test-migrations.yml b/.azure/job-test-migrations.yml deleted file mode 100644 index 422ad9b8014..00000000000 --- a/.azure/job-test-migrations.yml +++ /dev/null @@ -1,10 +0,0 @@ -jobs: -- job: test_migrations - pool: - vmImage: 'ubuntu-latest' - steps: - - template: step-prepare-environment.yml - - template: step-composer-install.yml - - template: step-prepare-db.yml - parameters: - import: false diff --git a/.azure/job-tests.yml b/.azure/job-tests.yml deleted file mode 100644 index a1324ad5e3c..00000000000 --- a/.azure/job-tests.yml +++ /dev/null @@ -1,18 +0,0 @@ -jobs: -- job: tests - pool: - vmImage: 'ubuntu-latest' - strategy: - parallel: 4 - steps: - - template: step-prepare-environment.yml - - template: step-composer-install.yml - - template: step-remove-xdebug.yml - - template: step-prepare-db.yml - - template: step-seed-test-db.yml - - - template: step-test-unit.yml - - - template: step-publish-results.yml - parameters: - artifact: results$(System.JobPositionInPhase) diff --git a/.azure/sign.sh b/.azure/sign.sh deleted file mode 100755 index 9e2b600975b..00000000000 --- a/.azure/sign.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && /bin/pwd -P) - -cat $SELF_PATH/../azure-pipelines.yml $SELF_PATH/*.yml > $SELF_PATH/azure -rm -f $SELF_PATH/azure.sig -gpg --sign --armor --output $SELF_PATH/azure.sig --detach-sig $SELF_PATH/azure || true -gpg --verify $SELF_PATH/azure.sig || true -rm -f $SELF_PATH/azure diff --git a/.azure/step-cache-composer.yml b/.azure/step-cache-composer.yml deleted file mode 100644 index 0cf1fab7c6b..00000000000 --- a/.azure/step-cache-composer.yml +++ /dev/null @@ -1,8 +0,0 @@ -steps: -- task: Cache@2 - inputs: - key: composer-v2 | composer.lock - restoreKeys: | - composer-v2 - path: $(COMPOSER_HOME)/cache - displayName: Cache composer packages diff --git a/.azure/step-cache-sonar.yml b/.azure/step-cache-sonar.yml deleted file mode 100644 index fde1c4ef068..00000000000 --- a/.azure/step-cache-sonar.yml +++ /dev/null @@ -1,17 +0,0 @@ -steps: -- task: Cache@2 - inputs: - key: sonarscanner-v1 | "$(SONAR_VERSION)" | scripts/tests/runsonar.sh - restoreKeys: | - sonarscanner-v1 | "$(SONAR_VERSION)" - sonarscanner-v1 - path: $(HOME)/sonarscanner - displayName: Cache sonar scanner -- task: Cache@2 - inputs: - key: sonarcache-v1 | "$(SONAR_VERSION)" | scripts/tests/runsonar.sh - restoreKeys: | - sonarcache-v1 | "$(SONAR_VERSION)" - sonarcache-v1 - path: $(HOME)/.sonar - displayName: Cache sonar cache diff --git a/.azure/step-cache-yarn.yml b/.azure/step-cache-yarn.yml deleted file mode 100644 index da14b7d6ea7..00000000000 --- a/.azure/step-cache-yarn.yml +++ /dev/null @@ -1,8 +0,0 @@ -steps: -- task: Cache@2 - inputs: - key: yarn-v1 | yarn.lock - restoreKeys: | - yarn-v1 - path: $(YARN_CACHE_FOLDER) - displayName: Cache Yarn packages diff --git a/.azure/step-composer-install.yml b/.azure/step-composer-install.yml deleted file mode 100644 index 789a82f3a07..00000000000 --- a/.azure/step-composer-install.yml +++ /dev/null @@ -1,18 +0,0 @@ -parameters: -- { name: no_dev, type: boolean, default: false } - -steps: -- template: step-cache-composer.yml - -- script: composer validate - displayName: Validate composer files - -- ${{ if not(parameters.no_dev) }}: - - script: echo '##vso[task.setvariable variable=EXTRA_PARAM]' - displayName: Set empty param -- ${{ if parameters.no_dev }}: - - script: echo '##vso[task.setvariable variable=EXTRA_PARAM]--no-dev' - displayName: Set extra param - -- bash: composer install --no-interaction --no-progress --ignore-platform-reqs $EXTRA_PARAM - displayName: composer install diff --git a/.azure/step-prepare-db.yml b/.azure/step-prepare-db.yml deleted file mode 100644 index 5c36500fe52..00000000000 --- a/.azure/step-prepare-db.yml +++ /dev/null @@ -1,19 +0,0 @@ -# database.test.sql file is generated with: -# mysqldump -u homestead -psecret -n --skip-add-drop-table --skip-add-locks --skip-comments monica_test > scripts/database.test.sql -parameters: -- { name: import, type: boolean, default: true } - -steps: -- script: sudo service mysql start - displayName: Start mysql - -- script: mysql --protocol=tcp -u root -proot - -e "CREATE DATABASE IF NOT EXISTS monica CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" - displayName: Create db - -- ${{ if parameters.import }}: - - script: mysql -u root -proot monica < scripts/database.test.sql - displayName: Prepare db - -- script: php artisan migrate --no-interaction -vvv - displayName: Run migration scripts diff --git a/.azure/step-prepare-environment.yml b/.azure/step-prepare-environment.yml deleted file mode 100644 index 9fdec9504d9..00000000000 --- a/.azure/step-prepare-environment.yml +++ /dev/null @@ -1,17 +0,0 @@ -steps: -- bash: | - sudo update-alternatives --set php /usr/bin/php$(phpVersion) - sudo update-alternatives --set phar /usr/bin/phar$(phpVersion) - sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion) - sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion) - sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion) - sudo apt-get update - sudo apt-get install php$(phpVersion)-imagick - php -version - displayName: Set php version $(phpVersion) - -- bash: | - mkdir -p results/coverage - sed 's/DB_TEST_PASSWORD=/DB_TEST_PASSWORD=root/' scripts/ci/.env.mysql > .env - touch .sentry-release - displayName: Prepare environment diff --git a/.azure/step-publish-results.yml b/.azure/step-publish-results.yml deleted file mode 100644 index ff5be378758..00000000000 --- a/.azure/step-publish-results.yml +++ /dev/null @@ -1,16 +0,0 @@ -parameters: -- { name: artifact, type: string, default: 'results' } - -steps: -- task: PublishTestResults@2 - displayName: Publish Test Results - inputs: - testResultsFormat: JUnit - testResultsFiles: 'results*.xml' - searchFolder: '$(System.DefaultWorkingDirectory)/results/junit' - mergeTestResults: true - condition: succeededOrFailed() - -- publish: $(System.DefaultWorkingDirectory)/results - artifact: ${{ parameters.artifact }} - condition: succeededOrFailed() diff --git a/.azure/step-remove-xdebug.yml b/.azure/step-remove-xdebug.yml deleted file mode 100644 index 2ceb56d76e7..00000000000 --- a/.azure/step-remove-xdebug.yml +++ /dev/null @@ -1,3 +0,0 @@ -steps: -- bash: sudo rm -f /etc/php/$(phpVersion)/cli/conf.d/20-xdebug.ini - displayName: Remove xdebug diff --git a/.azure/step-runsonar.yml b/.azure/step-runsonar.yml deleted file mode 100644 index 89379ccd62c..00000000000 --- a/.azure/step-runsonar.yml +++ /dev/null @@ -1,17 +0,0 @@ -steps: -- script: | - echo "##vso[task.setvariable variable=JAVA_HOME]$(JAVA_HOME_11_X64)" - echo "##vso[task.setvariable variable=PATH]$(JAVA_HOME_11_X64)\bin;$(PATH)" - displayName: Use Java 11 - -- template: step-cache-sonar.yml - -- bash: | - source scripts/ci/fixsecrets.sh - export SONAR_COVERAGE=$(ls -m ./results/coverage*.xml | sed 's/ //g' | sed ':a;N;$!ba;s/\n//g') - scripts/tests/runsonar.sh - displayName: Run sonar scanner - env: - SONAR_RESULT: '$(System.DefaultWorkingDirectory)/results/results.xml' - SONAR_TOKEN: $(SONAR_TOKEN) - GITHUB_TOKEN: $(GITHUB_TOKEN) diff --git a/.azure/step-seed-test-db.yml b/.azure/step-seed-test-db.yml deleted file mode 100644 index 19321f5cc5f..00000000000 --- a/.azure/step-seed-test-db.yml +++ /dev/null @@ -1,5 +0,0 @@ -steps: -- script: | - php artisan db:seed --no-interaction -vvv - php artisan passport:keys --no-interaction -vvv - displayName: Seed database diff --git a/.azure/step-test-browser.yml b/.azure/step-test-browser.yml deleted file mode 100644 index a4ca85f3058..00000000000 --- a/.azure/step-test-browser.yml +++ /dev/null @@ -1,19 +0,0 @@ -steps: -- bash: | - echo "##vso[task.setvariable variable=DISPLAY]$DISPLAY" - Xvfb ${DISPLAY} -screen 0 1920x1080x24 & - php artisan dusk:chrome-driver $(google-chrome -version | awk '{ print $3 }' | cut -d . -f 1) - ./vendor/laravel/dusk/bin/chromedriver-linux > /dev/null 2>&1 & - displayName: Launch google chrome - env: - DISPLAY: ':99' - -- bash: | - php -S localhost:8000 -t public scripts/tests/server-cc.php & - php -S localhost:8001 -t public scripts/tests/server-cc.php & - displayName: Run http server - -- script: php artisan dusk --log-junit results/junit/results0.xml - displayName: Run browser tests - env: - CHROME_DRIVER_OPTS: --headless --disable-gpu --disable-dev-shm-usage --no-sandbox --remote-debugging-port=9222 --window-size=1920,1080 diff --git a/.azure/step-test-unit.yml b/.azure/step-test-unit.yml deleted file mode 100644 index 57874d6979f..00000000000 --- a/.azure/step-test-unit.yml +++ /dev/null @@ -1,18 +0,0 @@ -steps: -- bash: | - IFS='|' read -r -a TESTS <<< "$TESTSUITES" - TESTSUITE=${TESTS[$SYSTEM_JOBPOSITIONINPHASE-1]} - echo "TestSuite $TESTSUITE" - echo "##vso[task.setvariable variable=TESTSUITE]$TESTSUITE" - displayName: Select testsuite - env: - TESTSUITES: "Api|Feature|Unit-Models|Unit-Services" - -- bash: | - source scripts/ci/fixsecrets.sh - php artisan route:cache - ulimit -S unlimited - phpdbg -dmemory_limit=4G -qrr vendor/bin/phpunit -c phpunit.xml --log-junit ./results/junit/results${SYSTEM_JOBPOSITIONINPHASE}.xml --coverage-clover ./results/coverage${SYSTEM_JOBPOSITIONINPHASE}.xml --testsuite $TESTSUITE - displayName: Run unit tests - env: - STRIPE_SECRET: $(STRIPE_SECRET) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000000..533f72f2e2b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,101 @@ +name: Build + +on: + push: + branches: [master] + pull_request: + types: [opened, synchronize, reopened] + branches-ignore: ['l10n_master*'] + release: + types: [created] + + workflow_run: + workflows: ['Compress images'] + types: [completed] + +jobs: + ############# + # Build + ############# + build: + runs-on: ubuntu-latest + name: Build (PHP ${{ matrix.php-version }}) + + strategy: + fail-fast: false + matrix: + php-version: [7.4] + + env: + node-version: 14 + + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: imagick, mbstring, dom, fileinfo, ${{ matrix.connection }} + coverage: none + - name: Check PHP Version + run: php -v + - name: Check Composer Version + run: composer -V + - name: Check PHP Extensions + run: php -m + + # Composer + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer files + uses: actions/cache@v2.1.4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + ${{ runner.os }}-composer-${{ matrix.php-version }} + ${{ runner.os }}-composer- + + - name: Install composer dependencies + run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-req=php + + # Yarn + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: ${{ env.node-version }} + - name: Get yarn cache directory path + id: yarn-cache + run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Cache yarn files + uses: actions/cache@v2.1.4 + with: + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + ${{ runner.os }}-yarn- + + - name: Install yarn dependencies + run: yarn inst + - name: Lint files + run: yarn run lint:all + - name: Build assets + run: yarn run production + + - name: Check if there is any file update needed + run: | + status=$(git status --porcelain) + if [ -z "$status" ]; then + echo "Nothing to push, already up to date." + else + echo -e "Waiting modifications:\n$status" + exit -1 + fi diff --git a/.github/workflows/calibreapp-image-actions.yml b/.github/workflows/calibreapp-image-actions.yml new file mode 100644 index 00000000000..9aac129135d --- /dev/null +++ b/.github/workflows/calibreapp-image-actions.yml @@ -0,0 +1,21 @@ +name: Compress images + +on: + pull_request: + paths: + - '**.jpg' + - '**.png' + - '**.webp' + +jobs: + build: + name: calibreapp/image-actions + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + + - name: Compress Images + uses: calibreapp/image-actions@2 + with: + githubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 5d83e819109..00000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: "Code scanning - action" - -on: - schedule: - - cron: '0 7 * * 0' - -jobs: - CodeQL-Build: - - # CodeQL runs on ubuntu-latest and windows-latest - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - # Override language selection by uncommenting this and choosing your languages - with: - languages: javascript - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 3375de3f1ac..5a145a3d3de 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -10,23 +10,15 @@ jobs: if: contains(github.event.pull_request.labels.*.name, 'cypress') name: Cypress tests with ${{ matrix.browser }} (PHP ${{ matrix.php-version }}) - services: - mysql: - image: mysql:5.7 - env: - MYSQL_ALLOW_EMPTY_PASSWORD: yes - MYSQL_DATABASE: monica - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - strategy: fail-fast: false matrix: php-version: [7.4] browser: [chrome] containers: [1, 2, 3, 4, 5, 6, 7, 8] - max-parallel: 10 + + env: + node-version: 14 steps: - name: Checkout sources @@ -36,7 +28,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} - extensions: imagick + extensions: imagick, mbstring, dom, fileinfo coverage: none - name: Check PHP Version run: php -v @@ -45,65 +37,83 @@ jobs: - name: Check PHP Extensions run: php -m - # step-prepare-environment - - name: Prepare environment - run: | - mkdir -p results/coverage - cp scripts/ci/.env.mysql .env - touch .sentry-release - echo "REQUIRES_SUBSCRIPTION=true" >> .env - + # Composer - name: Validate composer.json and composer.lock run: composer validate - name: Get Composer Cache Directory - id: composer-cache-dir-path + id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache composer files uses: actions/cache@v2.1.4 with: - path: ${{ steps.composer-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} restore-keys: | - ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + ${{ runner.os }}-composer-${{ matrix.php-version }} ${{ runner.os }}-composer- - - name: Install dependencies - run: composer install --no-interaction --ignore-platform-reqs - - # step-prepare-db - - name: Prepare db - run: mysql -h 127.0.0.1 -u root -P 3306 monica < scripts/database.test.sql - - name: Run migration scripts - run: php artisan migrate --no-interaction -vvv - - # step-seed-test-db - - name: Seed database - run: | - php artisan db:seed --no-interaction -vvv - php artisan passport:keys --no-interaction -vvv + - name: Install composer dependencies + run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-req=php + # Yarn + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: ${{ env.node-version }} - name: Get yarn cache directory path - id: yarn-cache-dir-path + id: yarn-cache run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v2.1.4 + - name: Cache yarn files + uses: actions/cache@v2.1.4 with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + path: ${{ steps.yarn-cache.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | + ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} ${{ runner.os }}-yarn- - - name: yarn install + - name: Install yarn dependencies run: yarn inst - - name: yarn build + - name: Build assets run: yarn run production - - name: Cypress verify - run: npm run cy:verify - - name: which google-chrome + # Prepare + - name: Prepare environment run: | - which google-chrome || true - - uses: cypress-io/github-action@v1 + cp scripts/ci/.env.mysql .env + touch config/.version config/.release .sentry-release .sentry-commit + mkdir -p results/coverage + echo "REQUIRES_SUBSCRIPTION=true" >> .env + + - name: Generate key + run: php artisan key:generate + + - name: Start mysql + run: sudo systemctl start mysql.service + - name: Create database + run: mysql --protocol=tcp -u root -proot -e "CREATE DATABASE IF NOT EXISTS monica CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" + - name: Prepare database + run: mysql --protocol=tcp -u root -proot monica < scripts/database.test.sql + - name: Run migrations + run: php artisan migrate --no-interaction -vvv + + - name: Run seeds + run: php artisan db:seed --no-interaction -vvv + - name: Create passport keys + run: php artisan passport:keys --no-interaction -vvv + + + # Cypress + - name: Cypress verify + run: npx cypress verify + + - name: Find google-chrome + run: which google-chrome || true + - uses: cypress-io/github-action@v2 + id: cypress + continue-on-error: true with: start: php artisan serve browser: ${{ matrix.browser }} @@ -111,7 +121,7 @@ jobs: record: true parallel: true install: false - group: Azure DevOps CI ${{ matrix.browser }} + group: github action ${{ matrix.browser }} tag: ${{ github.event_name }} config: baseUrl=http://localhost:8000 wait-on: http://localhost:8000 diff --git a/.github/workflows/migration_tests.yml b/.github/workflows/migration_tests.yml new file mode 100644 index 00000000000..c9616de4845 --- /dev/null +++ b/.github/workflows/migration_tests.yml @@ -0,0 +1,84 @@ +name: Migration tests + +on: + push: + branches: [master] + pull_request: + types: [opened, synchronize, reopened] + branches-ignore: ['l10n_master*'] + release: + types: [created] + + workflow_run: + workflows: ['Compress images'] + types: [completed] + +jobs: + ##################### + # Run tests migration + ##################### + tests_migration: + runs-on: ubuntu-latest + name: Test migration on ${{ matrix.connection }} (PHP ${{ matrix.php-version }}) + + strategy: + fail-fast: false + matrix: + php-version: [7.4] + connection: [mysql] + + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: imagick, mbstring, dom, fileinfo, ${{ matrix.connection }} + coverage: none + - name: Check PHP Version + run: php -v + - name: Check Composer Version + run: composer -V + - name: Check PHP Extensions + run: php -m + + # Composer + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer files + uses: actions/cache@v2.1.4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + ${{ runner.os }}-composer-${{ matrix.php-version }} + ${{ runner.os }}-composer- + + - name: Install composer dependencies + run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-req=php + + # Prepare + - name: Prepare environment + run: cp scripts/ci/.env.${{ matrix.connection }} .env + + - name: Start mysql + if: matrix.connection == 'mysql' + run: sudo systemctl start mysql.service + - name: Create database + if: matrix.connection == 'mysql' + run: mysql --protocol=tcp -u root -proot -e "CREATE DATABASE IF NOT EXISTS monica CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" + - name: Prepare database + if: matrix.connection == 'mysql' + run: mysql --protocol=tcp -u root -proot monica < scripts/database.test.sql + - name: Run migrations + run: php artisan migrate --no-interaction -vvv + + - name: Run seeds + run: php artisan db:seed --no-interaction -vvv diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 043b3ee72c9..bd7187a4dc0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,6 +60,7 @@ jobs: env: php-version: 7.4 + node-version: 14 steps: - name: Checkout repository @@ -75,7 +76,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ env.php-version }} - extensions: mbstring, dom, fileinfo + extensions: imagick, mbstring, dom, fileinfo coverage: none # Composer @@ -90,8 +91,13 @@ jobs: restore-keys: | ${{ runner.os }}-composer-${{ env.php-version }}-${{ hashFiles('**/composer.lock') }} ${{ runner.os }}-composer-${{ env.php-version }} + ${{ runner.os }}-composer- # Yarn + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: ${{ env.node-version }} - name: Get yarn cache directory path id: yarn-cache run: echo "::set-output name=dir::$(yarn cache dir)" diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 00000000000..bbedd43074d --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,83 @@ +name: Static analysis + +on: + pull_request: + types: [opened, synchronize, reopened] + + workflow_run: + workflows: ['Compress images'] + types: [completed] + +jobs: + psalm: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: [7.4] + + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: imagick, mbstring, dom, fileinfo + coverage: none + + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer files + uses: actions/cache@v2.1.4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + ${{ runner.os }}-composer-${{ matrix.php-version }} + ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader + + - name: Run psalm + run: vendor/bin/psalm --output-format=github + + + phpstan: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: [7.4] + + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: imagick, mbstring, dom, fileinfo + coverage: none + + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer files + uses: actions/cache@v2.1.4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + ${{ runner.os }}-composer-${{ matrix.php-version }} + ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader + + - name: Run phpstan + run: vendor/bin/phpstan analyse diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000000..94c83681666 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,317 @@ +name: Unit tests + +on: + push: + branches: [master] + pull_request: + types: [opened, synchronize, reopened] + branches-ignore: ['l10n_master*'] + release: + types: [created] + + workflow_run: + workflows: ['Compress images'] + types: [completed] + +jobs: + ############# + # Run tests + ############# + tests: + runs-on: ubuntu-latest + name: Unit tests on ${{ matrix.connection }} Testsuite ${{ matrix.testsuite }} (PHP ${{ matrix.php-version }}) + + strategy: + fail-fast: false + matrix: + php-version: [7.4, 8.0] + connection: [mysql] + testsuite: [Api, Feature, Unit-Models, Unit-Services] + + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: imagick, mbstring, dom, fileinfo, ${{ matrix.connection }} + coverage: none + - name: Check PHP Version + run: php -v + - name: Check Composer Version + run: composer -V + - name: Check PHP Extensions + run: php -m + + # Composer + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer files + uses: actions/cache@v2.1.4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + ${{ runner.os }}-composer-${{ matrix.php-version }} + ${{ runner.os }}-composer- + + - name: Install composer dependencies + run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-req=php + + # Prepare + - name: Prepare environment + run: | + cp scripts/ci/.env.${{ matrix.connection }} .env + touch config/.version config/.release .sentry-release .sentry-commit + mkdir -p public/js public/css results/coverage + {\ + echo "{"; \ + for f in app.js manifest.js vendor.js app-ltr.css app-rtl.css stripe.js stripe.css; do \ + [[ $first == 1 ]] && echo -n "," || first=1; \ + k=${f##*.}/$f; \ + echo "\"/$k\": \"/$k\""; \ + echo '' > public/$k; \ + done; \ + echo "}"; \ + } | tee public/mix-manifest.json + + - name: Generate key + run: php artisan key:generate + + - name: Start mysql + if: matrix.connection == 'mysql' + run: sudo systemctl start mysql.service + - name: Create database + if: matrix.connection == 'mysql' + run: mysql --protocol=tcp -u root -proot -e "CREATE DATABASE IF NOT EXISTS monica CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" + - name: Prepare database + if: matrix.connection == 'mysql' + run: mysql --protocol=tcp -u root -proot monica < scripts/database.test.sql + - name: Run migrations + run: php artisan migrate --no-interaction -vvv + + - name: Run seeds + run: php artisan db:seed --no-interaction -vvv + - name: Create passport keys + run: php artisan passport:keys --no-interaction -vvv + - name: Cache route + run: php artisan route:cache + + # Test + - name: Run Unit test suite + if: matrix.php-version == '7.4' + run: phpdbg -dmemory_limit=4G -qrr vendor/bin/phpunit -c phpunit.xml --testsuite ${{ matrix.testsuite }} --log-junit ./results/junit/results${{ matrix.testsuite }}.xml --coverage-clover ./results/coverage${{ matrix.testsuite }}.xml + env: + DB_CONNECTION: ${{ matrix.connection }} + - name: Run Unit test suite + if: matrix.php-version != '7.4' + run: vendor/bin/phpunit -c phpunit.xml --testsuite ${{ matrix.testsuite }} + env: + DB_CONNECTION: ${{ matrix.connection }} + + - name: Fix results files + if: matrix.php-version == '7.4' + run: sed -i -e "s%$GITHUB_WORKSPACE/%%g" results/*/*.xml + + - name: Store results + if: matrix.php-version == '7.4' && always() + uses: actions/upload-artifact@v2 + with: + name: results${{ matrix.testsuite }} + path: results + + + ################### + # Run tests browser + ################### + tests_browser: + runs-on: ubuntu-latest + name: Tests browser on ${{ matrix.connection }} (PHP ${{ matrix.php-version }}) + + strategy: + fail-fast: false + matrix: + php-version: [7.4] + connection: [mysql] + + env: + node-version: 14 + + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: imagick, ${{ matrix.connection }} + - name: Check PHP Version + run: php -v + - name: Check Composer Version + run: composer -V + - name: Check PHP Extensions + run: php -m + + # Composer + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer files + uses: actions/cache@v2.1.4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + ${{ runner.os }}-composer-${{ matrix.php-version }} + ${{ runner.os }}-composer- + + - name: Install composer dependencies + run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-req=php + + # Yarn + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: ${{ env.node-version }} + - name: Get yarn cache directory path + id: yarn-cache + run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Cache yarn files + uses: actions/cache@v2.1.4 + with: + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + ${{ runner.os }}-yarn- + + - name: Install yarn dependencies + run: yarn inst + - name: Build assets + run: yarn run production + + # Prepare + - name: Prepare environment + run: | + cp scripts/ci/.env.${{ matrix.connection }} .env + touch config/.version config/.release .sentry-release .sentry-commit + mkdir -p results/coverage results/console + chmod -R 777 storage bootstrap/cache + + - name: Generate key + run: php artisan key:generate + + - name: Start mysql + if: matrix.connection == 'mysql' + run: sudo systemctl start mysql.service + - name: Create database + if: matrix.connection == 'mysql' + run: mysql --protocol=tcp -u root -proot -e "CREATE DATABASE IF NOT EXISTS monica CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" + - name: Prepare database + if: matrix.connection == 'mysql' + run: mysql --protocol=tcp -u root -proot monica < scripts/database.test.sql + - name: Run migrations + run: php artisan migrate --no-interaction -vvv + + - name: Run seeds + run: php artisan db:seed --no-interaction -vvv + - name: Create passport keys + run: php artisan passport:keys --no-interaction -vvv + - name: Cache route + run: php artisan route:cache + + # Test + - name: Upgrade Chrome Driver + run: php artisan dusk:chrome-driver $(google-chrome -version | awk '{ print $3 }' | cut -d . -f 1) + - name: Start Chrome Driver + run: | + chmod -R 0755 vendor/laravel/dusk/bin/ + ./vendor/laravel/dusk/bin/chromedriver-linux & + + - name: Run http server + run: | + php -S localhost:8000 -t public scripts/tests/server-cc.php & + php -S localhost:8001 -t public scripts/tests/server-cc.php & + + - name: Run browser tests + run: php artisan dusk --log-junit results/junit/results0.xml + env: + APP_URL: http://localhost:8000 + + - name: Fix coverage + run: | + vendor/bin/phpcov merge --clover=results/coverage0.xml results/coverage/ + rm -rf results/coverage + + - name: Store results + if: always() + uses: actions/upload-artifact@v2 + with: + name: results0 + path: results + + + ########################### + # Reporting to sonarcloud + ########################### + reporting: + needs: [tests, tests_browser] + runs-on: ubuntu-latest + name: Sonarcloud + if: ${{ ! startsWith(github.ref, 'dependabot/') }} + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - name: Checkout HEAD + if: github.event_name == 'pull_request' + run: git checkout HEAD^2 + + - name: Download results + uses: actions/download-artifact@v2 + with: + path: results + + - name: Fix results paths + run: | + pushd results + for f in $(ls); do cp -rf $f/* .; rm -rf $f; done + + - name: Merge junit files + run: | + yarn global add junit-merge + $(yarn global bin)/junit-merge --recursive --dir results/junit --out results/results.xml + + - name: Set version parameter + id: version + run: | + version=$(git tag --points-at HEAD) + test -z "$version" && version="main" + echo "::set-output name=value::$version" + + - name: SonarCloud Scan + if: env.SONAR_TOKEN != '' + uses: SonarSource/sonarcloud-github-action@v1.5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: | + -Dsonar.projectVersion=${{ steps.version.outputs.value }} diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 5f280707b65..00000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,39 +0,0 @@ -# PHP -# Test and package your PHP project. -# Add steps that run tests, save build artifacts, deploy, and more: -# https://docs.microsoft.com/azure/devops/pipelines/languages/php - -trigger: - batch: true - branches: - include: - - master - tags: - include: - - '*' -pr: - autoCancel: true - branches: - include: - - '*' - -variables: - - group: Monica - - name: phpVersion - value: 7.4 - - name: COMPOSER_HOME - value: $(Pipeline.Workspace)/.composer - - name: YARN_CACHE_FOLDER - value: $(Pipeline.Workspace)/.yarn - -stages: - - stage: build - displayName: Build - condition: not(startsWith(variables['System.PullRequest.SourceBranch'], 'l10n_master')) - jobs: - - template: .azure/job-build.yml - - template: .azure/job-tests.yml - - template: .azure/job-analyzers.yml - - template: .azure/job-test-browser.yml - - template: .azure/job-reporting.yml - - template: .azure/job-test-migrations.yml diff --git a/config/database.php b/config/database.php index c6e36913221..a9a3d7bf2c1 100644 --- a/config/database.php +++ b/config/database.php @@ -97,7 +97,7 @@ ], 'testing' => [ - 'driver' => 'mysql', + 'driver' => env('DB_TEST_DRIVER', 'mysql'), 'host' => env('DB_TEST_HOST'), 'unix_socket' => env('DB_TEST_UNIX_SOCKET', ''), 'database' => env('DB_TEST_DATABASE'), diff --git a/phpunit.xml b/phpunit.xml index 4bab4269dc7..34a6cd7f434 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,15 +1,15 @@ - + ./tests/Api @@ -44,21 +44,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/scripts/ci/.deploy.json.in b/scripts/ci/.deploy.json.in deleted file mode 100644 index db96aa6fc49..00000000000 --- a/scripts/ci/.deploy.json.in +++ /dev/null @@ -1,31 +0,0 @@ -{ - "package": { - "name": "monica", - "repo": "builds", - "subject": "monicahq", - "desc": "MonicaHQ, the Personal Relationship Manager", - "website_url": "https://www.monicahq.com", - "issue_tracker_url": "https://github.com/monicahq/monica/issues", - "vcs_url": "https://github.com/monicahq/monica.git", - "github_use_tag_release_notes": true, - "github_release_notes_file": "CHANGELOG.md", - "licenses": ["AGPL-V3"], - "labels": [], - "attributes": [] - }, - "version": { - "name": "$(version)", - "desc": "$(description)", - "released": "$(released)", - "vcs_tag": "$(vcs_tag)", - "github_use_tag_release_notes": true, - "attributes": [ - {"name": "commit", "values" : ["$(vcs_commit)"], "type": "string"}, - {"name": "build", "values" : [$(build_number)]} - ] - }, - "files": [ - {"includePattern": "results/(monica.*)", "uploadPattern": "$1"} - ], - "publish": true -} \ No newline at end of file diff --git a/scripts/ci/.env.jenkins.mysql b/scripts/ci/.env.jenkins.mysql deleted file mode 100644 index e76ac9525e5..00000000000 --- a/scripts/ci/.env.jenkins.mysql +++ /dev/null @@ -1,15 +0,0 @@ -APP_ENV=testing -APP_KEY=base64:NTrXToqFZJlv48dgPc+kNpc3SBt333TfDnF1mDShsBg= -APP_URL=http://localhost:8000 - -DB_CONNECTION=testing -DB_TEST_HOST=mysql -DB_TEST_DATABASE=monica -DB_TEST_USERNAME=root -DB_TEST_PASSWORD= - -CACHE_DRIVER=array -SESSION_DRIVER=file -QUEUE_CONNECTION=sync - -MFA_ENABLED=true diff --git a/scripts/ci/.env.mysql b/scripts/ci/.env.mysql index 9b4d04c4f57..b000832f864 100644 --- a/scripts/ci/.env.mysql +++ b/scripts/ci/.env.mysql @@ -1,19 +1,27 @@ +# ENV FILE FOR THE GITHUB ACTION RUNNING MYSQL APP_ENV=testing APP_KEY=base64:NTrXToqFZJlv48dgPc+kNpc3SBt333TfDnF1mDShsBg= +APP_DEBUG=true APP_URL=http://localhost:8000 -DB_CONNECTION=testing -DB_TEST_HOST=127.0.0.1 -DB_TEST_DATABASE=monica -DB_TEST_USERNAME=root -DB_TEST_PASSWORD= +DB_CONNECTION=mysql +DB_HOST=127.0.0.1 +DB_PORT=3306 +DB_DATABASE=monica +DB_USERNAME=root +DB_PASSWORD=root +DB_USE_UTF8MB4=true -MAIL_FROM_ADDRESS= -MAIL_FROM_NAME= -APP_EMAIL_NEW_USERS_NOTIFICATION= +BROADCAST_DRIVER=log +LOG_CHANNEL=testing +# Values from phpunit.xml +DEBUGBAR_ENABLED=false CACHE_DRIVER=array -SESSION_DRIVER=file QUEUE_CONNECTION=sync -LOG_CHANNEL=testing -BROADCAST_DRIVER=log +SESSION_DRIVER=file +MAIL_MAILER=array + +MAIL_FROM_ADDRESS= +MAIL_FROM_NAME= +APP_EMAIL_NEW_USERS_NOTIFICATION= diff --git a/scripts/ci/fixsecrets.sh b/scripts/ci/fixsecrets.sh deleted file mode 100755 index 06fab08dccf..00000000000 --- a/scripts/ci/fixsecrets.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -if [ "$SONAR_TOKEN" == "\$(SONAR_TOKEN)" ]; then - echo -e "\033[0;36mFix SONAR_TOKEN\033[0;37m" - export SONAR_TOKEN= -fi -if [ "$GITHUB_TOKEN" == "\$(GITHUB_TOKEN)" ]; then - echo -e "\033[0;36mFix GITHUB_TOKEN\033[0;37m" - export GITHUB_TOKEN= -fi -if [ "$ASSETS_USERNAME" == "\$(ASSETS_USERNAME)" ]; then - echo -e "\033[0;36mFix ASSETS_USERNAME\033[0;37m" - export ASSETS_USERNAME= -fi -if [ "$ASSETS_EMAIL" == "\$(ASSETS_EMAIL)" ]; then - echo -e "\033[0;36mFix ASSETS_EMAIL\033[0;37m" - export ASSETS_EMAIL= -fi -if [ "$ASSETS_GITHUB_TOKEN" == "\$(ASSETS_GITHUB_TOKEN)" ]; then - echo -e "\033[0;36mFix ASSETS_GITHUB_TOKEN\033[0;37m" - export ASSETS_GITHUB_TOKEN= -fi -if [ "$STRIPE_SECRET" == "\$(STRIPE_SECRET)" ]; then - echo -e "\033[0;36mFix STRIPE_SECRET\033[0;37m" - export STRIPE_SECRET= -fi -if [ "$CYPRESS_RECORD_KEY" == "\$(CYPRESS_RECORD_KEY)" ]; then - echo -e "\033[0;36mFix CYPRESS_RECORD_KEY\033[0;37m" - export CYPRESS_RECORD_KEY= -fi diff --git a/scripts/ci/rebase.sh b/scripts/ci/rebase.sh deleted file mode 100755 index 25b08693e6d..00000000000 --- a/scripts/ci/rebase.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# Rebase source on top of based branch - -set -exvo pipefail - -export GIT_COMMIT=$(git rev-parse --verify "HEAD^2" 2>/dev/null || echo $BUILD_SOURCEVERSION) -echo -e "GIT_COMMIT=$GIT_COMMIT" -echo -e "##vso[task.setvariable variable=GIT_COMMIT]$GIT_COMMIT" - -git config checkout.defaultRemote origin -git reset --hard "$GIT_COMMIT" - -if [[ $BUILD_SOURCEBRANCH == refs/tags/* ]]; then - git checkout -q "$BUILD_SOURCEBRANCHNAME" -elif [ -n "$SYSTEM_PULLREQUEST_SOURCEBRANCH" ]; then - git checkout -q -B "$SYSTEM_PULLREQUEST_SOURCEBRANCH" -fi - -#git reset --hard "$GIT_COMMIT" -git log -n1 diff --git a/scripts/tests/runsonar.sh b/scripts/tests/runsonar.sh deleted file mode 100755 index 76b01ebb550..00000000000 --- a/scripts/tests/runsonar.sh +++ /dev/null @@ -1,221 +0,0 @@ -#!/bin/bash - -RUNREVPARSE=false -if [ "$CIRCLECI" == "true" ]; then - if [[ ! -z $CIRCLE_PULL_REQUEST ]] ; then - CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}" - REPO=$CIRCLE_PULL_REQUEST - REPO=${REPO##https://github.com/} - REPO=${REPO%%/pull/$CIRCLE_PR_NUMBER} - else - REPO=$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME - fi - BRANCH=${CIRCLE_BRANCH:-$CIRCLE_TAG} - PR_NUMBER=${CIRCLE_PR_NUMBER:-false} - BUILD_NUMBER=$CIRCLE_BUILD_NUM - GIT_COMMIT=$CIRCLE_SHA1 - RUNREVPARSE=true -elif [ "$TRAVIS" == "true" ]; then - REPO=$TRAVIS_REPO_SLUG - BRANCH=${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH} - PR_NUMBER=$TRAVIS_PULL_REQUEST - BUILD_NUMBER=$TRAVIS_BUILD_NUMBER - GIT_COMMIT=${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} -elif [ "$TF_BUILD" == "True" ]; then - REPO=$BUILD_REPOSITORY_NAME - BRANCH=${SYSTEM_PULLREQUEST_SOURCEBRANCH:-$BUILD_SOURCEBRANCHNAME} - PR_NUMBER=${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER:-false} - BUILD_NUMBER=$BUILD_BUILDNUMBER - if [[ -z $GIT_COMMIT ]]; then - GIT_COMMIT=$(git rev-parse --verify "HEAD^2" 2>/dev/null || echo $BUILD_SOURCEVERSION) - fi -elif [[ -n $BUILD_NUMBER ]]; then - echo "CHANGE_ID=$CHANGE_ID" - echo "CHANGE_URL=$CHANGE_URL" - REPO=${CHANGE_URL##https://github.com/} - if [[ ! -z $CHANGE_ID ]] ; then - REPO=${REPO%%/pull/$CHANGE_ID} - fi - PR_NUMBER=${CHANGE_ID:-false} - BRANCH=$BRANCH_NAME -fi - -echo "REPO=$REPO" -echo "BRANCH=$BRANCH" -echo "PR_NUMBER=$PR_NUMBER" -echo "BUILD_NUMBER=$BUILD_NUMBER" -echo "GIT_COMMIT=$GIT_COMMIT" - -set -euo pipefail - -REPOSITORY_OWNER=monicahq/monica -SONAR_ORGANIZATION=monicahq - -function installSonar { - echo '== Setup sonar scanner' - - # set version of sonar scanner to use : - sonarversion=${SONAR_VERSION:-} - if [ -z "${sonarversion:-}" ]; then - sonarversion=4.3.0.2102 - fi - echo "== Using sonarscanner $sonarversion" - - mkdir -p $HOME/sonarscanner - pushd $HOME/sonarscanner > /dev/null - if [ ! -d "sonar-scanner-$sonarversion" ]; then - echo "== Downloading sonarscanner $sonarversion" - java_path=$(which java || true) - if [ -x "$java_path" ]; then - wget --quiet --continue https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$sonarversion.zip - unzip -q sonar-scanner-cli-$sonarversion.zip - rm sonar-scanner-cli-$sonarversion.zip - else - wget --quiet --continue https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$sonarversion-linux.zip - unzip -q sonar-scanner-cli-$sonarversion-linux.zip - rm sonar-scanner-cli-$sonarversion-linux.zip - mv sonar-scanner-$sonarversion-linux sonar-scanner-$sonarversion - fi - else - pushd sonar-scanner-$sonarversion > /dev/null - chmod a+x bin/sonar-scanner - test -f jre/bin/java && chmod a+x jre/bin/java - popd > /dev/null - fi - export SONAR_SCANNER_HOME=$HOME/sonarscanner/sonar-scanner-$sonarversion - export PATH=$SONAR_SCANNER_HOME/bin:$PATH - popd > /dev/null -} - -function CommonParams { - extra="" - if [ "$REPO" != "$REPOSITORY_OWNER" ]; then - # Avoid forks to send reports to the same project - project="${REPO/\//_}" - extra="$extra -Dsonar.projectKey=monica:$project -Dsonar.projectName=$project" - fi - - echo -Dsonar.host.url=$SONAR_HOST_URL \ - -Dsonar.organization=$SONAR_ORGANIZATION \ - -Dsonar.php.tests.reportPath=$SONAR_RESULT \ - -Dsonar.php.coverage.reportPaths=$SONAR_COVERAGE \ - -Dsonar.analysis.buildNumber=$BUILD_NUMBER \ - -Dsonar.analysis.pipeline=$BUILD_NUMBER \ - -Dsonar.analysis.sha1=$GIT_COMMIT \ - -Dsonar.analysis.repository=$REPO \ - $extra -} - -function gitFetch { - echo '== gitFetch' - echo '# git fetch --all' - git fetch --all - if [ "$RUNREVPARSE" == "true" ]; then - if [ -n "${PULL_REQUEST_BASEBRANCH:-}" ]; then - echo "# git branch -D $PULL_REQUEST_BASEBRANCH" - git branch -D $PULL_REQUEST_BASEBRANCH || true - echo "# git rev-parse origin/$PULL_REQUEST_BASEBRANCH" - git rev-parse origin/$PULL_REQUEST_BASEBRANCH - fi - fi - echo '' -} - -function getSonarlauncher { - sonarlauncherversion=0.7.0 - mkdir -p ~/sonarlauncher - pushd ~/sonarlauncher > /dev/null - if [ ! -d "$sonarlauncherversion" ]; then - echo "== Download sonarlauncher $sonarlauncherversion" - mkdir -p ~/sonarlauncher/$sonarlauncherversion - curl -sSL https://github.com/monicahq/sonarlauncher/releases/download/$sonarlauncherversion/sonarlauncher.tar | tar x -C ~/sonarlauncher/$sonarlauncherversion - fi - popd > /dev/null - cp ~/sonarlauncher/$sonarlauncherversion/sonarlauncher . -} - -if [ -z "${SONAR_HOST_URL:-}" ]; then - export SONAR_HOST_URL=https://sonarcloud.io -fi - -if [ "$BRANCH" == "master" ] && [ "$PR_NUMBER" == "false" ] && [ -n "${SONAR_TOKEN:-}" ]; then - echo '==========================' - echo '== SONAR:Analyze master ==' - echo '==========================' - installSonar - gitFetch - - SONAR_PARAMS="$(CommonParams) \ - -Dsonar.projectVersion=master" - - echo "# sonar-scanner $SONAR_PARAMS" - $SONAR_SCANNER_HOME/bin/sonar-scanner $SONAR_PARAMS -Dsonar.login=$SONAR_TOKEN - exit $? - -elif [ -n "${BRANCH:-}" ] && [ "$PR_NUMBER" == "false" ] && [ -n "${SONAR_TOKEN:-}" ]; then - echo '==================================' - echo '== SONAR:Analyze release branch ==' - echo '==================================' - installSonar - gitFetch - - SONAR_PARAMS="$(CommonParams) \ - -Dsonar.projectVersion=$(php artisan monica:getversion)" - - echo "# sonar-scanner $SONAR_PARAMS" - $SONAR_SCANNER_HOME/bin/sonar-scanner $SONAR_PARAMS -Dsonar.login=$SONAR_TOKEN - exit $? - -elif [ "$PR_NUMBER" != "false" ] && [ -n "${SONAR_TOKEN:-}" ] && [ -n "${GITHUB_TOKEN:-}" ]; then - - REPOS_VALUES=($(curl -H "Authorization: token $GITHUB_TOKEN" -sSL https://api.github.com/repos/$REPO/pulls/$PR_NUMBER | jq -r -c ".head.repo.full_name, .head.repo.owner.login, .base.ref, .head.ref")) - - PULL_REQUEST_BRANCH= - PULL_REQUEST_REPOSITORY=${REPOS_VALUES[0]} - PULL_REQUEST_USER=${REPOS_VALUES[1]} - PULL_REQUEST_BASEBRANCH=${REPOS_VALUES[2]} - PULL_REQUEST_HEADBRANCH=${REPOS_VALUES[3]} - - if [ -z "${PULL_REQUEST_REPOSITORY:-}" ] || [ "$PULL_REQUEST_REPOSITORY" == "null" ]; then - echo '== Error with github api call' - exit 11 - elif [ "$PULL_REQUEST_REPOSITORY" == "$REPOSITORY_OWNER" ]; then - echo '=========================================' - echo '== SONAR:Analyze internal pull request ==' - echo '=========================================' - PULL_REQUEST_BRANCH=$PULL_REQUEST_HEADBRANCH - else - echo '=========================================' - echo '== SONAR:Analyze external pull request ==' - echo '=========================================' - echo "== External repository: $PULL_REQUEST_REPOSITORY" - PULL_REQUEST_BRANCH="${PULL_REQUEST_USER}__$PULL_REQUEST_HEADBRANCH" - fi - echo "PULL_REQUEST_BRANCH=$PULL_REQUEST_BRANCH" - echo "PULL_REQUEST_REPOSITORY=$PULL_REQUEST_REPOSITORY" - echo "PULL_REQUEST_USER=$PULL_REQUEST_USER" - echo "PULL_REQUEST_BASEBRANCH=$PULL_REQUEST_BASEBRANCH" - echo "PULL_REQUEST_HEADBRANCH=$PULL_REQUEST_HEADBRANCH" - - installSonar - gitFetch - - SONAR_PARAMS="$(CommonParams) \ - -Dsonar.pullrequest.key=$PR_NUMBER \ - -Dsonar.pullrequest.base=$PULL_REQUEST_BASEBRANCH \ - -Dsonar.pullrequest.branch=$PULL_REQUEST_BRANCH \ - -Dsonar.pullrequest.provider=GitHub \ - -Dsonar.pullrequest.github.repository=$REPO" - - echo "# sonar-scanner $SONAR_PARAMS" - $SONAR_SCANNER_HOME/bin/sonar-scanner $SONAR_PARAMS -Dsonar.login=$SONAR_TOKEN - exit $? - -elif [ ! -x "sonarlauncher" ]; then - - getSonarlauncher - echo '===== Run sonar launcher =====' - ./sonarlauncher - exit $? - -fi diff --git a/scripts/tests/runsonar.sh.sig b/scripts/tests/runsonar.sh.sig deleted file mode 100644 index 0847c3399f4..00000000000 --- a/scripts/tests/runsonar.sh.sig +++ /dev/null @@ -1,16 +0,0 @@ ------BEGIN PGP SIGNATURE----- - -iQIzBAABCgAdFiEEuNgCced4O/05ANeg4OezJU6ORAcFAl7mE1wACgkQ4OezJU6O -RAdeWRAAog33nvJ/iWsvo1uh7fcg+i/jogjm4I5tQqBnX9OoIdR7fw87RFZ09aFb -hHYsEb+ZOW5rgfRDnM2KuR4kQ+SyMamRKd29yyLMSwrlHUdWHM81uev2hqwEF7mT -iymOGVRvXAGe6QrQ+MsXkAdih+d/jbaQxwCYG5JcCQ3Zr5P9ZcOGJr+1ZDBRtb+7 -dtPSL6hEKGtwUsVU9xyPuKaK8dv4von6QtSJGyj+5eX2NIklsElPba/ukv/HrdVD -TxtF0rHn+6KXr3ZD/987EG1N3CCEXugN30E2bmJXw+jER5swJ+pQ7t0mpAZ5N9MN -U2780DOV2sQU3bsP7pfWg2uv7VvwfxfZUFw+Kc/iL5zyfZ6liH0T6cOCrYbiOFVa -w+uoK6zDR6PPdW1AkkY9cACndxB+7/fNJJe1nYh8K9GgimFDKkIKiYPispra3Hli -v1ZA3wGF+mcfGMRH32EfOgUTWo+Il80Ctu0K6z2+GK+k+Ayxf97wvqSyHg+x9Jv6 -P6ZdO2m2ybAGo4AVl067zWltGU9p0H6mDXBvFMx7uepQfkrBOQquwOp5g2SlNh2s -43Sw4XGLBP+yr5x0MuUODrFW1crLRDgHvCjDVPSNRfexhYSL2H5RHu9VoNPcsSdu -HPZqtO5CJmJJC2IQCiYxI7GKp8tGwznyIS7x+DiQMwc+BXG9+X0= -=A98D ------END PGP SIGNATURE----- diff --git a/sonar-project.properties b/sonar-project.properties index 19e6676f567..f33d604b797 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,22 +1,21 @@ # must be unique in a given SonarQube instance sonar.projectKey=monica -# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. sonar.projectName=monica -#sonar.projectVersion= -#sonar.organization=monicahq -#sonar.host.url=https://sonarcloud.io +sonar.organization=monicahq # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. # This property is optional if sonar.modules is set. -sonar.sources=app,bootstrap,config,public,resources,routes -#sonar.exclusions=bootstrap/cache/*,public/css/*,public/js/*,public/storage/* +sonar.sources=app,bootstrap,config,database,public,resources,routes +sonar.exclusions=bootstrap/cache/*,public/vendor/**,resources/lang/** sonar.tests=tests +sonar.coverage.exclusions=routes/*.php,config/*.php,bootstrap/**,resources/**/*.php,database/factories/*,database/migrations/*.php,public/*.php,resources/**/*.vue,resources/**/*.js +sonar.cpd.exclusions=routes/*.php,config/*.php,bootstrap/**,resources/**/*.php,database/**/*.php # Encoding of the source code. Default is default system encoding sonar.sourceEncoding=UTF-8 # Links for sonarcloud.io page sonar.links.homepage=https://monicahq.com -sonar.links.ci=https://dev.azure.com/monicahq/monica +sonar.links.ci=https://github.com/monicahq/monica/actions sonar.links.scm=https://github.com/monicahq/monica sonar.links.issue=https://github.com/monicahq/monica/issues diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php index 23479d63f30..aa2c042180d 100644 --- a/tests/DuskTestCase.php +++ b/tests/DuskTestCase.php @@ -32,7 +32,7 @@ protected function setUp(): void */ public static function prepare() { - if (env('SAUCELABS') != '1') { + if (! static::runningInSail()) { static::startChromeDriver(); } } @@ -44,22 +44,32 @@ public static function prepare() */ protected function driver() { - $options = (new ChromeOptions)->addArguments(explode(' ', env('CHROME_DRIVER_OPTS', ''))); - $capabilities = DesiredCapabilities::chrome()->setCapability( - ChromeOptions::CAPABILITY, $options + $options = (new ChromeOptions)->addArguments(collect([ + '--window-size=1920,1080', + ])->unless($this->hasHeadlessDisabled(), function ($items) { + return $items->merge([ + '--disable-gpu', + '--headless', + ]); + })->all()); + + return RemoteWebDriver::create( + $_ENV['DUSK_DRIVER_URL'] ?? 'http://localhost:9515', + DesiredCapabilities::chrome()->setCapability( + ChromeOptions::CAPABILITY, $options + ) ); + } - if (env('SAUCELABS') == '1') { - $capabilities->setCapability('tunnel-identifier', env('TRAVIS_JOB_NUMBER')); - - return RemoteWebDriver::create( - 'http://'.env('SAUCE_USERNAME').':'.env('SAUCE_ACCESS_KEY').'@localhost:4445/wd/hub', $capabilities - ); - } else { - return RemoteWebDriver::create( - 'http://localhost:9515', $capabilities - ); - } + /** + * Determine whether the Dusk command has disabled headless mode. + * + * @return bool + */ + protected function hasHeadlessDisabled() + { + return isset($_SERVER['DUSK_HEADLESS_DISABLED']) || + isset($_ENV['DUSK_HEADLESS_DISABLED']); } /**