diff --git a/.drone.star b/.drone.star index 85598b2fec6d..a7988995db7b 100644 --- a/.drone.star +++ b/.drone.star @@ -58,9 +58,6 @@ config = { "master", ], "dependencies": True, - "codestyle": True, - "phpstan": True, - "phan": True, "javascript": True, "litmus": True, "dav": True, @@ -508,10 +505,10 @@ def main(ctx): return initial + before + coverageTests + afterCoverageTests + nonCoverageTests + stages def initialPipelines(ctx): - return dependencies(ctx) + checkStarlark() + checkGitCommit() + return dependencies(ctx) + checkStarlark() def beforePipelines(ctx): - return codestyle(ctx) + changelog(ctx) + phpstan(ctx) + phan(ctx) + return changelog(ctx) def coveragePipelines(ctx): # All unit test pipelines that have coverage or other test analysis reported @@ -593,10 +590,6 @@ def dependencies(ctx): "steps": cacheRestore() + cacheClearOnEventPush(phpVersion) + composerInstall(phpVersion) + - vendorbinCodestyle(phpVersion) + - vendorbinCodesniffer(phpVersion) + - vendorbinPhan(phpVersion) + - vendorbinPhpstan(phpVersion) + vendorbinBehat() + yarnInstall() + cacheRebuildOnEventPush() + @@ -617,80 +610,6 @@ def dependencies(ctx): return pipelines -def codestyle(ctx): - pipelines = [] - - if "codestyle" not in config: - return pipelines - - default = { - "phpVersions": [DEFAULT_PHP_VERSION], - } - - if "defaults" in config: - if "codestyle" in config["defaults"]: - for item in config["defaults"]["codestyle"]: - default[item] = config["defaults"]["codestyle"][item] - - codestyleConfig = config["codestyle"] - - if type(codestyleConfig) == "bool": - if codestyleConfig: - # the config has 'codestyle' true, so specify an empty dict that will get the defaults - codestyleConfig = {} - else: - return pipelines - - if len(codestyleConfig) == 0: - # 'codestyle' is an empty dict, so specify a single section that will get the defaults - codestyleConfig = {"doDefault": {}} - - for category, matrix in codestyleConfig.items(): - params = {} - for item in default: - params[item] = matrix[item] if item in matrix else default[item] - - for phpVersion in params["phpVersions"]: - name = "coding-standard-php%s" % phpVersion - - result = { - "kind": "pipeline", - "type": "docker", - "name": name, - "workspace": { - "base": dir["base"], - "path": "src", - }, - "steps": skipIfUnchanged(ctx, "lint") + - cacheRestore() + - composerInstall(phpVersion) + - vendorbinCodestyle(phpVersion) + - vendorbinCodesniffer(phpVersion) + - [ - { - "name": "php-style", - "image": OC_CI_PHP % phpVersion, - "commands": [ - "make test-php-style", - ], - }, - ], - "depends_on": [], - "trigger": { - "ref": [ - "refs/pull/**", - "refs/tags/**", - ], - }, - } - - for branch in config["branches"]: - result["trigger"]["ref"].append("refs/heads/%s" % branch) - - pipelines.append(result) - - return pipelines - def changelog(ctx): repo_slug = ctx.build.source_repo if ctx.build.source_repo else ctx.repo.slug pipelines = [] @@ -785,150 +704,6 @@ def changelog(ctx): return pipelines -def phpstan(ctx): - pipelines = [] - - if "phpstan" not in config: - return pipelines - - default = { - "phpVersions": [DEFAULT_PHP_VERSION], - "logLevel": "2", - } - - if "defaults" in config: - if "phpstan" in config["defaults"]: - for item in config["defaults"]["phpstan"]: - default[item] = config["defaults"]["phpstan"][item] - - phpstanConfig = config["phpstan"] - - if type(phpstanConfig) == "bool": - if phpstanConfig: - # the config has 'phpstan' true, so specify an empty dict that will get the defaults - phpstanConfig = {} - else: - return pipelines - - if len(phpstanConfig) == 0: - # 'phpstan' is an empty dict, so specify a single section that will get the defaults - phpstanConfig = {"doDefault": {}} - - for category, matrix in phpstanConfig.items(): - params = {} - for item in default: - params[item] = matrix[item] if item in matrix else default[item] - - for phpVersion in params["phpVersions"]: - name = "phpstan-php%s" % phpVersion - - result = { - "kind": "pipeline", - "type": "docker", - "name": name, - "workspace": { - "base": dir["base"], - "path": "src", - }, - "steps": skipIfUnchanged(ctx, "lint") + - cacheRestore() + - composerInstall(phpVersion) + - vendorbinPhpstan(phpVersion) + - installServer(phpVersion, "sqlite", params["logLevel"]) + - enableAppsForPhpStan(phpVersion) + - [ - { - "name": "php-phpstan", - "image": OC_CI_PHP % phpVersion, - "commands": [ - "make test-php-phpstan", - ], - }, - ], - "depends_on": [], - "trigger": { - "ref": [ - "refs/pull/**", - "refs/tags/**", - ], - }, - } - - pipelines.append(result) - - return pipelines - -def phan(ctx): - pipelines = [] - - if "phan" not in config: - return pipelines - - default = { - "phpVersions": [DEFAULT_PHP_VERSION], - "logLevel": "2", - } - - if "defaults" in config: - if "phan" in config["defaults"]: - for item in config["defaults"]["phan"]: - default[item] = config["defaults"]["phan"][item] - - phanConfig = config["phan"] - - if type(phanConfig) == "bool": - if phanConfig: - # the config has 'phan' true, so specify an empty dict that will get the defaults - phanConfig = {} - else: - return pipelines - - if len(phanConfig) == 0: - # 'phan' is an empty dict, so specify a single section that will get the defaults - phanConfig = {"doDefault": {}} - - for category, matrix in phanConfig.items(): - params = {} - for item in default: - params[item] = matrix[item] if item in matrix else default[item] - - for phpVersion in params["phpVersions"]: - name = "phan-php%s" % phpVersion - - result = { - "kind": "pipeline", - "type": "docker", - "name": name, - "workspace": { - "base": dir["base"], - "path": "src", - }, - "steps": skipIfUnchanged(ctx, "lint") + cacheRestore() + - composerInstall(phpVersion) + - vendorbinPhan(phpVersion) + - installServer(phpVersion, "sqlite", params["logLevel"]) + - [ - { - "name": "phan", - "image": OC_CI_PHP % phpVersion, - "commands": [ - "make test-php-phan", - ], - }, - ], - "depends_on": [], - "trigger": { - "ref": [ - "refs/pull/**", - "refs/tags/**", - ], - }, - } - - pipelines.append(result) - - return pipelines - def litmus(): pipelines = [] @@ -2391,54 +2166,6 @@ def composerInstall(phpVersion): ], }] -def vendorbinCodestyle(phpVersion): - return [{ - "name": "vendorbin-codestyle", - "image": OC_CI_PHP % phpVersion, - "environment": { - "COMPOSER_HOME": "%s/.cache/composer" % dir["server"], - }, - "commands": [ - "make vendor-bin-codestyle", - ], - }] - -def vendorbinCodesniffer(phpVersion): - return [{ - "name": "vendorbin-codesniffer", - "image": OC_CI_PHP % phpVersion, - "environment": { - "COMPOSER_HOME": "%s/.cache/composer" % dir["server"], - }, - "commands": [ - "make vendor-bin-codesniffer", - ], - }] - -def vendorbinPhan(phpVersion): - return [{ - "name": "vendorbin-phan", - "image": OC_CI_PHP % phpVersion, - "environment": { - "COMPOSER_HOME": "%s/.cache/composer" % dir["server"], - }, - "commands": [ - "make vendor-bin-phan", - ], - }] - -def vendorbinPhpstan(phpVersion): - return [{ - "name": "vendorbin-phpstan", - "image": OC_CI_PHP % phpVersion, - "environment": { - "COMPOSER_HOME": "%s/.cache/composer" % dir["server"], - }, - "commands": [ - "make vendor-bin-phpstan", - ], - }] - def vendorbinBehat(): return [{ "name": "vendorbin-behat", @@ -2577,18 +2304,6 @@ def installServer(phpVersion, db, logLevel = "2", ssl = False, federatedServerNe ], }] -def enableAppsForPhpStan(phpVersion): - return [{ - "name": "enable-apps-for-phpstan", - "image": OC_CI_PHP % phpVersion, - "commands": [ - # files_external can be disabled. - # We need it to be enabled so that the PHP static analyser can find classes in it. - "php occ a:e files_external", - "php occ a:l", - ], - }] - def installAndConfigureFederated(ctx, federatedServerVersion, phpVersion, logLevel, protocol, db, dbSuffix = "fed"): return [ installFederated(ctx, federatedServerVersion, db, dbSuffix), @@ -2951,25 +2666,6 @@ def checkStarlark(): }, }] -def checkGitCommit(): - return [{ - "kind": "pipeline", - "type": "docker", - "name": "check-git-commit-messages", - "steps": [ - { - "name": "format-check-git-commit", - "image": "aevea/commitsar:latest", - }, - ], - "depends_on": [], - "trigger": { - "ref": [ - "refs/pull/**", - ], - }, - }] - def skipIfUnchanged(ctx, type): if ("full-ci" in ctx.build.title.lower()): return [] diff --git a/.github/workflows/lint-and-codestyle.yml b/.github/workflows/lint-and-codestyle.yml new file mode 100644 index 000000000000..5c8161b75786 --- /dev/null +++ b/.github/workflows/lint-and-codestyle.yml @@ -0,0 +1,72 @@ +name: Lint and Code Style + +on: + push: + branches: + - master + pull_request: + types: + - opened + - synchronize + - reopened + +permissions: + contents: read + +concurrency: + group: lint-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint-php-codestyle: + name: PHP Code Style + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-version: ["7.4"] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: curl, gd, json, xml, zip + ini-values: "memory_limit=1024M" + tools: phpstan, codesniffer + + - name: Install Composer dependencies + run: | + make install-composer-deps + make vendor-bin-deps + + - name: Install Server + run: | + DATA_DIRECTORY=$(pwd)/data bash tests/drone/install-server.sh + + - name: Run PHP Code Style Checks + run: | + make test-php-style + + - name: Run PHP Stan + run: | + make test-php-phpstan + + - name: Run PHP Phan + run: | + make test-php-phan + + git-commit-messages: + name: Git Commit Messages + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Validate commit messages + uses: docker://aevea/commitsar:latest +