Skip to content

Commit 10ba9cc

Browse files
committed
debug openssl on macos
1 parent a16047a commit 10ba9cc

File tree

3 files changed

+314
-6
lines changed

3 files changed

+314
-6
lines changed

.github/workflows/debug.yml

Lines changed: 300 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,300 @@
1+
name: debug
2+
permissions: {}
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- release*
9+
pull_request:
10+
branches:
11+
- main
12+
- release*
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
debug_source:
20+
runs-on: ubuntu-22.04
21+
outputs:
22+
gem_version: ${{ steps.build_gem.outputs.gem_version }}
23+
steps:
24+
- name: Install dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y libcurl4-openssl-dev
28+
- uses: actions/checkout@v4
29+
with:
30+
submodules: recursive
31+
fetch-depth: 0
32+
fetch-tags: true
33+
- uses: ruby/setup-ruby@v1
34+
with:
35+
ruby-version: 3.3
36+
bundler-cache: true
37+
- name: Build
38+
id: build_gem
39+
run: |
40+
COMMITS_SINCE_LAST_TAG=$(git describe --tags --always --long | awk -F '-' '{print $2}')
41+
ruby bin/jenkins/patch-version.rb ${COMMITS_SINCE_LAST_TAG}
42+
GEM_VERSION=$(ruby -r ./lib/couchbase/version.rb -e "puts Couchbase::VERSION[:sdk]")
43+
echo "gem_version=${GEM_VERSION}" >> "$GITHUB_OUTPUT"
44+
bundle exec rake build
45+
- name: RDoc
46+
run: |
47+
cat > patch-readme.rb <<EOF
48+
require_relative "./lib/couchbase/version.rb"
49+
gemfile = <<EOS.strip
50+
gem "couchbase", "#{Couchbase::VERSION[:sdk]}"
51+
EOS
52+
old_content = File.read("README.md")
53+
new_content = old_content.gsub(/(gem "couchbase", ").*?"/, gemfile)
54+
File.write("README.md", new_content)
55+
EOF
56+
ruby patch-readme.rb
57+
bundle exec yard doc --hide-api private --output-dir docs/couchbase-ruby-client-${{ steps.build_gem.outputs.gem_version }} lib --main README.md
58+
- uses: actions/upload-artifact@v4
59+
with:
60+
name: couchbase-${{ steps.build_gem.outputs.gem_version }}
61+
path: |
62+
pkg/*.gem
63+
- uses: actions/upload-artifact@v4
64+
with:
65+
retention-days: 1
66+
name: scripts-${{ steps.build_gem.outputs.gem_version }}
67+
path: |
68+
Gemfile
69+
Rakefile
70+
bin/**/*
71+
couchbase.gemspec
72+
lib/couchbase/version.rb
73+
task/**/*
74+
- uses: actions/upload-artifact@v4
75+
with:
76+
retention-days: 1
77+
name: tests-${{ steps.build_gem.outputs.gem_version }}
78+
path: |
79+
test/**/*
80+
test_data/**/*
81+
- uses: actions/upload-artifact@v4
82+
with:
83+
name: docs-${{ steps.build_gem.outputs.gem_version }}
84+
path: |
85+
docs/**/*
86+
87+
88+
debug_verify_openssl:
89+
needs: debug_source
90+
runs-on: macos-15-intel
91+
strategy:
92+
fail-fast: false
93+
matrix:
94+
ruby:
95+
- '3.3'
96+
steps:
97+
- uses: hendrikmuhs/[email protected]
98+
with:
99+
max-size: 2G
100+
key: ${{ github.job }}-${{ matrix.ruby }}
101+
- uses: ruby/setup-ruby@v1
102+
with:
103+
ruby-version: ${{ matrix.ruby }}
104+
105+
- name: Check system OpenSSL & Homebrew
106+
run: |
107+
echo "macOS version:"
108+
/usr/bin/sw_vers
109+
echo "--- System OpenSSL:"
110+
find /usr/lib -name '*ssl*' -type f 2>/dev/null | head -10 || echo "No system ssl libs found"
111+
ls -la /usr/lib/libssl* /System/Library/Frameworks/Security.framework/libssl* 2>/dev/null || echo "No explicit libssl*"
112+
openssl version || echo "OpenSSL CLI not found"
113+
echo "--- Homebrew OpenSSL:"
114+
ls -la /opt/homebrew/lib/libssl* /usr/local/lib/libssl* 2>/dev/null || echo "No Homebrew libssl"
115+
echo "--- Ruby lib path (for native exts):"
116+
ruby -e 'puts RbConfig::CONFIG["libdir"] + "/ruby/" + RbConfig::CONFIG["ruby_version"]'
117+
118+
- name: Check Ruby OpenSSL
119+
run: |
120+
ruby -r openssl -e "
121+
puts 'Ruby OpenSSL version: ' + OpenSSL::OPENSSL_VERSION
122+
ctx = OpenSSL::SSL::SSLContext.new
123+
puts 'SSLContext min_version: ' + (ctx.respond_to?(:min_version) ? ctx.min_version.to_s : 'unsupported')
124+
puts 'SSLContext max_version: ' + (ctx.respond_to?(:max_version) ? ctx.max_version.to_s : 'unsupported')
125+
puts 'SSL config file: ' + (defined?(OpenSSL::OPENSSL_CONF) ? OpenSSL::OPENSSL_CONF.to_s : 'undefined')
126+
begin
127+
engines = OpenSSL::Engine.engines
128+
puts 'Loaded OpenSSL engines: ' + engines.map(&:name).join(', ')
129+
rescue NameError
130+
puts 'OpenSSL::Engine unavailable'
131+
end
132+
" || echo "Ruby OpenSSL check completed (ignore NameError)"
133+
134+
- name: Test OpenSSL HTTPS fetch
135+
run: |
136+
ruby -e "
137+
require 'net/http'; require 'uri'; require 'openssl'
138+
uri = URI('https://www.couchbase.com/')
139+
http = Net::HTTP.new(uri.host, uri.port)
140+
http.use_ssl = true
141+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
142+
begin
143+
response = http.get(uri.path.empty? ? '/' : uri.path)
144+
puts 'SUCCESS: HTTP ' + response.code + ' - ' + response['content-type']
145+
puts 'SSL handshake OK - OpenSSL functional'
146+
rescue OpenSSL::SSL::SSLError => e
147+
puts 'SSL Error: ' + e.message
148+
rescue => e
149+
puts 'Error: ' + e.class.name + ' - ' + e.message
150+
end
151+
"
152+
153+
debug_build_macos_x86_64:
154+
needs: debug_source
155+
runs-on: macos-15-intel
156+
strategy:
157+
fail-fast: false
158+
matrix:
159+
ruby:
160+
- '3.3'
161+
steps:
162+
- uses: hendrikmuhs/[email protected]
163+
with:
164+
max-size: 2G
165+
key: ${{ github.job }}-${{ matrix.ruby }}
166+
- uses: ruby/setup-ruby@v1
167+
with:
168+
ruby-version: ${{ matrix.ruby }}
169+
- uses: actions/download-artifact@v4
170+
with:
171+
name: couchbase-${{ needs.debug_source.outputs.gem_version }}
172+
- name: Precompile
173+
env:
174+
CB_STATIC_BORINGSSL: 1
175+
CB_STATIC_STDLIB: 1
176+
CB_REMOVE_EXT_DIRECTORY: 1
177+
run: |
178+
gem install gem-compiler
179+
gem compile --prune couchbase-${{ needs.debug_source.outputs.gem_version }}.gem
180+
- uses: actions/upload-artifact@v4
181+
with:
182+
retention-days: 1
183+
name: couchbase-${{ needs.debug_source.outputs.gem_version }}-x86_64-darwin-${{ matrix.ruby }}
184+
path: |
185+
*-x86_64-darwin*.gem
186+
187+
debug_repackage_macos_x86_64:
188+
needs:
189+
- debug_source
190+
- debug_build_macos_x86_64
191+
runs-on: macos-15-intel
192+
steps:
193+
- uses: actions/download-artifact@v4
194+
with:
195+
name: scripts-${{ needs.debug_source.outputs.gem_version }}
196+
- uses: actions/download-artifact@v4
197+
with:
198+
path: pkg/binary/3.3
199+
name: couchbase-${{ needs.debug_source.outputs.gem_version }}-x86_64-darwin-3.3
200+
- uses: ruby/setup-ruby@v1
201+
with:
202+
ruby-version: 3.3
203+
- name: Repackage
204+
run: |
205+
ruby bin/jenkins/repackage-extension.rb
206+
- uses: actions/upload-artifact@v4
207+
with:
208+
name: couchbase-${{ needs.debug_source.outputs.gem_version }}-x86_64-darwin
209+
path: |
210+
pkg/fat/*.gem
211+
212+
debug_mock_macos_x86_64:
213+
timeout-minutes: 15
214+
needs:
215+
- debug_source
216+
- debug_repackage_macos_x86_64
217+
runs-on: macos-15-intel
218+
strategy:
219+
fail-fast: false
220+
matrix:
221+
ruby:
222+
- '3.3'
223+
steps:
224+
- uses: actions/download-artifact@v4
225+
with:
226+
name: couchbase-${{ needs.debug_source.outputs.gem_version }}-x86_64-darwin
227+
- uses: actions/download-artifact@v4
228+
with:
229+
name: scripts-${{ needs.debug_source.outputs.gem_version }}
230+
- uses: actions/download-artifact@v4
231+
with:
232+
name: tests-${{ needs.debug_source.outputs.gem_version }}
233+
- uses: ruby/setup-ruby@v1
234+
with:
235+
ruby-version: ${{ matrix.ruby }}
236+
- name: Install
237+
run: |
238+
COUCHBASE_GEM_PATH=$(realpath couchbase-*.gem)
239+
UNPACKED_GEM_PATH=$(gem unpack ${COUCHBASE_GEM_PATH} | grep "Unpacked gem" | cut -d "'" -f 2)
240+
gem unpack --spec --target ${UNPACKED_GEM_PATH} ${COUCHBASE_GEM_PATH}
241+
ruby -i.bak -pe "gsub(/gemspec/, 'gem \"couchbase\", path: \"${UNPACKED_GEM_PATH}\"')" Gemfile
242+
bundle install
243+
bundle exec ruby -r bundler/setup -r couchbase -e 'pp Couchbase::VERSION, Couchbase::BUILD_INFO'
244+
- name: Check library dependencies
245+
run: |
246+
targets=(
247+
"/Users/runner/hostedtoolcache/Ruby/3.3.10/x64/lib/libruby.3.3.dylib"
248+
"$(bundle show couchbase)"
249+
"$(bundle show openssl)"
250+
)
251+
252+
echo "=== Before exports ==="
253+
echo "DYLD_LIBRARY_PATH: $DYLD_LIBRARY_PATH"
254+
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
255+
echo "PATH: $PATH"
256+
257+
export DYLD_LIBRARY_PATH="/usr/local/lib:/opt/homebrew/lib:$DYLD_LIBRARY_PATH"
258+
export LD_LIBRARY_PATH="/usr/local/lib:/opt/homebrew/lib:$LD_LIBRARY_PATH"
259+
260+
echo "=== After exports ==="
261+
echo "DYLD_LIBRARY_PATH: $DYLD_LIBRARY_PATH"
262+
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
263+
264+
for target in "${targets[@]}"; do
265+
echo "=== Checking target: $target ==="
266+
if [[ "$target" == /* ]]; then
267+
echo "Direct otool -L:"
268+
otool -L "$target"
269+
else
270+
echo "Find-based otool -L:"
271+
otool -L "$(find "$target" -name '*.so' -o -name '*.dylib' -o -name '*.bundle')" 2>/dev/null
272+
fi
273+
done
274+
- name: Test
275+
env:
276+
CB_CAVES_LOGS_DIR: caves-logs
277+
COUCHBASE_BACKEND_DONT_WRITE_TO_STDERR: true
278+
COUCHBASE_BACKEND_LOG_PATH: logs/couchbase.log
279+
run: |
280+
export DYLD_LIBRARY_PATH="/usr/local/lib:/opt/homebrew/lib:$DYLD_LIBRARY_PATH"
281+
export LD_LIBRARY_PATH="/usr/local/lib:/opt/homebrew/lib:$LD_LIBRARY_PATH"
282+
bundle exec rake test
283+
- name: Upload logs
284+
if: failure()
285+
uses: actions/upload-artifact@v4
286+
with:
287+
name: ${{ github.job }}-${{ github.run_attempt }}-${{ matrix.ruby }}-logs
288+
path: |
289+
caves-logs/*
290+
logs/*
291+
test/**/*.{log,xml}
292+
retention-days: 5
293+
- name: Publish Test Report
294+
uses: mikepenz/[email protected]
295+
if: always()
296+
with:
297+
check_name: 🍏caves, ruby-${{ matrix.ruby }}
298+
report_paths: test/reports/*.xml
299+
require_tests: true
300+
annotate_only: true

.github/workflows/linters.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ permissions: {}
33

44
on:
55
push:
6-
branches: [ main ]
6+
branches:
7+
- do_not_run
8+
# - main
9+
# - release*
710
pull_request:
8-
branches: [ main ]
11+
branches:
12+
- do_not_run
13+
# - main
14+
# - release*
915

1016
env:
1117
LLVM_VERSION: 20

.github/workflows/tests.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ permissions: {}
44
on:
55
push:
66
branches:
7-
- main
8-
- release*
7+
- do_not_run
8+
# - main
9+
# - release*
910
pull_request:
1011
branches:
11-
- main
12-
- release*
12+
- do_not_run
13+
# - main
14+
# - release*
1315

1416
concurrency:
1517
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

0 commit comments

Comments
 (0)