From cd53bbf46e4cf4d2a4daac17e08bf871fb79926c Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 10 Apr 2024 14:57:47 -0400 Subject: [PATCH 1/3] ci: add freebsd coverage also split fedora out into two jobs (unit and examples) --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d37f549..970f4b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,10 @@ jobs: - run: bundle exec rake test:examples fedora: # see https://github.com/flavorjones/mini_portile/issues/118 + strategy: + fail-fast: false + matrix: + task: ["test:unit", "test:examples"] runs-on: ubuntu-latest container: image: fedora:35 @@ -84,5 +88,27 @@ jobs: path: examples/ports/archives key: examples-${{ hashFiles('examples/Rakefile') }} - run: bundle install - - run: bundle exec rake test:unit - - run: bundle exec rake test:examples + - run: bundle exec rake ${{ matrix.task }} + + freebsd: + strategy: + fail-fast: false + matrix: + task: ["test:unit", "test:examples"] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: examples/ports/archives + key: examples-${{ hashFiles('examples/Rakefile') }} + - uses: vmactions/freebsd-vm@v1 + with: + usesh: true + copyback: false + prepare: pkg install -y ruby devel/ruby-gems pkgconf git cmake textproc/libyaml security/gnupg + run: | + git config --global --add safe.directory /home/runner/work/mini_portile/mini_portile + gem install bundler + bundle install + bundle exec rake ${{ matrix.task }} From 22c70def2bad0b0eb49c19fe8c37afa1590dc9d2 Mon Sep 17 00:00:00 2001 From: Paul Mucur Date: Tue, 9 Apr 2024 08:31:01 +0100 Subject: [PATCH 2/3] Prefer cc and c++ when using CMake on FreeBSD As of FreeBSD 10.X, clang is installed as the default compiler with "cc" and "c++" as aliases to "clang" and "clang++" respectively. --- lib/mini_portile2/mini_portile_cmake.rb | 3 +++ test/test_cmake.rb | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/mini_portile2/mini_portile_cmake.rb b/lib/mini_portile2/mini_portile_cmake.rb index 41e1ad1..9fcfb4c 100644 --- a/lib/mini_portile2/mini_portile_cmake.rb +++ b/lib/mini_portile2/mini_portile_cmake.rb @@ -94,6 +94,9 @@ def find_c_and_cxx_compilers(host) if MiniPortile.darwin? c_compiler ||= 'clang' cxx_compiler ||='clang++' + elsif MiniPortile.freebsd? + c_compiler ||= 'cc' + cxx_compiler ||= 'c++' else c_compiler ||= 'gcc' cxx_compiler ||= 'g++' diff --git a/test/test_cmake.rb b/test/test_cmake.rb index 7a3483c..6d5ffa0 100644 --- a/test/test_cmake.rb +++ b/test/test_cmake.rb @@ -107,6 +107,29 @@ def test_configure_defaults_with_macos end end + def test_configure_defaults_with_freebsd + recipe = init_recipe + recipe.host = 'some-host' + + with_env({ "CC" => nil, "CXX" => nil }) do + with_stubbed_target(os: 'freebsd14') do + with_compilers(recipe, c_compiler: 'cc', cxx_compiler: 'c++') do + Open3.stub(:capture2, cmake_help_mock('Unix')) do + assert_equal( + [ + "-DCMAKE_SYSTEM_NAME=FreeBSD", + "-DCMAKE_SYSTEM_PROCESSOR=x86_64", + "-DCMAKE_C_COMPILER=cc", + "-DCMAKE_CXX_COMPILER=c++", + "-DCMAKE_BUILD_TYPE=Release" + ], + recipe.configure_defaults) + end + end + end + end + end + def test_configure_defaults_with_manual_system_name recipe = init_recipe recipe.system_name = 'Custom' From e0de7648d80c1007c8d69316a65f4e2eab48eab2 Mon Sep 17 00:00:00 2001 From: Paul Mucur Date: Fri, 12 Apr 2024 13:22:10 +0100 Subject: [PATCH 3/3] Explicitly use GNU make for FreeBSD build By default, "make" on FreeBSD is not compatible with the GNU make expected by the example libraries that test:examples will attempt to compile. GNU make _is_ available for FreeBSD but isn't installed by default so we explicitly download it and set the MAKE environment variable so MiniPortile will use it. --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 970f4b0..d848791 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,6 +96,8 @@ jobs: matrix: task: ["test:unit", "test:examples"] runs-on: ubuntu-latest + env: + MAKE: gmake steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 @@ -104,9 +106,10 @@ jobs: key: examples-${{ hashFiles('examples/Rakefile') }} - uses: vmactions/freebsd-vm@v1 with: + envs: MAKE usesh: true copyback: false - prepare: pkg install -y ruby devel/ruby-gems pkgconf git cmake textproc/libyaml security/gnupg + prepare: pkg install -y ruby devel/ruby-gems pkgconf git cmake devel/gmake textproc/libyaml security/gnupg run: | git config --global --add safe.directory /home/runner/work/mini_portile/mini_portile gem install bundler