diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/application.rb | 2 | ||||
-rw-r--r-- | config/initializers/rspec_profiling.rb | 50 | ||||
-rw-r--r-- | config/initializers/trusted_proxies.rb | 6 | ||||
-rw-r--r-- | config/karma.config.js | 14 | ||||
-rw-r--r-- | config/routes/group.rb | 1 | ||||
-rw-r--r-- | config/webpack.config.js | 58 |
6 files changed, 89 insertions, 42 deletions
diff --git a/config/application.rb b/config/application.rb index 1c11e347281..6bdf61edfb1 100644 --- a/config/application.rb +++ b/config/application.rb @@ -94,6 +94,7 @@ module Gitlab # - Webhook URLs (:hook) # - Sentry DSN (:sentry_dsn) # - File content from Web Editor (:content) + # - Jira shared secret (:sharedSecret) # # NOTE: It is **IMPORTANT** to also update gitlab-workhorse's filter when adding parameters here to not # introduce another security vulnerability: https://gitlab.com/gitlab-org/gitlab-workhorse/issues/182 @@ -108,6 +109,7 @@ module Gitlab trace variables content + sharedSecret ) # Enable escaping HTML in JSON. diff --git a/config/initializers/rspec_profiling.rb b/config/initializers/rspec_profiling.rb index 2de310753a9..715e17057e0 100644 --- a/config/initializers/rspec_profiling.rb +++ b/config/initializers/rspec_profiling.rb @@ -1,7 +1,28 @@ +# frozen_string_literal: true + +return unless Rails.env.test? + module RspecProfilingExt - module PSQL - def establish_connection - ::RspecProfiling::Collectors::PSQL::Result.establish_connection(ENV['RSPEC_PROFILING_POSTGRES_URL']) + module Collectors + class CSVWithTimestamps < ::RspecProfiling::Collectors::CSV + TIMESTAMP_FIELDS = %w(created_at updated_at).freeze + HEADERS = (::RspecProfiling::Collectors::CSV::HEADERS + TIMESTAMP_FIELDS).freeze + + def insert(attributes) + output << HEADERS.map do |field| + if TIMESTAMP_FIELDS.include?(field) + Time.now + else + attributes.fetch(field.to_sym) + end + end + end + + private + + def output + @output ||= ::CSV.open(path, "w").tap { |csv| csv << HEADERS } + end end end @@ -10,9 +31,13 @@ module RspecProfilingExt if ENV['CI_COMMIT_REF_NAME'] "#{defined?(Gitlab::License) ? 'ee' : 'ce'}:#{ENV['CI_COMMIT_REF_NAME']}" else - super + super&.chomp end end + + def sha + super&.chomp + end end module Run @@ -30,16 +55,11 @@ module RspecProfilingExt end end -if Rails.env.test? - RspecProfiling.configure do |config| - if ENV['RSPEC_PROFILING_POSTGRES_URL'].present? - RspecProfiling::Collectors::PSQL.prepend(RspecProfilingExt::PSQL) - config.collector = RspecProfiling::Collectors::PSQL - end - - if ENV.key?('CI') - RspecProfiling::VCS::Git.prepend(RspecProfilingExt::Git) - RspecProfiling::Run.prepend(RspecProfilingExt::Run) - end +RspecProfiling.configure do |config| + if ENV.key?('CI') || ENV.key?('RSPEC_PROFILING') + RspecProfiling::VCS::Git.prepend(RspecProfilingExt::Git) + RspecProfiling::Run.prepend(RspecProfilingExt::Run) + config.collector = RspecProfilingExt::Collectors::CSVWithTimestamps + config.csv_path = -> { "rspec_profiling/#{Time.now.to_i}-#{SecureRandom.hex(8)}-rspec-data.csv" } end end diff --git a/config/initializers/trusted_proxies.rb b/config/initializers/trusted_proxies.rb index 7af465d8443..13896408806 100644 --- a/config/initializers/trusted_proxies.rb +++ b/config/initializers/trusted_proxies.rb @@ -14,10 +14,8 @@ module Rack end gitlab_trusted_proxies = Array(Gitlab.config.gitlab.trusted_proxies).map do |proxy| - begin - IPAddr.new(proxy) - rescue IPAddr::InvalidAddressError - end + IPAddr.new(proxy) +rescue IPAddr::InvalidAddressError end.compact Rails.application.config.action_dispatch.trusted_proxies = ( diff --git a/config/karma.config.js b/config/karma.config.js index 746c11ebd64..1d6ff797a29 100644 --- a/config/karma.config.js +++ b/config/karma.config.js @@ -26,7 +26,7 @@ webpackConfig.devtool = 'cheap-inline-source-map'; webpackConfig.plugins.push( new webpack.DefinePlugin({ 'process.env.BABEL_ENV': JSON.stringify(process.env.BABEL_ENV || process.env.NODE_ENV || null), - }) + }), ); const specFilters = argumentsParser @@ -37,7 +37,7 @@ const specFilters = argumentsParser memo.push(filter, filter.replace(/\/?$/, '/**/*.js')); return memo; }, - [] + [], ) .parse(process.argv).filterSpec; @@ -51,7 +51,7 @@ if (specFilters.length) { root: ROOT_PATH, matchBase: true, }) - .filter(path => path.endsWith('spec.js')) + .filter(path => path.endsWith('spec.js')), ); // flatten @@ -78,8 +78,8 @@ if (specFilters.length) { new webpack.ContextReplacementPlugin( /spec[\\\/]javascripts$/, path.join(ROOT_PATH, 'spec/javascripts'), - newContext - ) + newContext, + ), ); } @@ -112,7 +112,7 @@ module.exports = function(config) { preprocessors: { 'spec/javascripts/**/*.js': ['webpack', 'sourcemap'], }, - reporters: ['progress'], + reporters: ['mocha'], webpack: webpackConfig, webpackMiddleware: { stats: 'errors-only' }, plugins: [ @@ -127,7 +127,7 @@ module.exports = function(config) { }; if (process.env.CI) { - karmaConfig.reporters = ['mocha', 'junit']; + karmaConfig.reporters.push('junit'); karmaConfig.junitReporter = { outputFile: 'junit_karma.xml', useBrowserName: false, diff --git a/config/routes/group.rb b/config/routes/group.rb index b3015529c6e..f42c1ee6e7d 100644 --- a/config/routes/group.rb +++ b/config/routes/group.rb @@ -31,6 +31,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do namespace :settings do resource :ci_cd, only: [:show], controller: 'ci_cd' do put :reset_registration_token + patch :update_auto_devops end end diff --git a/config/webpack.config.js b/config/webpack.config.js index 64e6ec49219..55122e341c3 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -1,3 +1,4 @@ +const fs = require('fs'); const path = require('path'); const glob = require('glob'); const webpack = require('webpack'); @@ -11,6 +12,10 @@ const ROOT_PATH = path.resolve(__dirname, '..'); const CACHE_PATH = process.env.WEBPACK_CACHE_PATH || path.join(ROOT_PATH, 'tmp/cache'); const IS_PRODUCTION = process.env.NODE_ENV === 'production'; const IS_DEV_SERVER = process.argv.join(' ').indexOf('webpack-dev-server') !== -1; +const IS_EE = + process.env.EE !== undefined + ? JSON.parse(process.env.EE) + : fs.existsSync(path.join(ROOT_PATH, 'ee')); const DEV_SERVER_HOST = process.env.DEV_SERVER_HOST || 'localhost'; const DEV_SERVER_PORT = parseInt(process.env.DEV_SERVER_PORT, 10) || 3808; const DEV_SERVER_LIVERELOAD = IS_DEV_SERVER && process.env.DEV_SERVER_LIVERELOAD !== 'false'; @@ -44,6 +49,14 @@ function generateEntries() { pageEntries.forEach(path => generateAutoEntries(path)); + if (IS_EE) { + const eePageEntries = glob.sync('pages/**/index.js', { + cwd: path.join(ROOT_PATH, 'ee/app/assets/javascripts'), + }); + eePageEntries.forEach(path => generateAutoEntries(path, 'ee')); + watchAutoEntries.push(path.join(ROOT_PATH, 'ee/app/assets/javascripts/pages/')); + } + const autoEntryKeys = Object.keys(autoEntriesMap); autoEntriesCount = autoEntryKeys.length; @@ -68,6 +81,31 @@ function generateEntries() { return Object.assign(manualEntries, autoEntries); } +const alias = { + '~': path.join(ROOT_PATH, 'app/assets/javascripts'), + emojis: path.join(ROOT_PATH, 'fixtures/emojis'), + empty_states: path.join(ROOT_PATH, 'app/views/shared/empty_states'), + icons: path.join(ROOT_PATH, 'app/views/shared/icons'), + images: path.join(ROOT_PATH, 'app/assets/images'), + vendor: path.join(ROOT_PATH, 'vendor/assets/javascripts'), + vue$: 'vue/dist/vue.esm.js', + spec: path.join(ROOT_PATH, 'spec/javascripts'), + + // the following resolves files which are different between CE and EE + ee_else_ce: path.join(ROOT_PATH, 'app/assets/javascripts'), +}; + +if (IS_EE) { + Object.assign(alias, { + ee: path.join(ROOT_PATH, 'ee/app/assets/javascripts'), + ee_empty_states: path.join(ROOT_PATH, 'ee/app/views/shared/empty_states'), + ee_icons: path.join(ROOT_PATH, 'ee/app/views/shared/icons'), + ee_images: path.join(ROOT_PATH, 'ee/app/assets/images'), + ee_spec: path.join(ROOT_PATH, 'ee/spec/javascripts'), + ee_else_ce: path.join(ROOT_PATH, 'ee/app/assets/javascripts'), + }); +} + module.exports = { mode: IS_PRODUCTION ? 'production' : 'development', @@ -85,19 +123,7 @@ module.exports = { resolve: { extensions: ['.js', '.gql', '.graphql'], - alias: { - '~': path.join(ROOT_PATH, 'app/assets/javascripts'), - emojis: path.join(ROOT_PATH, 'fixtures/emojis'), - empty_states: path.join(ROOT_PATH, 'app/views/shared/empty_states'), - icons: path.join(ROOT_PATH, 'app/views/shared/icons'), - images: path.join(ROOT_PATH, 'app/assets/images'), - vendor: path.join(ROOT_PATH, 'vendor/assets/javascripts'), - vue$: 'vue/dist/vue.esm.js', - spec: path.join(ROOT_PATH, 'spec/javascripts'), - - // the following resolves files which are different between CE and EE - ee_else_ce: path.join(ROOT_PATH, 'app/assets/javascripts'), - }, + alias, }, module: { @@ -251,7 +277,7 @@ module.exports = { } else { resource.request = path.join( ROOT_PATH, - 'app/assets/javascripts/vue_shared/components/empty_component.js' + 'app/assets/javascripts/vue_shared/components/empty_component.js', ); } }), @@ -267,7 +293,7 @@ module.exports = { const missingDeps = Array.from(compilation.missingDependencies); const nodeModulesPath = path.join(ROOT_PATH, 'node_modules'); const hasMissingNodeModules = missingDeps.some( - file => file.indexOf(nodeModulesPath) !== -1 + file => file.indexOf(nodeModulesPath) !== -1, ); // watch for changes to missing node_modules @@ -278,7 +304,7 @@ module.exports = { // report our auto-generated bundle count console.log( - `${autoEntriesCount} entries from '/pages' automatically added to webpack output.` + `${autoEntriesCount} entries from '/pages' automatically added to webpack output.`, ); callback(); |