1+ # !/usr/bin/env julia
2+
3+ # MWE: Exact reproduction of LinearSolveAutotune GitHub API call
4+ # Usage: GITHUB_TOKEN=your_token julia --project=lib/LinearSolveAutotune mwe_api_call.jl
5+
6+ using GitHub
7+ using Dates
8+
9+ function mwe_github_api_call ()
10+ println (" 🧪 MWE: LinearSolveAutotune GitHub API Call" )
11+ println (" =" ^ 50 )
12+
13+ # Check for token (exactly as package does)
14+ token = get (ENV , " GITHUB_TOKEN" , nothing )
15+ if token === nothing
16+ println (" ❌ No GITHUB_TOKEN found" )
17+ return false
18+ end
19+
20+ println (" ✅ Token found (length: $(length (token)) )" )
21+
22+ try
23+ # Step 1: Authenticate (exactly as package does)
24+ println (" 📋 Step 1: GitHub.authenticate(token)" )
25+ auth = GitHub. authenticate (token)
26+ println (" ✅ Authentication successful" )
27+ println (" Auth type: $(typeof (auth)) " )
28+
29+ # Step 2: Get repository object (exactly as package does)
30+ println (" \n 📋 Step 2: GitHub.repo(target_repo; auth=auth)" )
31+ target_repo = " SciML/LinearSolve.jl"
32+ repo_obj = GitHub. repo (target_repo; auth= auth)
33+ println (" ✅ Repository access successful" )
34+ println (" Repo: $(repo_obj. full_name) " )
35+
36+ # Step 3: Create title and body (exactly as package does)
37+ println (" \n 📋 Step 3: Create issue title and body" )
38+ system_info = Dict (
39+ " cpu_name" => " Test CPU Apple M2 Max" ,
40+ " os" => " Test Darwin"
41+ )
42+ content = """ ## Test Benchmark Results
43+
44+ ### System Information
45+ - **Julia Version**: $(VERSION )
46+ - **CPU**: $(system_info[" cpu_name" ])
47+ - **OS**: $(system_info[" os" ])
48+
49+ ### Sample Results
50+ | Algorithm | GFLOPs |
51+ |-----------|--------|
52+ | AppleAccelerateLUFactorization | 72.38 |
53+ | RFLUFactorization | 52.23 |
54+ | LUFactorization | 50.84 |
55+
56+ **This is a test issue - please close it**
57+
58+ ---
59+ *Generated automatically by LinearSolveAutotune.jl*"""
60+
61+ cpu_name = get (system_info, " cpu_name" , " unknown" )
62+ os_name = get (system_info, " os" , " unknown" )
63+ timestamp = Dates. format (Dates. now (), " yyyy-mm-dd HH:MM" )
64+
65+ issue_title = " Benchmark Results: $cpu_name on $os_name ($timestamp )"
66+
67+ issue_body = """
68+ # LinearSolve.jl Autotune Benchmark Results
69+
70+ $content
71+
72+ ---
73+
74+ ## System Summary
75+ - **CPU:** $cpu_name
76+ - **OS:** $os_name
77+ - **Timestamp:** $timestamp
78+
79+ 🤖 *Generated automatically by LinearSolve.jl autotune system*
80+ """
81+
82+ println (" ✅ Issue content created" )
83+ println (" Title: $(issue_title) " )
84+ println (" Body length: $(length (issue_body)) characters" )
85+
86+ # Step 4: Create issue (EXACT reproduction of package call)
87+ println (" \n 📋 Step 4: GitHub.create_issue() - EXACT package reproduction" )
88+ println (" Calling: GitHub.create_issue(repo_obj, title=issue_title, body=issue_body, auth=auth)" )
89+
90+ issue_result = GitHub. create_issue (
91+ repo_obj,
92+ title= issue_title,
93+ body= issue_body,
94+ auth= auth
95+ )
96+
97+ println (" 🎉 SUCCESS!" )
98+ println (" ✅ Created issue #$(issue_result. number) " )
99+ println (" 🔗 URL: $(issue_result. html_url) " )
100+ println ()
101+ println (" 📝 Please close this test issue: $(issue_result. html_url) " )
102+
103+ return true
104+
105+ catch e
106+ println (" ❌ ERROR at step above:" )
107+ println (" Error type: $(typeof (e)) " )
108+ println (" Error message: $e " )
109+
110+ # Additional diagnostic info
111+ println (" \n 🔍 Diagnostic Information:" )
112+ println (" Julia version: $(VERSION ) " )
113+ println (" GitHub.jl version: $(pkgversion (GitHub)) " )
114+
115+ # Try to show available methods
116+ try
117+ println (" Available GitHub.create_issue methods:" )
118+ for m in methods (GitHub. create_issue)
119+ println (" $m " )
120+ end
121+ catch
122+ println (" Could not list methods" )
123+ end
124+
125+ return false
126+ end
127+ end
128+
129+ # Also test different syntax variations to find what works
130+ function test_syntax_variations ()
131+ println (" \n 🔧 Testing Syntax Variations" )
132+ println (" =" ^ 35 )
133+
134+ token = get (ENV , " GITHUB_TOKEN" , nothing )
135+ if token === nothing
136+ println (" ❌ No token for syntax tests" )
137+ return
138+ end
139+
140+ try
141+ auth = GitHub. authenticate (token)
142+ repo_obj = GitHub. repo (" SciML/LinearSolve.jl" ; auth= auth)
143+
144+ title = " SYNTAX TEST: $(Dates. format (Dates. now (), " yyyy-mm-dd HH:MM:SS" )) "
145+ body = " Test of different GitHub.create_issue syntax variations.\n\n **Please close this test issue.**"
146+
147+ # Test 1: Package's current syntax
148+ println (" 🧪 Syntax 1: GitHub.create_issue(repo_obj, title=title, body=body, auth=auth)" )
149+ try
150+ issue1 = GitHub. create_issue (repo_obj, title= title, body= body, auth= auth)
151+ println (" ✅ Syntax 1 WORKS! Issue #$(issue1. number) " )
152+ return
153+ catch e1
154+ println (" ❌ Syntax 1 failed: $(typeof (e1)) - $e1 " )
155+ end
156+
157+ # Test 2: All keyword arguments
158+ println (" \n 🧪 Syntax 2: GitHub.create_issue(repo_obj; title=title, body=body, auth=auth)" )
159+ try
160+ issue2 = GitHub. create_issue (repo_obj; title= title, body= body, auth= auth)
161+ println (" ✅ Syntax 2 WORKS! Issue #$(issue2. number) " )
162+ return
163+ catch e2
164+ println (" ❌ Syntax 2 failed: $(typeof (e2)) - $e2 " )
165+ end
166+
167+ # Test 3: Positional arguments
168+ println (" \n 🧪 Syntax 3: GitHub.create_issue(repo_obj, title, body, auth)" )
169+ try
170+ issue3 = GitHub. create_issue (repo_obj, title, body, auth)
171+ println (" ✅ Syntax 3 WORKS! Issue #$(issue3. number) " )
172+ return
173+ catch e3
174+ println (" ❌ Syntax 3 failed: $(typeof (e3)) - $e3 " )
175+ end
176+
177+ # Test 4: Auth first
178+ println (" \n 🧪 Syntax 4: GitHub.create_issue(repo_obj, auth=auth, title=title, body=body)" )
179+ try
180+ issue4 = GitHub. create_issue (repo_obj, auth= auth, title= title, body= body)
181+ println (" ✅ Syntax 4 WORKS! Issue #$(issue4. number) " )
182+ return
183+ catch e4
184+ println (" ❌ Syntax 4 failed: $(typeof (e4)) - $e4 " )
185+ end
186+
187+ println (" \n ❌ All syntax variations failed" )
188+
189+ catch e
190+ println (" ❌ Setup for syntax tests failed: $e " )
191+ end
192+ end
193+
194+ # Run the MWE
195+ println (" Starting MWE reproduction of LinearSolveAutotune API call...\n " )
196+
197+ success = mwe_github_api_call ()
198+
199+ if ! success
200+ test_syntax_variations ()
201+ end
202+
203+ println (" \n 📊 MWE Results:" )
204+ if success
205+ println (" ✅ The package's API call works correctly" )
206+ println (" 💡 Issue might be in authentication or permissions" )
207+ else
208+ println (" ❌ The package's API call fails" )
209+ println (" 💡 Need to fix the API call syntax in the package" )
210+ end
0 commit comments