Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RPM packaging tests and RPM packaging rake task #1329

Merged
merged 3 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,40 @@ jobs:
kubectl cluster-info
- name: Test k8s-bootstrap
run: /bin/bash hooks/k8s-bootstrap/k8s-bootstrap-ondemand.sh test hooks/hook.env.example

rpm-packaging-tests:
strategy:
matrix:
os: ["ubuntu-latest"]
johrstrom marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ${{ matrix.os }}
name: RPM packaging tests

steps:
- name: Checkout ${{ github.sha }}
uses: actions/checkout@v2

- name: Ensure tags exist for packaging
run: git fetch --prune --unshallow --tags

- name: Set version
id: version
run: |
version=$(git describe --tags --abbrev=0)
echo ::set-output name=version::${version#v}

- name: Setup Ruby using Bundler
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.7.1"
bundler: "2.1.4"
bundler-cache: true

- name: Package EL7
run: bundle exec rake package:rpm[el7]
env:
VERSION: "${{ steps.version.outputs.version }}"

- name: Package EL8
run: bundle exec rake package:rpm[el8]
env:
VERSION: "${{ steps.version.outputs.version }}"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,6 @@ tags

# Ignore files downloaded for testing
/tests/*.zip

# Ignore temporary files
/tmp
31 changes: 30 additions & 1 deletion lib/tasks/packaging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ def tag_latest_container_cmd(image_name)
"#{container_runtime} tag #{image_name}:#{image_tag} #{image_name}:latest"
end

def git_clone_packaging(branch, dir)
args = ["clone", "--single-branch"]
args.concat ["--branch", branch]
args.concat ["https://github.com/OSC/ondemand-packaging.git", dir]

"git #{args.join(' ')}"
end

def rpm_build_cmd(packaging_dir, work_dir, output_dir, dist, version, extra_args)
args = ["-w", work_dir, "-o", output_dir]
args.concat ["-d", dist, "-V", "v#{version}"]

"#{File.join(packaging_dir, 'build.sh')} #{args.join(' ')} #{extra_args} #{File.join(Dir.pwd, 'packaging')}"
end

desc "Tar and zip OnDemand into packaging dir with version name v#<version>"
task :tar do
`which gtar 1>/dev/null 2>&1`
Expand Down Expand Up @@ -82,4 +97,18 @@ def tag_latest_container_cmd(image_name)
sh build_cmd("Dockerfile.dev", dev_image_name, extra_args: extra) unless image_exists?("#{dev_image_name}:#{image_tag}")
sh tag_latest_container_cmd(dev_image_name)
end
end

desc "Build RPM"
task :rpm, [:dist, :extra_args] => :tar do |t, args|
version = ENV['VERSION']
version_major, version_minor, version_patch = version.split('.', 3)
dist = args[:dist]
extra_args = args[:extra_args].nil? ? '' : args[:extra_args]
tmp_dir = File.join(Dir.pwd, 'tmp')
packaging_dir = File.join(tmp_dir, "ondemand-packaging")

Dir.mkdir(tmp_dir) unless Dir.exist?(tmp_dir)
sh git_clone_packaging("#{version_major}.#{version_minor}", packaging_dir) unless Dir.exist?(packaging_dir)
sh rpm_build_cmd(packaging_dir, File.join(tmp_dir, "work"), File.join(tmp_dir, "output"), dist, version, extra_args)
end
end