From 7d444361be67c9c5a8e1454854359627a3149b97 Mon Sep 17 00:00:00 2001 From: Dennis Klein Date: Mon, 3 Feb 2025 17:24:46 +0100 Subject: [PATCH] build: Rewrite dev container tasks to more idiomatic Ruby --- Rakefile | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Rakefile b/Rakefile index 4989ef3..5586465 100644 --- a/Rakefile +++ b/Rakefile @@ -13,18 +13,22 @@ task default: %i[rubocop spec integration] desc 'Build the ONA development container with podman' task :build_onadev_container do - unless system('podman image exists localhost/ona-dev:latest') - system('podman login docker.io') - `git clone https://github.com/opennetadmin/ona onadev` - `podman build --build-arg UBUNTU_VERSION=24.04 -t ona-dev:latest onadev` - `rm -rf onadev` + require 'fileutils' + require 'tmpdir' + sh 'podman login docker.io' + dir = Dir.mktmpdir + begin + sh "git clone --depth 1 https://github.com/opennetadmin/ona #{dir}" + sh "podman build --build-arg UBUNTU_VERSION=24.04 -t ona-dev:latest #{dir}" + ensure + FileUtils.remove_entry dir end end desc 'Publish ONA development container to ghcr.io' task publish_onadev_container_to_ghcr: :build_onadev_container do - system('podman login ghcr.io') - `podman image push localhost/ona-dev:latest docker://ghcr.io/gsi-hpc/ona-dev:latest` + sh 'podman login ghcr.io' + sh 'podman image push localhost/ona-dev:latest docker://ghcr.io/gsi-hpc/ona-dev:latest' end RSpec::Core::RakeTask.new(:integration) do |task|