diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-04-04 20:04:39 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-04-04 20:04:39 +0100 |
commit | 85b45ce94de94a85bb341d2978f1471a21b9a0ff (patch) | |
tree | ab65c6cfefc07fd2a65c20e15d7fda98047886bb /scripts | |
parent | dd3b1526af1675f7686f189ec41b8d919b6835a2 (diff) | |
parent | cb5bb4dbc67c5dd43bb7b27faf79ca79f8ae3e1f (diff) | |
download | gitlab-ce-85b45ce94de94a85bb341d2978f1471a21b9a0ff.tar.gz |
[ci skip] Merge branch 'master' into 44427-state-management-with-vuex
* master: (544 commits)
Bulk deleting refs is handled by Gitaly by default
Allow assigning and filtering issuables by ancestor group labels
Fix links to subdirectories of a directory with a plus character in its path
Add banzai filter to detect commit message trailers and properly link the users
Render MR commit SHA instead "diffs" when viable
Fix a transient failure by removing unneeded expectations
Revert changelog entry for removed feature
Revert "Allow CI/CD Jobs being grouped on version strings"
Add support for Sidekiq JSON logging
Resolve "Protected branches count is wrong when a wildcard includes several protected branches"
Remove unused form for admin application settings
Use standard codequality job
Resolve "Allow the configuration of a project's merge method via the API"
Move the rest of application settings to expandable blocks
[Rails5] Rename `sort` methods to `sort_by_attribute`
Add better LDAP connection handling
Updated components to PascalCase
Handle invalid params when trying update_username
Move network related app settings to expandable blocks
[Rails5] Update Gemfile.rails5.lock [ci skip]
...
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/codequality | 19 | ||||
-rw-r--r-- | scripts/frontend/frontend_script_utils.js | 8 | ||||
-rw-r--r-- | scripts/frontend/prettier.js | 40 | ||||
-rwxr-xr-x | scripts/lint-doc.sh | 34 | ||||
-rwxr-xr-x | scripts/trigger-build-omnibus | 3 |
5 files changed, 61 insertions, 43 deletions
diff --git a/scripts/codequality b/scripts/codequality deleted file mode 100755 index 2f3ccef7d2d..00000000000 --- a/scripts/codequality +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -set -eo pipefail - -code_path=$(pwd) - -# docker run --tty will merge stderr and stdout, we don't need this on CI or -# it will break codequality json file -[ "$CI" != "" ] || docker_tty="--tty" - -# The codebase and instructions for the following image can be found at https://gitlab.com/gitlab-org/codeclimate-rubocop/wikis/home -docker pull dev.gitlab.org:5005/gitlab/gitlab-build-images:gitlab-codeclimate-rubocop-0-52-1 > /dev/null -docker tag dev.gitlab.org:5005/gitlab/gitlab-build-images:gitlab-codeclimate-rubocop-0-52-1 codeclimate/codeclimate-rubocop:gitlab-codeclimate-rubocop-0-52-1 > /dev/null - -exec docker run --rm $docker_tty --env CODECLIMATE_CODE="$code_path" \ - --volume "$code_path":/code \ - --volume /var/run/docker.sock:/var/run/docker.sock \ - --volume /tmp/cc:/tmp/cc \ - "codeclimate/codeclimate:${CODECLIMATE_VERSION:-0.71.1}" "$@" diff --git a/scripts/frontend/frontend_script_utils.js b/scripts/frontend/frontend_script_utils.js index 2c06747255c..e42b912d359 100644 --- a/scripts/frontend/frontend_script_utils.js +++ b/scripts/frontend/frontend_script_utils.js @@ -1,4 +1,3 @@ -/* eslint import/no-commonjs: "off" */ const execFileSync = require('child_process').execFileSync; const exec = (command, args) => { @@ -18,12 +17,7 @@ const execGitCmd = args => module.exports = { getStagedFiles: fileExtensionFilter => { - const gitOptions = [ - 'diff', - '--name-only', - '--cached', - '--diff-filter=ACMRTUB', - ]; + const gitOptions = ['diff', '--name-only', '--cached', '--diff-filter=ACMRTUB']; if (fileExtensionFilter) gitOptions.push(...fileExtensionFilter); return execGitCmd(gitOptions); }, diff --git a/scripts/frontend/prettier.js b/scripts/frontend/prettier.js index 863572bf64d..39de77bc333 100644 --- a/scripts/frontend/prettier.js +++ b/scripts/frontend/prettier.js @@ -1,7 +1,8 @@ -/* eslint import/no-commonjs: "off", import/no-extraneous-dependencies: "off", no-console: "off" */ const glob = require('glob'); const prettier = require('prettier'); const fs = require('fs'); +const path = require('path'); +const prettierIgnore = require('ignore')(); const getStagedFiles = require('./frontend_script_utils').getStagedFiles; @@ -11,6 +12,10 @@ const allFiles = mode === 'check-all' || mode === 'save-all'; const config = { patterns: ['**/*.js', '**/*.vue', '**/*.scss'], + /* + * The ignore patterns below are just to reduce search time with glob, as it includes the + * folders with the most ignored assets, the actual `.prettierignore` will be used later on + */ ignore: ['**/node_modules/**', '**/vendor/**', '**/public/**'], parsers: { js: 'babylon', @@ -18,13 +23,25 @@ const config = { scss: 'css', }, }; + +/* + * Unfortunately the prettier API does not expose support for `.prettierignore` files, they however + * use the ignore package, so we do the same. We simply cannot use the glob package, because + * gitignore style is not compatible with globs ignore style. + */ +prettierIgnore.add( + fs + .readFileSync(path.join(__dirname, '../../', '.prettierignore')) + .toString() + .trim() + .split(/\r?\n/) +); + const availableExtensions = Object.keys(config.parsers); console.log(`Loading ${allFiles ? 'All' : 'Staged'} Files ...`); -const stagedFiles = allFiles - ? null - : getStagedFiles(availableExtensions.map(ext => `*.${ext}`)); +const stagedFiles = allFiles ? null : getStagedFiles(availableExtensions.map(ext => `*.${ext}`)); if (stagedFiles) { if (!stagedFiles.length || (stagedFiles.length === 1 && !stagedFiles[0])) { @@ -41,17 +58,14 @@ let files; if (allFiles) { const ignore = config.ignore; const patterns = config.patterns; - const globPattern = - patterns.length > 1 ? `{${patterns.join(',')}}` : `${patterns.join(',')}`; - files = glob - .sync(globPattern, { ignore }) - .filter(f => allFiles || stagedFiles.includes(f)); + const globPattern = patterns.length > 1 ? `{${patterns.join(',')}}` : `${patterns.join(',')}`; + files = glob.sync(globPattern, { ignore }).filter(f => allFiles || stagedFiles.includes(f)); } else { - files = stagedFiles.filter(f => - availableExtensions.includes(f.split('.').pop()), - ); + files = stagedFiles.filter(f => availableExtensions.includes(f.split('.').pop())); } +files = prettierIgnore.filter(files); + if (!files.length) { console.log('No Files found to process with Prettier'); return; @@ -81,7 +95,7 @@ prettier } else if (!prettier.check(input, options)) { if (!didWarn) { console.log( - '\n===============================\nGitLab uses Prettier to format all JavaScript code.\nPlease format each file listed below or run "yarn prettier-staged-save"\n===============================\n', + '\n===============================\nGitLab uses Prettier to format all JavaScript code.\nPlease format each file listed below or run "yarn prettier-staged-save"\n===============================\n' ); didWarn = true; } diff --git a/scripts/lint-doc.sh b/scripts/lint-doc.sh index e5242fee32b..178b209aacf 100755 --- a/scripts/lint-doc.sh +++ b/scripts/lint-doc.sh @@ -3,7 +3,7 @@ cd "$(dirname "$0")/.." # Use long options (e.g. --header instead of -H) for curl examples in documentation. -echo 'Checking for curl short options...' +echo '=> Checking for cURL short options...' grep --extended-regexp --recursive --color=auto 'curl (.+ )?-[^- ].*' doc/ >/dev/null 2>&1 if [ $? == 0 ] then @@ -15,7 +15,7 @@ fi # Ensure that the CHANGELOG.md does not contain duplicate versions DUPLICATE_CHANGELOG_VERSIONS=$(grep --extended-regexp '^## .+' CHANGELOG.md | sed -E 's| \(.+\)||' | sort -r | uniq -d) -echo 'Checking for CHANGELOG.md duplicate entries...' +echo '=> Checking for CHANGELOG.md duplicate entries...' if [ "${DUPLICATE_CHANGELOG_VERSIONS}" != "" ] then echo '✖ ERROR: Duplicate versions in CHANGELOG.md:' >&2 @@ -25,7 +25,7 @@ fi # Make sure no files in doc/ are executable EXEC_PERM_COUNT=$(find doc/ app/ -type f -perm 755 | wc -l) -echo 'Checking for executable permissions...' +echo '=> Checking for executable permissions...' if [ "${EXEC_PERM_COUNT}" -ne 0 ] then echo '✖ ERROR: Executable permissions should not be used in documentation! Use `chmod 644` to the files in question:' >&2 @@ -33,5 +33,33 @@ then exit 1 fi +# Do not use 'README.md', instead use 'index.md' +# Number of 'README.md's as of 2018-03-26 +NUMBER_READMES_CE=42 +NUMBER_READMES_EE=46 +FIND_READMES=$(find doc/ -name "README.md" | wc -l) +echo '=> Checking for new README.md files...' +if [ "${CI_PROJECT_NAME}" == 'gitlab-ce' ] +then + if [ ${FIND_READMES} -ne ${NUMBER_READMES_CE} ] + then + echo + echo ' ✖ ERROR: New README.md file(s) detected, prefer index.md over README.md.' >&2 + echo ' https://docs.gitlab.com/ee/development/writing_documentation.html#location-and-naming-documents' + echo + exit 1 + fi +elif [ "${CI_PROJECT_NAME}" == 'gitlab-ee' ] +then + if [ ${FIND_READMES} -ne $NUMBER_READMES_EE ] + then + echo + echo ' ✖ ERROR: New README.md file(s) detected, prefer index.md over README.md.' >&2 + echo ' https://docs.gitlab.com/ee/development/writing_documentation.html#location-and-naming-documents' + echo + exit 1 + fi +fi + echo "✔ Linting passed" exit 0 diff --git a/scripts/trigger-build-omnibus b/scripts/trigger-build-omnibus index 85ea4aa74ac..95f35b44f5a 100755 --- a/scripts/trigger-build-omnibus +++ b/scripts/trigger-build-omnibus @@ -9,6 +9,7 @@ module Omnibus class Trigger TOKEN = ENV['BUILD_TRIGGER_TOKEN'] + TRIGGERER = ENV['CI_PROJECT_NAME'] def initialize @uri = URI("https://gitlab.com/api/v4/projects/#{CGI.escape(Omnibus::PROJECT_PATH)}/trigger/pipeline") @@ -32,7 +33,7 @@ module Omnibus private def ee? - File.exist?('CHANGELOG-EE.md') + TRIGGERER == 'gitlab-ee' || File.exist?('CHANGELOG-EE.md') end def env_params |