Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #41 from owncloud/update_php_and_db_version
Browse files Browse the repository at this point in the history
fix CI, update php and db versions
  • Loading branch information
wkloucek authored Sep 9, 2021
2 parents d5f6406 + 02c8080 commit 62debc6
Show file tree
Hide file tree
Showing 14 changed files with 2,280 additions and 1,595 deletions.
3,315 changes: 1,967 additions & 1,348 deletions .drone.star

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions .drone/cancelBuilds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
SCRIPT_PATH=$(dirname "$0")
SCRIPT_PATH=$( cd "${SCRIPT_PATH}" && pwd ) # normalized and made absolute

if [ -z "${OWNCLOUD_APP}" ]
then
echo "OWNCLOUD_APP environment variable is required to be defined as the organisation and repo name in the format: owncloud/app_name"
exit 1
fi
# The recentBuilds.txt file contains all the information of the PR whose builds are recently running.
# Therefore, to filter out the BuildID and the Reference from all the recent builds which are running,
# the following awk command is used and the output containing the BuildId and the Reference of each
# builds/prs are stored in the filteredDescriptions.txt file.
awk "/Build #|Ref: refs\/pull/" ${SCRIPT_PATH}/../recentBuilds.txt > ${SCRIPT_PATH}/filteredDescriptions.txt

# The thisBuildInfo.txt file contains the information of the current Build, including the BuildID, Reference, and
# other information of that particular build. To get the reference number/ pr number of the recent build,
# the following awk command and grep commands are used, where the Reference part ("Ref: refs/pull/5496/head")
# is stored in the "thisBuildFiltered.txt" file. From the reference, only the pr/reference number is extracted into
# the "NUMBER" variable.
awk "/Ref: refs\/pull/" ${SCRIPT_PATH}/../thisBuildInfo.txt > ${SCRIPT_PATH}/thisBuildFiltered.txt
NUMBER=$(grep -o -E "[0-9]+" ${SCRIPT_PATH}/thisBuildFiltered.txt)
referenceNum="Ref: refs/pull/"$NUMBER"/head"

# From all the recent builds, the information about the BuildID and the reference which was stored in the
# "filteredDescriptions.txt" file, only the BuildID part from each of the buildInformation whose Reference is
# exactly same as that of the current build reference is filtered and stored in the "buildsToStop.txt" file.
# The buildIDs and the reference information of each build is stored sequentially in the "filteredDescriptions.txt" file as:

# "Build #<buildID-1>"
# "<ReferenceInformationOfBuildID-1>"
# "Build #<buildID-2>"
# "<ReferenceInformationOfBuildID-2>"
# "Build #<buildID-n>"
# "<ReferenceInformationOfBuildID-n>"

# Therefore the following awk command extracts each lines just above the expected reference information.
awk -v ref="$referenceNum" 'index($0,ref){print p} {p=$0}' ${SCRIPT_PATH}/filteredDescriptions.txt > ${SCRIPT_PATH}/buildsToStop.txt


# The "buildsToStop.txt" file now contains the buildIDs of the recent builds whose reference id was equal to the reference of the
# current pr/build.

# "Build #<BuildID-1>"
# "Build #<BuildID-2>"
# "Build #<BuildID-3>"
# "Build #<BuildID-4>"
# "Build #<BuildID-m>"

# For each build in the "buildsToStop.txt" file, if the build number is older than the current drone build number, the build is cancelled.

while IFS="" read -r p || [ -n "$p" ]
do
printf '%s\n' "$p"
buildNumber=$(echo "$p" | awk -F'#' '{print $(2)}')

if [ $DRONE_BUILD_NUMBER \> "$buildNumber" ]
then
echo "CANCELLING BUILD: " $buildNumber
drone build stop $OWNCLOUD_APP $buildNumber
fi

done <${SCRIPT_PATH}/buildsToStop.txt
13 changes: 13 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

$config = new OC\CodingStandard\Config();

$config
->setUsingCache(true)
->getFinder()
->exclude('l10n')
->exclude('vendor')
->exclude('vendor-bin')
->in(__DIR__);

return $config;
13 changes: 0 additions & 13 deletions .php_cs.dist

This file was deleted.

179 changes: 105 additions & 74 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,89 +1,108 @@
SHELL := /bin/bash

YARN := $(shell command -v yarn 2> /dev/null)
NODE_PREFIX=$(shell pwd)
COMPOSER_BIN := $(shell command -v composer 2> /dev/null)

NPM := $(shell command -v npm 2> /dev/null)
ifndef NPM
$(error npm is not available on your system, please install npm)
endif
# directories
app_name=$(notdir $(CURDIR))
build_dir=$(CURDIR)/build
dist_dir=$(build_dir)/dist
doc_files=README.md LICENSE
src_dirs=appinfo lib vendor
all_src=$(src_dirs) $(doc_files)

app_name=qnap
acceptance_test_deps=vendor-bin/behat/vendor

# bin file definitions
PHPUNIT=php -d zend.enable_gc=0 "$(PWD)/../../lib/composer/bin/phpunit"
PHPUNITDBG=phpdbg -qrr -d memory_limit=4096M -d zend.enable_gc=0 "$(PWD)/../../lib/composer/bin/phpunit"
PHPUNIT=php -d zend.enable_gc=0 ../../lib/composer/bin/phpunit
PHPUNITDBG=phpdbg -qrr -d memory_limit=4096M -d zend.enable_gc=0 "../../lib/composer/bin/phpunit"
PHP_CS_FIXER=php -d zend.enable_gc=0 vendor-bin/owncloud-codestyle/vendor/bin/php-cs-fixer
PHAN=php -d zend.enable_gc=0 vendor-bin/phan/vendor/bin/phan
PHPSTAN=php -d zend.enable_gc=0 vendor-bin/phpstan/vendor/bin/phpstan
BEHAT_BIN=vendor-bin/behat/vendor/bin/behat

occ?=$(CURDIR)/../../occ
private_key?=$(HOME)/.owncloud/certificates/$(app_name).key
certificate?=$(HOME)/.owncloud/certificates/$(app_name).crt
sign?=$(occ) integrity:sign-app --privateKey="$(private_key)" --certificate="$(certificate)"
sign_skip_msg="Skipping signing, either no key and certificate found in $(private_key) and $(certificate) or occ can not be found at $(occ)"
ifneq (,$(wildcard $(private_key)))
ifneq (,$(wildcard $(certificate)))
ifneq (,$(wildcard $(occ)))
CAN_SIGN=true
endif
endif
endif

KARMA=$(NODE_PREFIX)/node_modules/.bin/karma

.DEFAULT_GOAL := all
# start with displaying help
.DEFAULT_GOAL := help

help:
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' | sed -e 's/ */ /' | column -t -s :

##
## Entrypoints
##----------------------

.PHONY: all
all: install-deps

# Remove the appstore build
.PHONY: clean
clean: clean-nodejs-deps clean-composer-deps
rm -rf ./build

.PHONY: clean-nodejs-deps
clean-nodejs-deps:
rm -Rf $(nodejs_deps)
clean: clean-composer-deps clean-build-dir clean-vendor

.PHONY: clean-composer-deps
clean-composer-deps:
rm -rf ./vendor
rm -Rf vendor-bin/**/vendor vendor-bin/**/composer.lock

.PHONY: dev
dev: ## Initialize dev environment
dev: install-deps
.PHONY: clean-vendor
clean-vendor:
rm -Rf vendor

.PHONY: clean-build-dir
clean-build-dir:
rm -Rf $(build_dir)

##---------------------
## Build targets
##---------------------

#
# Release
# make this app compatible with the ownCloud
# default build tools
#
.PHONY: dist
dist:
make -f Makefile.release dist
dist: ## Build distribution
dist: vendor distdir sign package

.PHONY: distdir
distdir:
rm -rf $(build_dir)
mkdir -p $(dist_dir)/$(app_name)
cp -R $(all_src) $(dist_dir)/$(app_name)

.PHONY: sign
sign:
ifdef CAN_SIGN
$(sign) --path="$(dist_dir)/$(app_name)"
else
@echo $(sign_skip_msg)
endif

$(KARMA): $(nodejs_deps)
.PHONY: package
package:
tar -czf $(dist_dir)/$(app_name).tar.gz -C $(dist_dir) $(app_name)

##
##---------------------
## Tests
##----------------------
##---------------------

.PHONY: test-php-unit
test-php-unit: ## Run php unit tests
test-php-unit: vendor/bin/phpunit
$(PHPUNIT) --configuration ./phpunit.xml --testsuite qnap-unit
test-php-unit: ../../lib/composer/bin/phpunit
$(PHPUNIT) --configuration ./phpunit.xml --testsuite unit

.PHONY: test-php-unit-dbg
test-php-unit-dbg: ## Run php unit tests using phpdbg
test-php-unit-dbg: vendor/bin/phpunit
$(PHPUNITDBG) --configuration ./phpunit.xml --testsuite qnap-unit
test-php-unit-dbg: ../../lib/composer/bin/phpunit
$(PHPUNITDBG) --configuration ./phpunit.xml --testsuite unit

.PHONY: test-php-style
test-php-style: ## Run php-cs-fixer and check owncloud code-style
test-php-style: vendor-bin/owncloud-codestyle/vendor
$(PHP_CS_FIXER) fix -v --diff --diff-format udiff --allow-risky yes --dry-run
$(PHP_CS_FIXER) fix -v --diff --allow-risky yes --dry-run

.PHONY: test-php-style-fix
test-php-style-fix: ## Run php-cs-fixer and fix code style issues
test-php-style-fix: vendor-bin/owncloud-codestyle/vendor
$(PHP_CS_FIXER) fix -v --diff --diff-format udiff --allow-risky yes
$(PHP_CS_FIXER) fix -v --diff --allow-risky yes

.PHONY: test-php-phan
test-php-phan: ## Run phan
Expand All @@ -95,9 +114,30 @@ test-php-phpstan: ## Run phpstan
test-php-phpstan: vendor-bin/phpstan/vendor
$(PHPSTAN) analyse --memory-limit=4G --configuration=./phpstan.neon --no-progress --level=5 appinfo lib

.PHONY: test-js
test-js: $(nodejs_deps)
$(KARMA) start tests/js/karma.config.js --single-run
.PHONY: test-acceptance-api
test-acceptance-api: ## Run API acceptance tests
test-acceptance-api: $(acceptance_test_deps)
BEHAT_BIN=$(BEHAT_BIN) ../../tests/acceptance/run.sh --remote --type api

.PHONY: test-acceptance-cli
test-acceptance-cli: ## Run CLI acceptance tests
test-acceptance-cli: $(acceptance_test_deps)
BEHAT_BIN=$(BEHAT_BIN) ../../tests/acceptance/run.sh --remote --type cli

.PHONY: test-acceptance-webui
test-acceptance-webui: ## Run webUI acceptance tests
test-acceptance-webui: $(acceptance_test_deps)
BEHAT_BIN=$(BEHAT_BIN) ../../tests/acceptance/run.sh --remote --type webUI

.PHONY: test-acceptance-core-api
test-acceptance-core-api: ## Run core API acceptance tests
test-acceptance-core-api: $(acceptance_test_deps)
BEHAT_BIN=$(BEHAT_BIN) ../../tests/acceptance/run.sh --remote --type api -c ../../tests/acceptance/config/behat.yml --tags '~@skipOnEncryption&&~@skipOnEncryptionType:${ENCRYPTION_TYPE}&&~@skip'

.PHONY: test-acceptance-core-webui
test-acceptance-core-webui: ## Run core webUI acceptance tests
test-acceptance-core-webui: $(acceptance_test_deps)
BEHAT_BIN=$(BEHAT_BIN) ../../tests/acceptance/run.sh --remote --type webui -c ../../tests/acceptance/config/behat.yml --tags '~@skipOnEncryption&&~@skipOnEncryptionType:${ENCRYPTION_TYPE}&&~@skip'

#
# Translation
Expand Down Expand Up @@ -128,48 +168,39 @@ l10n-write: l10n/l10n.pl
l10n/l10n.pl:
wget -qO l10n/l10n.pl https://raw.githubusercontent.com/owncloud-ci/transifex/d1c63674d791fe8812216b29da9d8f2f26e7e138/rootfs/usr/bin/l10n

##
## Dependency management
##----------------------

.PHONY: install-deps
install-deps: ## Install dependencies
install-deps: install-php-deps install-js-deps
#
# Dependency management
#----------------------

composer.lock: composer.json
@echo composer.lock is not up to date.

.PHONY: install-php-deps
install-php-deps: ## Install PHP dependencies
install-php-deps: vendor vendor-bin composer.json composer.lock

.PHONY: install-js-deps
install-js-deps: ## Install PHP dependencies
install-js-deps: $(nodejs_deps)

vendor: composer.lock
$(COMPOSER_BIN) install --no-dev
vendor:
composer install --no-dev

vendor/bin/phpunit: composer.lock
$(COMPOSER_BIN) install

vendor/bamarni/composer-bin-plugin: composer.lock
$(COMPOSER_BIN) install
vendor/bamarni/composer-bin-plugin:
composer install

vendor-bin/owncloud-codestyle/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/owncloud-codestyle/composer.lock
$(COMPOSER_BIN) bin owncloud-codestyle install --no-progress
composer bin owncloud-codestyle install --no-progress

vendor-bin/owncloud-codestyle/composer.lock: vendor-bin/owncloud-codestyle/composer.json
@echo owncloud-codestyle composer.lock is not up to date.

vendor-bin/phan/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/phan/composer.lock
$(COMPOSER_BIN) bin phan install --no-progress
composer bin phan install --no-progress

vendor-bin/phan/composer.lock: vendor-bin/phan/composer.json
@echo phan composer.lock is not up to date.

vendor-bin/phpstan/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/phpstan/composer.lock
$(COMPOSER_BIN) bin phpstan install --no-progress
composer bin phpstan install --no-progress

vendor-bin/phpstan/composer.lock: vendor-bin/phpstan/composer.json
@echo phpstan composer.lock is not up to date.

vendor-bin/behat/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/behat/composer.lock
composer bin behat install --no-progress

vendor-bin/behat/composer.lock: vendor-bin/behat/composer.json
@echo behat composer.lock is not up to date.
Loading

0 comments on commit 62debc6

Please sign in to comment.