From 14cad464f91da38a7cf60e83b28a8e7f0019b0d5 Mon Sep 17 00:00:00 2001 From: "David M. Lary" Date: Mon, 17 Mar 2025 12:45:30 -0500 Subject: [PATCH 1/7] fix Struct error, add CI --- .github/workflows/main.yml | 34 ++++++++++++++++++++++++++++++++++ lib/ctypes/struct.rb | 1 + 2 files changed, 35 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..d60f465 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,34 @@ +name: CI + +on: + pull_request: + branches: + - main + push: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + main: + runs-on: ubuntu-latest + strategy: + matrix: + ruby: + - "3.1" + - "3.2" + - "3.3" + - "3.4" + - ruby-head + name: "Ruby ${{ matrix.ruby }}: ${{ matrix.task }}" + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "${{ matrix.ruby }}" + bundler-cache: true + - run: bundle install + - run: bundle exec rake spec diff --git a/lib/ctypes/struct.rb b/lib/ctypes/struct.rb index 6db3a86..511f70c 100644 --- a/lib/ctypes/struct.rb +++ b/lib/ctypes/struct.rb @@ -517,6 +517,7 @@ def pretty_print(q) # :nodoc: type.is_a?(CTypes::Pad) end q.seplist(fields, -> { q.breakable("") }) do |name, _| + names = name.is_a?(::Array) ? name : [name] names.each do |name| next if name.is_a?(CTypes::Pad) q.text(".#{name} = ") From 27dc929bfa63c42a6d940789abb7431cf9d26fac Mon Sep 17 00:00:00 2001 From: "David M. Lary" Date: Mon, 17 Mar 2025 12:58:58 -0500 Subject: [PATCH 2/7] debugging CI issues --- spec/spec_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b766ab9..74293ab 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -42,4 +42,5 @@ def bitstr(buf) config.extend(CTypes::Helpers) config.extend(Helpers) + pp(extended: CTypes::Helpers.public_methods.sort) end From 75f147ed6454c2d042b6c4aa125a76bf6b7b11ad Mon Sep 17 00:00:00 2001 From: "David M. Lary" Date: Mon, 17 Mar 2025 13:03:22 -0500 Subject: [PATCH 3/7] more CI debugging Looks like the .rspec file is not being loaded in CI when we run `bundle exec rake spec`. Trying `bundle exec rspec` instead. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d60f465..7ad8991 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,4 +31,4 @@ jobs: ruby-version: "${{ matrix.ruby }}" bundler-cache: true - run: bundle install - - run: bundle exec rake spec + - run: bundle exec rspec From 518b4db444380d87e1e85ad57a680d5702fdd22e Mon Sep 17 00:00:00 2001 From: "David M. Lary" Date: Mon, 17 Mar 2025 13:13:00 -0500 Subject: [PATCH 4/7] more CI debugging No clue why .rspec isn't being honored --- .github/workflows/main.yml | 3 ++- Rakefile | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7ad8991..c1c5068 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,4 +31,5 @@ jobs: ruby-version: "${{ matrix.ruby }}" bundler-cache: true - run: bundle install - - run: bundle exec rspec + - run: bundle exec rake debug + - run: bundle exec rake spec diff --git a/Rakefile b/Rakefile index df40677..2e9a919 100644 --- a/Rakefile +++ b/Rakefile @@ -8,3 +8,13 @@ RSpec::Core::RakeTask.new(:spec) require "standard/rake" task default: %i[spec standard] + +task :debug do + puts <<~END % [`ls`, `cat .rspec`] + files: + %s + + .rspec: + %s + END +end From 9044a846edd6cc72bcdaeba559e6502a7eba14a6 Mon Sep 17 00:00:00 2001 From: "David M. Lary" Date: Mon, 17 Mar 2025 13:14:43 -0500 Subject: [PATCH 5/7] Add .rspec file --- .gitignore | 1 - .rspec | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .rspec diff --git a/.gitignore b/.gitignore index 24f1319..6b621f4 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ Gemfile.lock # rspec failure tracking .rspec_status -.rspec # apple files .DS_Store diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..34c5164 --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--format documentation +--color +--require spec_helper From 1e38946d8158db71d9a9e2bda1ad0c08a1600e24 Mon Sep 17 00:00:00 2001 From: "David M. Lary" Date: Mon, 17 Mar 2025 13:14:43 -0500 Subject: [PATCH 6/7] CI updates --- .github/workflows/main.yml | 3 ++- Rakefile | 10 ---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c1c5068..5c13e0e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,6 +30,7 @@ jobs: with: ruby-version: "${{ matrix.ruby }}" bundler-cache: true + # install castxml for the importer tests + - run: sudo apt-get update && sudo apt-get install -y castxml - run: bundle install - - run: bundle exec rake debug - run: bundle exec rake spec diff --git a/Rakefile b/Rakefile index 2e9a919..df40677 100644 --- a/Rakefile +++ b/Rakefile @@ -8,13 +8,3 @@ RSpec::Core::RakeTask.new(:spec) require "standard/rake" task default: %i[spec standard] - -task :debug do - puts <<~END % [`ls`, `cat .rspec`] - files: - %s - - .rspec: - %s - END -end From 6efbce2a3276132e7dafb6e16dd543eaa5afbb0e Mon Sep 17 00:00:00 2001 From: "David M. Lary" Date: Mon, 17 Mar 2025 13:22:42 -0500 Subject: [PATCH 7/7] remove debugging output --- spec/spec_helper.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 74293ab..b766ab9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -42,5 +42,4 @@ def bitstr(buf) config.extend(CTypes::Helpers) config.extend(Helpers) - pp(extended: CTypes::Helpers.public_methods.sort) end