diff --git a/app/assets/javascripts/diffs/components/diff_table_cell.vue b/app/assets/javascripts/diffs/components/diff_table_cell.vue
index 514d26862a3df8898e66d653758b52ebf6b41ebf..198113e330a2fa8df49d90083e7b1e069e363bee 100644
--- a/app/assets/javascripts/diffs/components/diff_table_cell.vue
+++ b/app/assets/javascripts/diffs/components/diff_table_cell.vue
@@ -4,15 +4,13 @@ import { GlIcon } from '@gitlab/ui';
import { getParameterByName, parseBoolean } from '~/lib/utils/common_utils';
import DiffGutterAvatars from './diff_gutter_avatars.vue';
import {
- MATCH_LINE_TYPE,
CONTEXT_LINE_TYPE,
LINE_POSITION_RIGHT,
EMPTY_CELL_TYPE,
- OLD_LINE_TYPE,
OLD_NO_NEW_LINE_TYPE,
+ OLD_LINE_TYPE,
NEW_NO_NEW_LINE_TYPE,
LINE_HOVER_CLASS_NAME,
- LINE_UNFOLD_CLASS_NAME,
} from '../constants';
export default {
@@ -29,10 +27,6 @@ export default {
type: String,
required: true,
},
- contextLinesPath: {
- type: String,
- required: true,
- },
isHighlighted: {
type: Boolean,
required: true,
@@ -52,11 +46,6 @@ export default {
required: false,
default: '',
},
- isContentLine: {
- type: Boolean,
- required: false,
- default: false,
- },
isBottom: {
type: Boolean,
required: false,
@@ -68,6 +57,11 @@ export default {
default: false,
},
},
+ data() {
+ return {
+ isCommentButtonRendered: false,
+ };
+ },
computed: {
...mapGetters(['isLoggedIn']),
lineCode() {
@@ -81,13 +75,7 @@ export default {
return `#${this.line.line_code || ''}`;
},
shouldShowCommentButton() {
- return (
- this.isHover &&
- !this.isMatchLine &&
- !this.isContextLine &&
- !this.isMetaLine &&
- !this.hasDiscussions
- );
+ return this.isHover && !this.isContextLine && !this.isMetaLine && !this.hasDiscussions;
},
hasDiscussions() {
return this.line.discussions && this.line.discussions.length > 0;
@@ -99,6 +87,10 @@ export default {
return this.showCommentButton && this.hasDiscussions;
},
shouldRenderCommentButton() {
+ if (!this.isCommentButtonRendered) {
+ return false;
+ }
+
if (this.isLoggedIn && this.showCommentButton) {
const isDiffHead = parseBoolean(getParameterByName('diff_head'));
return !isDiffHead || gon.features?.mergeRefHeadComments;
@@ -106,9 +98,6 @@ export default {
return false;
},
- isMatchLine() {
- return this.line.type === MATCH_LINE_TYPE;
- },
isContextLine() {
return this.line.type === CONTEXT_LINE_TYPE;
},
@@ -126,13 +115,8 @@ export default {
type,
{
hll: this.isHighlighted,
- [LINE_UNFOLD_CLASS_NAME]: this.isMatchLine,
[LINE_HOVER_CLASS_NAME]:
- this.isLoggedIn &&
- this.isHover &&
- !this.isMatchLine &&
- !this.isContextLine &&
- !this.isMetaLine,
+ this.isLoggedIn && this.isHover && !this.isContextLine && !this.isMetaLine,
},
];
},
@@ -140,6 +124,17 @@ export default {
return this.lineType === OLD_LINE_TYPE ? this.line.old_line : this.line.new_line;
},
},
+ mounted() {
+ this.unwatchShouldShowCommentButton = this.$watch('shouldShowCommentButton', newVal => {
+ if (newVal) {
+ this.isCommentButtonRendered = true;
+ this.unwatchShouldShowCommentButton();
+ }
+ });
+ },
+ beforeDestroy() {
+ this.unwatchShouldShowCommentButton();
+ },
methods: {
...mapActions('diffs', ['showCommentForm', 'setHighlightedRow', 'toggleLineDiscussions']),
handleCommentButton() {
@@ -151,34 +146,32 @@ export default {
-
+
+
+
+
|
diff --git a/app/assets/javascripts/diffs/components/inline_diff_table_row.vue b/app/assets/javascripts/diffs/components/inline_diff_table_row.vue
index bd99fcb71b8b548ff94b5d25397665dfde03aded..4e228577666f287b9110a880ac66ac0a6c01db0b 100644
--- a/app/assets/javascripts/diffs/components/inline_diff_table_row.vue
+++ b/app/assets/javascripts/diffs/components/inline_diff_table_row.vue
@@ -28,10 +28,6 @@ export default {
type: String,
required: true,
},
- contextLinesPath: {
- type: String,
- required: true,
- },
line: {
type: Object,
required: true,
@@ -106,7 +102,6 @@ export default {
>
diff --git a/app/assets/javascripts/diffs/components/parallel_diff_table_row.vue b/app/assets/javascripts/diffs/components/parallel_diff_table_row.vue
index 83d803f42b14fb389407b1d7473a0ade50755fc5..c2553dc87a6b3500cfc560478e9554a509ec18e0 100644
--- a/app/assets/javascripts/diffs/components/parallel_diff_table_row.vue
+++ b/app/assets/javascripts/diffs/components/parallel_diff_table_row.vue
@@ -31,10 +31,6 @@ export default {
type: String,
required: true,
},
- contextLinesPath: {
- type: String,
- required: true,
- },
line: {
type: Object,
required: true,
@@ -144,7 +140,6 @@ export default {
diff --git a/app/models/concerns/reactive_caching.rb b/app/models/concerns/reactive_caching.rb
index d294563139cf305466223a23719bd989cd6c9049..5f30fc0c36c4f789b24b6b3eea311f55a3340744 100644
--- a/app/models/concerns/reactive_caching.rb
+++ b/app/models/concerns/reactive_caching.rb
@@ -29,7 +29,7 @@ module ReactiveCaching
self.reactive_cache_lease_timeout = 2.minutes
self.reactive_cache_refresh_interval = 1.minute
self.reactive_cache_lifetime = 10.minutes
- self.reactive_cache_hard_limit = 1.megabyte
+ self.reactive_cache_hard_limit = nil # this value should be set in megabytes. E.g: 1.megabyte
self.reactive_cache_work_type = :default
self.reactive_cache_worker_finder = ->(id, *_args) do
find_by(primary_key => id)
@@ -159,8 +159,12 @@ module ReactiveCaching
WORK_TYPE.fetch(self.class.reactive_cache_work_type.to_sym)
end
+ def reactive_cache_limit_enabled?
+ !!self.reactive_cache_hard_limit
+ end
+
def check_exceeded_reactive_cache_limit!(data)
- return unless Feature.enabled?(:reactive_cache_limit)
+ return unless reactive_cache_limit_enabled?
data_deep_size = Gitlab::Utils::DeepSize.new(data, max_size: self.class.reactive_cache_hard_limit)
diff --git a/app/models/environment.rb b/app/models/environment.rb
index 103d34f753d17cea36806e7856ee98dfb74fd5ae..a3b8f220f0077993210271c9dddd73e3acb6ec37 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -362,6 +362,11 @@ class Environment < ApplicationRecord
def generate_slug
self.slug = Gitlab::Slug::Environment.new(name).generate
end
+
+ # Overrides ReactiveCaching default to activate limit checking behind a FF
+ def reactive_cache_limit_enabled?
+ Feature.enabled?(:reactive_caching_limit_environment, project)
+ end
end
Environment.prepend_if_ee('EE::Environment')
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 68ff336a1bb2ee4291bd556e523d0c7184c3df07..699f82c7e6be71489a32e01dc94a47ba2b956dac 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -26,7 +26,6 @@ class MergeRequest < ApplicationRecord
self.reactive_cache_key = ->(model) { [model.project.id, model.iid] }
self.reactive_cache_refresh_interval = 10.minutes
self.reactive_cache_lifetime = 10.minutes
- self.reactive_cache_hard_limit = 20.megabytes
SORTING_PREFERENCE_FIELD = :merge_requests_sort
diff --git a/changelogs/unreleased/update_android_ci.yml b/changelogs/unreleased/update_android_ci.yml
new file mode 100644
index 0000000000000000000000000000000000000000..62a99d5b3288c5d1f80bb7b3f86937f28b250a21
--- /dev/null
+++ b/changelogs/unreleased/update_android_ci.yml
@@ -0,0 +1,5 @@
+---
+title: Updated the Android CI Script
+merge_request: 34007
+author: s-ayush2903
+type: fixed
diff --git a/config/initializers/01_secret_token.rb b/config/initializers/01_secret_token.rb
index 8b96727a2a14efd2403a397ec64152253563f2cd..5949f463457cedea3915d3d245ca982a93553eaa 100644
--- a/config/initializers/01_secret_token.rb
+++ b/config/initializers/01_secret_token.rb
@@ -1,13 +1,5 @@
-# WARNING: If you add a new secret to this file, make sure you also
-# update Omnibus GitLab or updates will fail. Omnibus is responsible for
-# writing the `secrets.yml` file. If Omnibus doesn't know about a
-# secret, Rails will attempt to write to the file, but this will fail
-# because Rails doesn't have write access.
-#
-# As an example:
-# * https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/27581
-# * https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/3267
-#
+# WARNING: Before you make a change to secrets.yml, read the development guide for GitLab secrets
+# doc/development/application_secrets.md.
#
# This file needs to be loaded BEFORE any initializers that attempt to
# prepend modules that require access to secrets (e.g. EE's 0_as_concern.rb).
diff --git a/doc/development/application_secrets.md b/doc/development/application_secrets.md
new file mode 100644
index 0000000000000000000000000000000000000000..7d8c5b407c3abc6ddbda1ccd74101d2ca033bab8
--- /dev/null
+++ b/doc/development/application_secrets.md
@@ -0,0 +1,41 @@
+# Application secrets
+
+This page is a development guide for application secrets.
+
+## Secret entries
+
+|Entry |Description |
+|--- |--- |
+|`secret_key_base` | The base key to be used for generating a various secrets |
+| `otp_key_base` | The base key for One Time Passwords, described in [User management](../raketasks/user_management.md#rotate-two-factor-authentication-encryption-key) |
+|`db_key_base` | The base key to encrypt the data for `attr_encrypted` columns |
+|`openid_connect_signing_key` | The singing key for OpenID Connect |
+
+## Where the secrets are stored
+
+|Installation type |Location |
+|--- |--- |
+|Omnibus |[`/etc/gitlab/gitlab-secrets.json`](https://docs.gitlab.com/omnibus/settings/backups.html#backup-and-restore-omnibus-gitlab-configuration) |
+|Cloud Native GitLab Charts |[Kubernets Secrets](https://gitlab.com/gitlab-org/charts/gitlab/-/blob/f65c3d37fc8cf09a7987544680413552fb666aac/doc/installation/secrets.md#gitlab-rails-secret)|
+|Source |`/config/secrets.yml` (Automatically generated by [01_secret_token.rb](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/initializers/01_secret_token.rb)) |
+
+## Warning: Before you add a new secret to application secrets
+
+Before you add a new secret to [`config/initializers/01_secret_token.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/initializers/01_secret_token.rb),
+make sure you also update Omnibus GitLab or updates will fail. Omnibus is responsible for writing the `secrets.yml` file.
+If Omnibus doesn't know about a secret, Rails will attempt to write to the file, but this will fail because Rails doesn't have write access.
+The same rules apply to Cloud Native GitLab charts, you must update the charts at first.
+In case you need the secret to have same value on each node (which is usually the case) you need to make sure it's configured for all
+GitLab.com environments prior to changing this file.
+
+**Examples**
+
+- [Change for source installation](https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/27581)
+- [Change for omnibus installation](https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/3267)
+- [Change for omnibus installation](https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/4158)
+- [Change for Cloud Native installation](https://gitlab.com/gitlab-org/charts/gitlab/-/merge_requests/1318)
+
+## Further iteration
+
+We might deprecate/remove this automatic secret generation '01_secret_token.rb' in the future.
+Please see [this issue](https://gitlab.com/gitlab-org/gitlab/-/issues/222690) for more information.
diff --git a/doc/development/foreign_keys.md b/doc/development/foreign_keys.md
index 508e5665f0885a7c7ddee464fc8b0f0ccded030d..8a81dc158a7d5c9eaeee88728145456ec2bb3e12 100644
--- a/doc/development/foreign_keys.md
+++ b/doc/development/foreign_keys.md
@@ -35,6 +35,17 @@ When adding a foreign key in PostgreSQL the column is not indexed automatically,
thus you must also add a concurrent index. Not doing so will result in cascading
deletes being very slow.
+## Naming foreign keys
+
+By default Ruby on Rails uses the `_id` suffix for foreign keys. So we should
+only use this suffix for associations between two tables. If you want to
+reference an ID on a third party platform the `_xid` suffix is recommended.
+
+The spec `spec/db/schema_spec.rb` will test if all columns with the `_id` suffix
+have a foreign key constraint. So if that spec fails, don't add the column to
+`IGNORED_FK_COLUMNS`, but instead add the FK constraint, or consider naming it
+differently.
+
## Dependent Removals
Don't define options such as `dependent: :destroy` or `dependent: :delete` when
diff --git a/doc/user/project/integrations/prometheus.md b/doc/user/project/integrations/prometheus.md
index c65e82d24f5ccd103f47fc4a029483526f69eb79..58257d1bfd8dee5beb5b69b15620c74d638d5c57 100644
--- a/doc/user/project/integrations/prometheus.md
+++ b/doc/user/project/integrations/prometheus.md
@@ -846,6 +846,29 @@ templating:
default: true # (Optional) This option should be the default value of this variable.
```
+##### `metric_label_values` variable type
+
+CAUTION: **Warning:**
+This variable type is an _alpha_ feature, and is subject to change at any time
+without prior notice!
+
+###### Full syntax
+
+This example creates a variable called `variable2`. The values of the dropdown will
+be all the different values of the `backend` label in the Prometheus series described by
+`up{env="production"}`.
+
+```yaml
+templating:
+ variables:
+ variable2: # The variable name that can be interpolated in queries.
+ label: 'Variable 2' # (Optional) label that will appear in the UI for this dropdown.
+ type: metric_label_values
+ options:
+ series_selector: 'up{env="production"}'
+ label: 'backend'
+```
+
### Add related links to custom dashboards
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/216385) in GitLab 13.1.
diff --git a/lib/gitlab/ci/templates/Android.gitlab-ci.yml b/lib/gitlab/ci/templates/Android.gitlab-ci.yml
index b7194110002d844fcd8e5358db307c4fd1612d20..d20dabc0b0005d2d838055210b74103859f413cc 100644
--- a/lib/gitlab/ci/templates/Android.gitlab-ci.yml
+++ b/lib/gitlab/ci/templates/Android.gitlab-ci.yml
@@ -4,32 +4,65 @@
image: openjdk:8-jdk
variables:
- ANDROID_COMPILE_SDK: "28"
- ANDROID_BUILD_TOOLS: "28.0.2"
- ANDROID_SDK_TOOLS: "4333796"
+ # ANDROID_COMPILE_SDK is the version of Android you're compiling with.
+ # It should match compileSdkVersion.
+ ANDROID_COMPILE_SDK: "29"
+
+ # ANDROID_BUILD_TOOLS is the version of the Android build tools you are using.
+ # It should match buildToolsVersion.
+ ANDROID_BUILD_TOOLS: "29.0.3"
+
+ # It's what version of the command line tools we're going to download from the official site.
+ # Official Site-> https://developer.android.com/studio/index.html
+ # There, look down below at the cli tools only, sdk tools package is of format:
+ # commandlinetools-os_type-ANDROID_SDK_TOOLS_latest.zip
+ # when the script was last modified for latest compileSdkVersion, it was which is written down below
+ ANDROID_SDK_TOOLS: "6514223"
+
+# Packages installation before running script
before_script:
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
- - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip
- - unzip -d android-sdk-linux android-sdk.zip
- - echo y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
- - echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null
- - echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
- - export ANDROID_HOME=$PWD/android-sdk-linux
- - export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
+
+ # Setup path as android_home for moving/exporting the downloaded sdk into it
+ - export ANDROID_HOME="${PWD}/android-home"
+ # Create a new directory at specified location
+ - install -d $ANDROID_HOME
+ # Here we are installing androidSDK tools from official source,
+ # (the key thing here is the url from where you are downloading these sdk tool for command line, so please do note this url pattern there and here as well)
+ # after that unzipping those tools and
+ # then running a series of SDK manager commands to install necessary android SDK packages that'll allow the app to build
+ - wget --output-document=$ANDROID_HOME/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip
+ # move to the archive at ANDROID_HOME
+ - pushd $ANDROID_HOME
+ - unzip -d cmdline-tools cmdline-tools.zip
+ - popd
+ - export PATH=$PATH:${ANDROID_HOME}/cmdline-tools/tools/bin/
+
+ # Nothing fancy here, just checking sdkManager version
+ - sdkmanager --version
+
+ # use yes to accept all licenses
+ - yes | sdkmanager --sdk_root=${ANDROID_HOME} --licenses || true
+ - sdkmanager --sdk_root=${ANDROID_HOME} "platforms;android-${ANDROID_COMPILE_SDK}"
+ - sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools"
+ - sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;${ANDROID_BUILD_TOOLS}"
+
+ # Not necessary, but just for surity
- chmod +x ./gradlew
- # temporarily disable checking for EPIPE error and use yes to accept all licenses
- - set +o pipefail
- - yes | android-sdk-linux/tools/bin/sdkmanager --licenses
- - set -o pipefail
+# Basic android and gradle stuff
+# Check linting
lintDebug:
+ interruptible: true
stage: build
script:
- ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint
+# Make Project
assembleDebug:
+ interruptible: true
stage: build
script:
- ./gradlew assembleDebug
@@ -37,7 +70,9 @@ assembleDebug:
paths:
- app/build/outputs/
+# Run all tests, if any fails, interrupt the pipeline(fail it)
debugTests:
+ interruptible: true
stage: test
script:
- ./gradlew -Pci --console=plain :app:testDebug
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index e791fd771d7ba46586c6e7dd42ca9cd03c52fad9..b59decbff72acbfa4bb37b51af9e79025defde0b 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -25434,6 +25434,9 @@ msgstr ""
msgid "VulnerabilityManagement|Something went wrong while trying to delete the comment. Please try again later."
msgstr ""
+msgid "VulnerabilityManagement|Something went wrong while trying to refresh the vulnerability. Please try again later."
+msgstr ""
+
msgid "VulnerabilityManagement|Something went wrong while trying to retrieve the vulnerability history. Please try again later."
msgstr ""
diff --git a/spec/db/schema_spec.rb b/spec/db/schema_spec.rb
index 2322babcd531a58b480bf448447061d187604df2..51ffd143836d984191c53b8b288bbe21f127ba89 100644
--- a/spec/db/schema_spec.rb
+++ b/spec/db/schema_spec.rb
@@ -10,8 +10,8 @@ RSpec.describe 'Database schema' do
let(:tables) { connection.tables }
let(:columns_name_with_jsonb) { retrieve_columns_name_with_jsonb }
- # Use if you are certain that this column should not have a foreign key
- # EE: edit the ee/spec/db/schema_support.rb
+ # List of columns historically missing a FK, don't add more columns
+ # See: https://docs.gitlab.com/ce/development/foreign_keys.html#naming-foreign-keys
IGNORED_FK_COLUMNS = {
abuse_reports: %w[reporter_id user_id],
application_settings: %w[performance_bar_allowed_group_id slack_app_id snowplow_app_id eks_account_id eks_access_key_id],
@@ -119,7 +119,11 @@ RSpec.describe 'Database schema' do
let(:ignored_columns) { ignored_fk_columns(table) }
it 'do have the foreign keys' do
- expect(column_names_with_id - ignored_columns).to contain_exactly(*foreign_keys_columns)
+ expect(column_names_with_id - ignored_columns).to match_array(foreign_keys_columns)
+ end
+
+ it 'and having foreign key are not in the ignore list' do
+ expect(ignored_columns).to match_array(ignored_columns - foreign_keys)
end
end
end
diff --git a/spec/frontend/diffs/components/diff_table_cell_spec.js b/spec/frontend/diffs/components/diff_table_cell_spec.js
index e871d86d9016bfa1e69a29991ee36962b7529578..9693fe68b57af1d16382ea9876e9d505a1a9b06a 100644
--- a/spec/frontend/diffs/components/diff_table_cell_spec.js
+++ b/spec/frontend/diffs/components/diff_table_cell_spec.js
@@ -100,7 +100,11 @@ describe('DiffTableCell', () => {
setWindowLocation({ href: `${TEST_HOST}?${query}` });
createComponent({ showCommentButton });
- expect(findNoteButton().exists()).toBe(expectation);
+ wrapper.setData({ isCommentButtonRendered: showCommentButton });
+
+ return wrapper.vm.$nextTick().then(() => {
+ expect(findNoteButton().exists()).toBe(expectation);
+ });
},
);
@@ -108,7 +112,6 @@ describe('DiffTableCell', () => {
isHover | otherProps | discussions | expectation
${true} | ${{}} | ${[]} | ${true}
${false} | ${{}} | ${[]} | ${false}
- ${true} | ${{ line: { ...line, type: 'match' } }} | ${[]} | ${false}
${true} | ${{ line: { ...line, type: 'context' } }} | ${[]} | ${false}
${true} | ${{ line: { ...line, type: 'old-nonewline' } }} | ${[]} | ${false}
${true} | ${{}} | ${[{}]} | ${false}
@@ -122,7 +125,13 @@ describe('DiffTableCell', () => {
...otherProps,
});
- expect(findNoteButton().isVisible()).toBe(expectation);
+ wrapper.setData({
+ isCommentButtonRendered: true,
+ });
+
+ return wrapper.vm.$nextTick().then(() => {
+ expect(findNoteButton().isVisible()).toBe(expectation);
+ });
},
);
});
diff --git a/spec/initializers/secret_token_spec.rb b/spec/initializers/secret_token_spec.rb
index a9360e10ee0684588c0c8d1ced6a41d510e0b3d2..362371e0962da61bc1620148fa55b6e63a89de88 100644
--- a/spec/initializers/secret_token_spec.rb
+++ b/spec/initializers/secret_token_spec.rb
@@ -19,6 +19,30 @@ RSpec.describe 'create_tokens' do
allow(self).to receive(:exit)
end
+ describe 'ensure acknowledged secrets in any installations' do
+ let(:acknowledged_secrets) do
+ %w[secret_key_base otp_key_base db_key_base openid_connect_signing_key]
+ end
+
+ it 'does not allow to add a new secret without a proper handling' do
+ create_tokens
+
+ secrets_hash = YAML.load_file(Rails.root.join('config/secrets.yml'))
+
+ secrets_hash.each do |environment, secrets|
+ new_secrets = secrets.keys - acknowledged_secrets
+
+ expect(new_secrets).to be_empty,
+ <<~EOS
+ CAUTION:
+ It looks like you have just added new secret(s) #{new_secrets.inspect} to the secrets.yml.
+ Please read the development guide for GitLab secrets at doc/development/application_secrets.md before you proceed this change.
+ If you're absolutely sure that the change is safe, please add the new secrets to the 'acknowledged_secrets' in order to silence this warning.
+ EOS
+ end
+ end
+ end
+
context 'setting secret keys' do
context 'when none of the secrets exist' do
before do
diff --git a/spec/models/concerns/reactive_caching_spec.rb b/spec/models/concerns/reactive_caching_spec.rb
index cfca383e0b0ba2a69ba0905afbe5a7f7b5aec832..c7427da736843c0f5c635da11d153bc1b3589c82 100644
--- a/spec/models/concerns/reactive_caching_spec.rb
+++ b/spec/models/concerns/reactive_caching_spec.rb
@@ -285,38 +285,30 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
go!
end
- context 'when calculated object size exceeds default reactive_cache_hard_limit' do
- let(:calculation) { -> { 'a' * 2 * 1.megabyte } }
+ context 'when reactive_cache_hard_limit is set' do
+ let(:test_class) { Class.new(cache_class_test) { self.reactive_cache_hard_limit = 1.megabyte } }
+ let(:instance) { test_class.new(666, &calculation) }
+
+ context 'when cache size is over the overridden limit' do
+ let(:calculation) { -> { 'a' * 2 * 1.megabyte } }
- shared_examples 'ExceededReactiveCacheLimit' do
it 'raises ExceededReactiveCacheLimit exception and does not cache new data' do
expect { go! }.to raise_exception(ReactiveCaching::ExceededReactiveCacheLimit)
expect(read_reactive_cache(instance)).not_to eq(calculation.call)
end
- end
- context 'when reactive_cache_hard_limit feature flag is enabled' do
- it_behaves_like 'ExceededReactiveCacheLimit'
-
- context 'when reactive_cache_hard_limit is overridden' do
- let(:test_class) { Class.new(cache_class_test) { self.reactive_cache_hard_limit = 3.megabytes } }
- let(:instance) { test_class.new(666, &calculation) }
+ context 'when reactive_cache_limit_enabled? is overriden to return false' do
+ before do
+ allow(instance).to receive(:reactive_cache_limit_enabled?).and_return(false)
+ end
it_behaves_like 'successful cache'
-
- context 'when cache size is over the overridden limit' do
- let(:calculation) { -> { 'a' * 4 * 1.megabyte } }
-
- it_behaves_like 'ExceededReactiveCacheLimit'
- end
end
end
- context 'when reactive_cache_limit feature flag is disabled' do
- before do
- stub_feature_flags(reactive_cache_limit: false)
- end
+ context 'when cache size is within the overridden limit' do
+ let(:calculation) { -> { 'Smaller than 1Mb reactive_cache_hard_limit' } }
it_behaves_like 'successful cache'
end
@@ -377,7 +369,7 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
it { expect(subject.reactive_cache_refresh_interval).to be_a(ActiveSupport::Duration) }
it { expect(subject.reactive_cache_lifetime).to be_a(ActiveSupport::Duration) }
it { expect(subject.reactive_cache_key).to respond_to(:call) }
- it { expect(subject.reactive_cache_hard_limit).to be_a(Integer) }
+ it { expect(subject.reactive_cache_hard_limit).to be_nil }
it { expect(subject.reactive_cache_worker_finder).to respond_to(:call) }
end
end
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb
index b93da518b689c226c742c953d52de53e3b71630c..303ae3b8eddd04c56bae07da762f78b35f95e2c5 100644
--- a/spec/models/environment_spec.rb
+++ b/spec/models/environment_spec.rb
@@ -847,6 +847,20 @@ describe Environment, :use_clean_rails_memory_store_caching do
subject { environment.calculate_reactive_cache }
+ it 'overrides default reactive_cache_hard_limit to 10 Mb' do
+ expect(described_class.reactive_cache_hard_limit).to eq(10.megabyte)
+ end
+
+ it 'overrides reactive_cache_limit_enabled? with a FF' do
+ environment_with_enabled_ff = FactoryBot.build(:environment)
+ environment_with_disabled_ff = FactoryBot.build(:environment)
+
+ stub_feature_flags(reactive_caching_limit_environment: environment_with_enabled_ff.project)
+
+ expect(environment_with_enabled_ff.send(:reactive_cache_limit_enabled?)).to be_truthy
+ expect(environment_with_disabled_ff.send(:reactive_cache_limit_enabled?)).to be_falsey
+ end
+
it 'returns cache data from the deployment platform' do
expect(environment.deployment_platform).to receive(:calculate_reactive_cache_for)
.with(environment).and_return(pods: %w(pod1 pod2))
diff --git a/spec/tooling/lib/tooling/test_file_finder_spec.rb b/spec/tooling/lib/tooling/test_file_finder_spec.rb
index 9c33f20877b83857ef230d90614f84cf09eaea40..3e6eb4bb5214886a14a0c3adec53c2f9775e6318 100644
--- a/spec/tooling/lib/tooling/test_file_finder_spec.rb
+++ b/spec/tooling/lib/tooling/test_file_finder_spec.rb
@@ -88,6 +88,62 @@ RSpec.describe Tooling::TestFileFinder do
end
end
+ context 'when given a factory file' do
+ let(:file) { 'spec/factories/users.rb' }
+
+ it 'returns spec/factories_spec.rb file' do
+ expect(subject.test_files).to contain_exactly('spec/factories_spec.rb')
+ end
+ end
+
+ context 'when given an ee factory file' do
+ let(:file) { 'ee/spec/factories/users.rb' }
+
+ it 'returns spec/factories_spec.rb file' do
+ expect(subject.test_files).to contain_exactly('spec/factories_spec.rb')
+ end
+ end
+
+ context 'when given db/structure.sql' do
+ let(:file) { 'db/structure.sql' }
+
+ it 'returns spec/db/schema_spec.rb' do
+ expect(subject.test_files).to contain_exactly('spec/db/schema_spec.rb')
+ end
+ end
+
+ context 'when given an initializer' do
+ let(:file) { 'config/initializers/action_mailer_hooks.rb' }
+
+ it 'returns the matching initializer spec' do
+ expect(subject.test_files).to contain_exactly('spec/initializers/action_mailer_hooks_spec.rb')
+ end
+ end
+
+ context 'when given a migration file' do
+ let(:file) { 'db/migrate/20191023152913_add_default_and_free_plans.rb' }
+
+ it 'returns the matching migration spec' do
+ test_files = %w[
+ spec/migrations/add_default_and_free_plans_spec.rb
+ spec/migrations/20191023152913_add_default_and_free_plans_spec.rb
+ ]
+ expect(subject.test_files).to contain_exactly(*test_files)
+ end
+ end
+
+ context 'when given a post-migration file' do
+ let(:file) { 'db/post_migrate/20200608072931_backfill_imported_snippet_repositories.rb' }
+
+ it 'returns the matching migration spec' do
+ test_files = %w[
+ spec/migrations/backfill_imported_snippet_repositories_spec.rb
+ spec/migrations/20200608072931_backfill_imported_snippet_repositories_spec.rb
+ ]
+ expect(subject.test_files).to contain_exactly(*test_files)
+ end
+ end
+
context 'with foss_test_only: true' do
subject { Tooling::TestFileFinder.new(file, foss_test_only: true) }
diff --git a/tooling/lib/tooling/test_file_finder.rb b/tooling/lib/tooling/test_file_finder.rb
index 4cf7ad35922765a5cd372a0f9d32c259c95c8b6d..36ace67caa30a6cb2dc7386b90a0d7f699be044c 100644
--- a/tooling/lib/tooling/test_file_finder.rb
+++ b/tooling/lib/tooling/test_file_finder.rb
@@ -12,7 +12,7 @@ module Tooling
end
def test_files
- impacted_tests = ee_impact | non_ee_impact
+ impacted_tests = ee_impact | non_ee_impact | either_impact
impacted_tests.impact(@file)
end
@@ -23,20 +23,22 @@ module Tooling
class ImpactedTestFile
attr_reader :pattern_matchers
- def initialize
+ def initialize(prefix: nil)
@pattern_matchers = {}
+ @prefix = prefix
yield self if block_given?
end
def associate(pattern, &block)
- @pattern_matchers[pattern] = block
+ @pattern_matchers[%r{^#{@prefix}#{pattern}}] = block
end
def impact(file)
@pattern_matchers.each_with_object(Set.new) do |(pattern, block), result|
if (match = pattern.match(file))
- result << block.call(match)
+ test_files = block.call(match)
+ result.merge(Array(test_files))
end
end.to_a
end
@@ -54,24 +56,37 @@ module Tooling
end
def ee_impact
- ImpactedTestFile.new do |impact|
+ ImpactedTestFile.new(prefix: EE_PREFIX) do |impact|
unless foss_test_only
- impact.associate(%r{^#{EE_PREFIX}app/(.+)\.rb$}) { |match| "#{EE_PREFIX}spec/#{match[1]}_spec.rb" }
- impact.associate(%r{^#{EE_PREFIX}app/(.*/)ee/(.+)\.rb$}) { |match| "#{EE_PREFIX}spec/#{match[1]}#{match[2]}_spec.rb" }
- impact.associate(%r{^#{EE_PREFIX}lib/(.+)\.rb$}) { |match| "#{EE_PREFIX}spec/lib/#{match[1]}_spec.rb" }
- impact.associate(%r{^#{EE_PREFIX}spec/(.+)_spec.rb$}) { |match| match[0] }
+ impact.associate(%r{app/(.+)\.rb$}) { |match| "#{EE_PREFIX}spec/#{match[1]}_spec.rb" }
+ impact.associate(%r{app/(.*/)ee/(.+)\.rb$}) { |match| "#{EE_PREFIX}spec/#{match[1]}#{match[2]}_spec.rb" }
+ impact.associate(%r{lib/(.+)\.rb$}) { |match| "#{EE_PREFIX}spec/lib/#{match[1]}_spec.rb" }
end
- impact.associate(%r{^#{EE_PREFIX}(?!spec)(.*/)ee/(.+)\.rb$}) { |match| "spec/#{match[1]}#{match[2]}_spec.rb" }
- impact.associate(%r{^#{EE_PREFIX}spec/(.*/)ee/(.+)\.rb$}) { |match| "spec/#{match[1]}#{match[2]}.rb" }
+ impact.associate(%r{(?!spec)(.*/)ee/(.+)\.rb$}) { |match| "spec/#{match[1]}#{match[2]}_spec.rb" }
+ impact.associate(%r{spec/(.*/)ee/(.+)\.rb$}) { |match| "spec/#{match[1]}#{match[2]}.rb" }
end
end
def non_ee_impact
ImpactedTestFile.new do |impact|
- impact.associate(%r{^app/(.+)\.rb$}) { |match| "spec/#{match[1]}_spec.rb" }
- impact.associate(%r{^(tooling/)?lib/(.+)\.rb$}) { |match| "spec/#{match[1]}lib/#{match[2]}_spec.rb" }
- impact.associate(%r{^spec/(.+)_spec.rb$}) { |match| match[0] }
+ impact.associate(%r{app/(.+)\.rb$}) { |match| "spec/#{match[1]}_spec.rb" }
+ impact.associate(%r{(tooling/)?lib/(.+)\.rb$}) { |match| "spec/#{match[1]}lib/#{match[2]}_spec.rb" }
+ impact.associate(%r{config/initializers/(.+).rb$}) { |match| "spec/initializers/#{match[1]}_spec.rb" }
+ impact.associate('db/structure.sql') { 'spec/db/schema_spec.rb' }
+ impact.associate(%r{db/(?:post_)?migrate/([0-9]+)_(.+).rb$}) do |match|
+ [
+ "spec/migrations/#{match[2]}_spec.rb",
+ "spec/migrations/#{match[1]}_#{match[2]}_spec.rb"
+ ]
+ end
+ end
+ end
+
+ def either_impact
+ ImpactedTestFile.new(prefix: %r{^(#{EE_PREFIX})?}) do |impact|
+ impact.associate(%r{spec/(.+)_spec.rb$}) { |match| match[0] }
+ impact.associate(%r{spec/factories/.+\.rb$}) { 'spec/factories_spec.rb' }
end
end
end