diff --git a/.github/workflows/pr-testing.yml b/.github/workflows/pr-testing.yml index e8b73e877..f13218f28 100644 --- a/.github/workflows/pr-testing.yml +++ b/.github/workflows/pr-testing.yml @@ -83,22 +83,48 @@ jobs: run: rake spec build: - name: build openvox-server - runs-on: ubuntu-24.04 + name: build openvox-server - Java ${{ matrix.java }} Ruby ${{ matrix.ruby }} + # https://rpm.org/releases/4.18.2 + # https://github.com/actions/runner-images?tab=readme-ov-file + # rpm in 22 is version 4.17.x and allows our macros + # rpm in 24 is version 4.18.x and does not allow our rpmversion macro + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + java: ['11', '17', '21'] + ruby: ['3.3'] steps: - name: checkout repo uses: actions/checkout@v5 with: submodules: recursive - - name: setup ruby + + - name: Setup Java ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: ${{ matrix.java }} + + - name: Setup Ruby ${{ matrix.ruby }} uses: ruby/setup-ruby@v1 with: - ruby-version: '3.2' + ruby-version: ${{ matrix.ruby }} bundler-cache: true - # uses the Dockerfile to build openvox-server in a container - # the container hardcodes the java version + + - name: Install clojure tools + uses: DeLaGuardo/setup-clojure@13.4 + with: + lein: latest + - name: build it run: bundle exec rake vox:build + env: + EZBAKE_ALLOW_UNREPRODUCIBLE_BUILDS: true + EZBAKE_BRANCH: no-bundle-on-local-build + EZBAKE_NODEPLOY: true + EZBAKE_REPO: https://github.com/rwaffen/ezbake + LEIN_PROFILES: ezbake clojure-linting: name: Clojure Linting diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 45be9e47d..000000000 --- a/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM almalinux:9 - -WORKDIR / - -RUN dnf install -y --enablerepo=crb vim wget git rpm-build java-11-openjdk java-11-openjdk-devel libyaml-devel zlib zlib-devel gcc-c++ patch readline readline-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison sqlite-devel -RUN wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein -RUN chmod a+x lein -RUN mv lein /usr/local/bin -RUN wget -q https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer -O- | bash -# todo: it would be great if we could get the used ruby version from openvox-agent and use it here -# and maybe don't randomly download rbenv and leiningen -# and how bad is it that we hardcode java 11 above? -RUN /bin/bash --login -c 'rbenv install 3.2.8' -RUN /bin/bash --login -c 'rbenv global 3.2.8' -RUN git config --global user.email "openvox@voxpupuli.org" -RUN git config --global user.name "Vox Pupuli" -RUN git config --global --add safe.directory /code - -CMD ["tail -f /dev/null"] diff --git a/Gemfile b/Gemfile index 44c076a0d..9f7da3412 100644 --- a/Gemfile +++ b/Gemfile @@ -11,8 +11,6 @@ def location_for(place, fake_version = nil) end gem 'public_suffix', '>= 4.0.7', '< 7' -# 1.0.0 is the first OpenVoxProject release -gem 'packaging', '~> 1.0', github: 'OpenVoxProject/packaging' gem 'rake', :group => [:development, :test] group :test do @@ -29,6 +27,12 @@ group :test do gem 'docker-api', '>=1.31.0', '< 3' end +# cut from ezbake +group :packaging do + gem 'packaging', '~> 1.0', github: 'OpenVoxProject/packaging' + gem 'fpm', '~> 1.16' +end + group :release, optional: true do # usually we pin to ~> 2.1, but some of the EoL beaker 6 dependencies require ancient faraday versions # it's all a huge pain and the beaker setup needs to be reworked diff --git a/tasks/build.rake b/tasks/build.rake index 210f9bbb3..b6698e533 100644 --- a/tasks/build.rake +++ b/tasks/build.rake @@ -18,71 +18,34 @@ rpm_platforms = ENV['RPM_PLATFORMS'] || 'el-7,el-8,el-9,el-10,sles-15,amazon-202 @debs = deb_platforms.split(',').map{ |p| "base-#{p.split('-').join}-i386.cow" }.join(' ') @rpms = rpm_platforms.split(',').map{ |p| "pl-#{p}-x86_64" }.join(' ') -def image_exists - !`docker images -q #{@image}`.strip.empty? -end - -def container_exists - !`docker container ls --all --filter 'name=#{@container}' --format json`.strip.empty? -end - -def teardown - if container_exists - puts "Stopping #{@container}" - run_command("docker stop #{@container}", silent: false, print_command: true) - run_command("docker rm #{@container}", silent: false, print_command: true) - end -end - -def start_container(ezbake_dir) - run_command("docker run -d --name #{@container} -v .:/code -v #{ezbake_dir}:/ezbake #{@image} /bin/sh -c 'tail -f /dev/null'", silent: false, print_command: true) -end - -def run(cmd) - run_command("docker exec #{@container} /bin/bash --login -c '#{cmd}'", silent: false, print_command: true) -end - namespace :vox do desc 'Build openvox-server packages with Docker' task :build, [:tag] do |_, args| - begin - #abort 'You must provide a tag.' if args[:tag].nil? || args[:tag].empty? - if args[:tag].nil? || args[:tag].empty? - puts 'running build with current branch' - else - puts "running build on #{args[:tag]}" - run_command("git fetch --tags && git checkout #{args[:tag]}") - end - - # If the Dockerfile has changed since this was last built, - # delete all containers and do `docker rmi ezbake-builder` - unless image_exists - puts "Building ezbake-builder image" - run_command("docker build -t ezbake-builder .", silent: false, print_command: true) - end - - puts "Checking out ezbake" - tmp = Dir.mktmpdir("ezbake") - ezbake_dir = "#{tmp}/ezbake" - ezbake_repo = ENV.fetch('EZBAKE_REPO', 'https://github.com/openvoxproject/ezbake') - ezbake_branch = ENV['EZBAKE_BRANCH'] || 'main' - run_command("git clone -b #{ezbake_branch} #{ezbake_repo} #{ezbake_dir}", silent: false, print_command: true) - - puts "Starting container" - teardown if container_exists - start_container(ezbake_dir) - - puts "Installing ezbake from source" - run("cd /ezbake && lein install") - - puts "Building openvox-server" - run("cd /code && rm -rf ruby && rm -rf output && bundle install --without test && lein install") - run("cd /code && COW=\"#{@debs}\" MOCK=\"#{@rpms}\" GEM_SOURCE='https://rubygems.org' EZBAKE_ALLOW_UNREPRODUCIBLE_BUILDS=true EZBAKE_NODEPLOY=true LEIN_PROFILES=ezbake lein with-profile user,ezbake,provided,internal ezbake local-build") - run_command("sudo chown -R $USER output", print_command: true) - Dir.glob('output/**/*i386*').each { |f| FileUtils.rm_rf(f) } - Dir.glob('output/puppetserver-*.tar.gz').each { |f| FileUtils.mv(f, f.sub('puppetserver','openvox-server'))} - ensure - teardown + if args[:tag].nil? || args[:tag].empty? + puts 'running build with current branch' + else + puts "running build on #{args[:tag]}" + run_command("git fetch --tags && git checkout #{args[:tag]}") end + + puts "Checking out ezbake" + tmp = Dir.mktmpdir("ezbake") + ezbake_dir = "#{tmp}/ezbake" + ezbake_repo = ENV.fetch('EZBAKE_REPO', 'https://github.com/openvoxproject/ezbake') + ezbake_branch = ENV['EZBAKE_BRANCH'] || 'main' + run_command("git clone -b #{ezbake_branch} #{ezbake_repo} #{ezbake_dir}", silent: false, print_command: true) + + # prepare git foo for packaging gem (????) + run_command("git config --global user.email 'you@example.com'; git config --global user.name 'Your Name'") + + puts "Installing ezbake from source" + run_command("cd #{ezbake_dir} && lein install", silent: false, print_command: true) + + puts "Building openvox-server" + run_command("rm -rf ruby && rm -rf output && bundle install --without test && lein install", silent: false, print_command: true) + run_command("COW=\"#{@debs}\" MOCK=\"#{@rpms}\" lein with-profile user,ezbake,provided ezbake local-build", silent: false, print_command: true) + run_command("sudo chown -R $USER output", print_command: true) + Dir.glob('output/**/*i386*').each { |f| FileUtils.rm_rf(f) } + Dir.glob('output/puppetserver-*.tar.gz').each { |f| FileUtils.mv(f, f.sub('puppetserver','openvox-server'))} end end