Skip to content

Commit

Permalink
Feature: TFC rpm (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
guyzsarun authored Jul 25, 2023
1 parent 3c88292 commit b299290
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 69 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ build
CMakeFiles
tests/**/*.pyc
.github
.pytest_cache
.pytest_cache
*.tar.gz
99 changes: 57 additions & 42 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,68 +23,102 @@ jobs:
context: .
file: docker/Dockerfile
tags: ${{ env.TEST_TAG }}
outputs: type=docker,dest=/tmp/myimage.tar
load: true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: myimage
path: /tmp/myimage.tar

test-json:
name: Test LFN Conversion
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out Git repository
uses: actions/checkout@v2

- uses: docker/setup-buildx-action@v1

- name: Download artifact
uses: actions/download-artifact@v3
- name: Build Docker image
uses: docker/build-push-action@v4
with:
name: myimage
path: /tmp
context: .
file: docker/Dockerfile
load: true
tags: ${{ env.TEST_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Unit test
run: |
docker load --input /tmp/myimage.tar
docker run --rm ${{ env.TEST_TAG }} python3 -m pytest -v
test-rpm:
name: Test RPM package
name: Test JSON RPM package
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out Git repository
uses: actions/checkout@v2

- uses: docker/setup-buildx-action@v1

- name: Download artifact
uses: actions/download-artifact@v3
- name: Build Docker image
uses: docker/build-push-action@v4
with:
name: myimage
path: /tmp
context: .
file: docker/Dockerfile
load: true
tags: ${{ env.TEST_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Unit test
run: |
docker load --input /tmp/myimage.tar
docker run --rm ${{ env.TEST_TAG }} bash -c '
mkdir -p /root/rpmbuild/SOURCES/ &&
tar -cvf /root/rpmbuild/SOURCES/xrootd-cmsjson.tar.gz . &&
rpmbuild -bb spec/xrootd-cmsjson.spec
'
test-tfc:
name: Test TFC RPM package
runs-on: ubuntu-latest
needs: [test-json,test-rpm]
steps:
- name: Check out Git repository
uses: actions/checkout@v2

- uses: docker/setup-buildx-action@v1

- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: .
file: docker/Dockerfile.rpm
cache-from: type=gha
cache-to: type=gha,mode=max


push-registry:
name: Push to Registry
runs-on: ubuntu-latest
needs: [test-json,test-rpm]
needs: test-tfc
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/release'
steps:
- name: Check out Git repository
uses: actions/checkout@v2

- uses: docker/setup-buildx-action@v1

- name: Download artifact
uses: actions/download-artifact@v3
- name: Build Docker image
uses: docker/build-push-action@v4
with:
name: myimage
path: /tmp
context: .
file: docker/Dockerfile
load: true
tags: ${{ env.TEST_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Login to Docker Hub
uses: docker/login-action@v2
Expand All @@ -95,26 +129,7 @@ jobs:

- name: Tag image
run: |
docker load --input /tmp/myimage.tar
docker tag ${{ env.TEST_TAG }} ${{ env.LATEST_TAG }}
- name: Push to registry
run: docker push ${{ env.LATEST_TAG }}

build_tarball:
name: Build source archive
needs: [test-json,test-rpm]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Create source archive
run: tar -cvf xrootd-cmsjson.tar.gz *

- name: Upload source archive as artifact
if: always() && github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v3
with:
name: xrootd-cmsjson.tar.gz
path: xrootd-cmsjson.tar.gz
run: docker push ${{ env.LATEST_TAG }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@
/build
/CMakeFiles
Makefile
tests/**/*.pyc
tests/**/*.pyc
*.tar.gz
33 changes: 8 additions & 25 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,18 @@ LABEL org.opencontainers.image.source https://github.com/guyzsarun/xrootd-cmsjso
WORKDIR /xrootd

RUN yum -y update && \
yum install -y dnf
yum install -y dnf \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
https://repo.opensciencegrid.org/osg/3.6/osg-3.6-el8-release-latest.rpm \
epel-release

RUN dnf group install -y "Development Tools"
RUN dnf -y install \
cmake \
diffutils \
file \
fuse-devel \
gcc-c++ \
git \
json-c-devel \
krb5-devel \
libtool \
libuuid-devel \
libxml2-devel \
make \
openssl-devel \
python3-devel \
python3-setuptools \
readline-devel \
systemd-devel \
zlib-devel

RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
https://repo.opensciencegrid.org/osg/3.6/osg-3.6-el8-release-latest.rpm \
epel-release

# CMS json dependency
RUN yum install -y xrootd \
RUN yum install -y cmake \
wget \
xrootd \
python3-devel \
python3-xrootd \
xrootd-devel \
https://cbs.centos.org/kojifiles/packages/jsoncpp/1.9.4/4.el8s/x86_64/jsoncpp-1.9.4-4.el8s.x86_64.rpm \
Expand Down
40 changes: 40 additions & 0 deletions docker/Dockerfile.rpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM almalinux:8
MAINTAINER Sarun Nuntaviriyakul <sarun.nuntaviriyakul@cern.ch>
LABEL org.opencontainers.image.source https://github.com/guyzsarun/xrootd-cmsjson

WORKDIR /xrootd

RUN yum -y update && \
yum install -y dnf \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
https://repo.opensciencegrid.org/osg/3.6/osg-3.6-el8-release-latest.rpm \
epel-release

RUN dnf group install -y "Development Tools"

# CMSTFC dependency
RUN yum install -y cmake \
wget \
xrootd \
python3-devel \
python3-xrootd \
xrootd-devel \
pcre-devel \
xerces-c-devel \
xrootd-devel \
https://cbs.centos.org/kojifiles/packages/jsoncpp/1.9.4/4.el8s/x86_64/jsoncpp-1.9.4-4.el8s.x86_64.rpm \
https://cbs.centos.org/kojifiles/packages/jsoncpp/1.9.4/4.el8s/x86_64/jsoncpp-devel-1.9.4-4.el8s.x86_64.rpm



RUN mkdir -p /root/rpmbuild/SOURCES
RUN wget -O /root/rpmbuild/SOURCES/xrootd-cmstfc.tar.gz https://github.com/opensciencegrid/xrootd-cmstfc/archive/refs/tags/v1.5.2.tar.gz

COPY . .

#RUN wget -O /root/rpmbuild/SOURCES/xrootd-cmsjson.tar.gz https://github.com/guyzsarun/xrootd-cmsjson/archive/refs/tags/0.0.1.tar.gz
RUN tar -czf /root/rpmbuild/SOURCES/xrootd-cmsjson.tar.gz --transform=s/xrootd/xrootd-cmsjson-0.0.1/ /xrootd/

RUN rpmbuild -bb spec/xrootd-cmstfc.spec

RUN yum install -y /root/rpmbuild/RPMS/x86_64/xrootd-cmstfc-2.0.0-1.el8.x86_64.rpm
78 changes: 78 additions & 0 deletions spec/xrootd-cmstfc.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
%global debug_package %{nil}

%define package_xml xrootd-cmstfc-1.5.2
%define xrootd-cmstfc_URL https://github.com/bbockelm/xrootd-cmstfc

%define package_json xrootd-cmsjson-0.0.1
%define xrootd-cmsjson_URL https://github.com/guyzsarun/xrootd-cmsjson

Name: xrootd-cmstfc
Version: 2.0.0
Release: 1%{?dist}
Summary: CMS TFC plugin for xrootd

Group: System Environment/Daemons
License: BSD
Source0: xrootd-cmstfc.tar.gz
Source1: xrootd-cmsjson.tar.gz

BuildRequires: xerces-c-devel pcre-devel jsoncpp-devel >= 1.9.4
BuildRequires: cmake
Requires: /usr/bin/xrootd pcre xerces-c jsoncpp >= 1.9.4

%package devel
Summary: Development headers and libraries for XRootD CMSTFC plugin
Group: System Environment/Development

%description
%{summary}


%description devel
%{summary}

%prep
%setup -n %{package_xml}
cd ..
gzip -dc /root/rpmbuild/SOURCES/xrootd-cmsjson.tar.gz | tar -xvvf -

%build
pushd $RPM_BUILD_DIR/%{package_xml}
mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} ..
make VERBOSE=1 %{?_smp_mflags}
popd

pushd $RPM_BUILD_DIR/%{package_json}
mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} ..
make VERBOSE=1 %{?_smp_mflags}
popd


%install
rm -rf $RPM_BUILD_ROOT
pushd $RPM_BUILD_DIR/%{package_xml}/build
make install DESTDIR=$RPM_BUILD_ROOT
popd

pushd $RPM_BUILD_DIR/%{package_json}/build
make install DESTDIR=$RPM_BUILD_ROOT
popd

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%{_exec_prefix}/lib/libXrdCmsTfc.so
%{_libdir}/libXrdCmsJson.so

%files devel
%defattr(-,root,root,-)
%{_includedir}/XrdCmsTfc.hh
%{_includedir}/XrdCmsJson.hh

%changelog

0 comments on commit b299290

Please sign in to comment.