From 912f1179e44a1f4ee7a4b472216fc34002b66926 Mon Sep 17 00:00:00 2001
From: chris <chris.r.jones.1983@gmail.com>
Date: Tue, 30 Apr 2024 19:23:12 -0500
Subject: [PATCH] exp with using additional github action ie. action-tmate to
 debug ubuntu ci [no ci]

---
 .github/workflows/tests.yml | 10 ++++++++++
 Formula/swig@4.1.1.rb       | 27 +++++++--------------------
 2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 53023160..0b092f6f 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -8,6 +8,12 @@ on:
       - master
 
   pull_request:
+    inputs:
+      debug_enabled:
+        type: boolean
+        description: 'run with tmate enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
+        required: false
+        default: false
   # workflow_dispatch:  # NOTE: nova with homebrew gha
 
 env:
@@ -48,6 +54,10 @@ jobs:
     timeout-minutes: 1200
 
     steps:
+      # enable tmate debugging if pull_request && debug enabled
+      - name: setup tmate session
+        uses: mxschmitt/action-tmate@v3
+        if: ${{ github.event_name == 'pull_request' && inputs.debug_enabled }}
 
       - name: Get current date
         id: get_current_date
diff --git a/Formula/swig@4.1.1.rb b/Formula/swig@4.1.1.rb
index bc2825b0..b972288c 100644
--- a/Formula/swig@4.1.1.rb
+++ b/Formula/swig@4.1.1.rb
@@ -5,7 +5,7 @@ class SwigAT411 < Formula
   url "https://downloads.sourceforge.net/project/swig/swig/swig-4.1.1/swig-4.1.1.tar.gz"
   sha256 "2af08aced8fcd65cdb5cc62426768914bedc735b1c250325203716f78e39ac9b"
   license "GPL-3.0-only"
-  revision 4
+  revision 3
 
   livecheck do
     url :stable
@@ -28,7 +28,6 @@ class SwigAT411 < Formula
 
   keg_only :versioned_formula
 
-  depends_on "ruby" => :test if OS.linux?
   depends_on "pcre2"
 
   uses_from_macos "ruby" => :test
@@ -48,7 +47,8 @@ def caveats
     EOS
   end
 
-  # NOTE: add upstream python test to this formula
+  # NOTE: add upstream python test this formula, #3
+
   test do
     (testpath/"test.c").write <<~EOS
       int add(int x, int y)
@@ -67,22 +67,9 @@ def caveats
       puts Test.add(1, 1)
     EOS
     system "#{bin}/swig", "-ruby", "test.i"
-    if OS.mac?
-      system ENV.cc, "-c", "test.c"
-      system ENV.cc, "-c", "test_wrap.c", "-I#{MacOS.sdk_path}/System/Library/Frameworks/Ruby.framework/Headers/"
-      system ENV.cc, "-bundle", "-undefined", "dynamic_lookup", "test.o", "test_wrap.o", "-o", "test.bundle"
-    else
-      ruby = Formula["ruby"]
-      args = Utils.safe_popen_read(
-        ruby.opt_bin/"ruby", "-e", "'puts RbConfig::CONFIG[\"LIBRUBYARG\"]'"
-      ).chomp
-      system ENV.cc, "-c", "-fPIC", "test.c"
-      system ENV.cc, "-c", "-fPIC", "test_wrap.c",
-        "-I#{ruby.opt_include}/ruby-#{ruby.version.major_minor}.0",
-        "-I#{ruby.opt_include}/ruby-#{ruby.version.major_minor}.0/x86_64-linux/"
-      system ENV.cc, "-shared", "test.o", "test_wrap.o", "-o", "test.so",
-        *args.delete("'").split
-    end
-    assert_equal "2", shell_output("ruby run.rb").strip
+    system ENV.cc, "-c", "test.c"
+    system ENV.cc, "-c", "test_wrap.c", "-I#{MacOS.sdk_path}/System/Library/Frameworks/Ruby.framework/Headers/"
+    system ENV.cc, "-bundle", "-undefined", "dynamic_lookup", "test.o", "test_wrap.o", "-o", "test.bundle"
+    assert_equal "2", shell_output("/usr/bin/ruby run.rb").strip
   end
 end