Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/integration-compute-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ concurrency:
jobs:
test-compute:
runs-on: fog-arc-runner
env:
RUBYOPT: "--enable-frozen-string-literal"
strategy:
matrix:
ruby-version: [ '3.0', '3.1', '3.2' ]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/integration-compute-instance_groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ concurrency:
jobs:
test:
runs-on: fog-arc-runner
env:
RUBYOPT: "--enable-frozen-string-literal"
strategy:
matrix:
ruby-version: [ '3.0', '3.1', '3.2' ]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/integration-compute-loadbalancing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ concurrency:
jobs:
test:
runs-on: fog-arc-runner
env:
RUBYOPT: "--enable-frozen-string-literal"
strategy:
matrix:
ruby-version: [ '3.0', '3.1', '3.2' ]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/integration-compute-networking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ concurrency:
jobs:
test:
runs-on: fog-arc-runner
env:
RUBYOPT: "--enable-frozen-string-literal"
strategy:
matrix:
ruby-version: [ '3.0', '3.1', '3.2' ]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/integration-monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ concurrency:
jobs:
test:
runs-on: fog-arc-runner
env:
RUBYOPT: "--enable-frozen-string-literal"
strategy:
matrix:
ruby-version: [ '3.0', '3.1', '3.2' ]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/integration-pubsub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ concurrency:
jobs:
test:
runs-on: fog-arc-runner
env:
RUBYOPT: "--enable-frozen-string-literal"
strategy:
matrix:
ruby-version: [ '3.0', '3.1', '3.2' ]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/integration-sql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ concurrency:
jobs:
test:
runs-on: fog-arc-runner
env:
RUBYOPT: "--enable-frozen-string-literal"
strategy:
matrix:
ruby-version: [ '3.0', '3.1', '3.2' ]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/integration-storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ concurrency:
jobs:
test:
runs-on: fog-arc-runner
env:
RUBYOPT: "--enable-frozen-string-literal"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't we expect these tests to fail without fixes for the frozen strings?

Copy link
Author

@davidgm0 davidgm0 Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To those files that modify strings I added:

# frozen_string_literal: false

That overrides the RUBYOPT for those files. The final behaviour should be that by default for all files the strings are frozen and for those few files the string literals are not frozen.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right, that's unexpected, though; usually I see # frozen_string_literal: true, or it's omitted entirely because false is the default.

I'm not opposed to this approach as a step 1. However, at the moment these integration tests need to be run by hand. I suspect just fixing the frozen string issue is relatively straightforward that we might as well try to fix them on a file-by-file basis, such as:

diff --git a/lib/fog/google/storage/storage_json/real.rb b/lib/fog/google/storage/storage_json/real.rb
index 23c86c5..ab99372 100644
--- a/lib/fog/google/storage/storage_json/real.rb
+++ b/lib/fog/google/storage/storage_json/real.rb
@@ -45,7 +45,7 @@ DATA
           end
           string_to_sign << canonical_google_headers.to_s
 
-          canonical_resource = "/"
+          canonical_resource = +"/"
           if subdomain = params.delete(:subdomain)
             canonical_resource << "#{CGI.escape(subdomain).downcase}/"
           end
diff --git a/lib/fog/google/storage/storage_xml/real.rb b/lib/fog/google/storage/storage_xml/real.rb
index 166e181..5c15bfc 100644
--- a/lib/fog/google/storage/storage_xml/real.rb
+++ b/lib/fog/google/storage/storage_xml/real.rb
@@ -57,7 +57,7 @@ DATA
           end
           string_to_sign << canonical_google_headers.to_s
 
-          canonical_resource = "/"
+          canonical_resource = +"/"
           if subdomain = params.delete(:subdomain)
             canonical_resource << "#{CGI.escape(subdomain).downcase}/"
           end

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be happy if these changes could be applied directly, I just don't know the codebase so well and I saw there were a fair amount of modifications, so I went for the easy fix. That can still be applied after this PR.

Oh, right, that's unexpected, though; usually I see # frozen_string_literal: true, or it's omitted entirely because false is the default.

Yeah, but that default will eventually change. If someone tries to already enable --enable-frozen-string-literal (as I did), they will get errors. This PR at least fixes that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, using +"..." was how we solved this for excon and it worked well (though it is a bit annoying initially).

strategy:
matrix:
ruby-version: [ '3.0', '3.1', '3.2' ]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ concurrency:
jobs:
test-unit:
runs-on: ubuntu-latest
env:
RUBYOPT: "--enable-frozen-string-literal"
strategy:
matrix:
ruby-version: [ '3.0', '3.1', '3.2', 'head', 'truffleruby-head']
Expand Down
4 changes: 3 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ Style/FormatString:
Style/RegexpLiteral:
Enabled: false

#TODO: this needs to be adressed not through the linter
# TODO: Some files modify strings in place, so we need to disable this cop.
# ci runs with RUBYOPT="--enable-frozen-string-literal", files that modify
# strings have frozen_string_literal: false.
Style/FrozenStringLiteralComment:
Enabled: false

Expand Down
2 changes: 2 additions & 0 deletions lib/fog/google/storage/storage_json/real.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: false

module Fog
module Google
class StorageJSON
Expand Down
2 changes: 2 additions & 0 deletions lib/fog/google/storage/storage_json/utils.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: false

require "addressable"

module Fog
Expand Down
2 changes: 2 additions & 0 deletions lib/fog/google/storage/storage_xml/real.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: false

module Fog
module Google
class StorageXML
Expand Down
2 changes: 2 additions & 0 deletions lib/fog/google/storage/storage_xml/utils.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: false

module Fog
module Google
class StorageXML
Expand Down