From b299290afdf0f06ad6f3e1098dc74a6a4dd0970e Mon Sep 17 00:00:00 2001 From: Sarun Nuntaviriyakul <48861591+guyzsarun@users.noreply.github.com> Date: Tue, 25 Jul 2023 16:20:55 +0200 Subject: [PATCH] Feature: TFC rpm (#9) --- .dockerignore | 3 +- .github/workflows/main.yaml | 99 +++++++++++++++++++++---------------- .gitignore | 3 +- docker/Dockerfile | 33 +++---------- docker/Dockerfile.rpm | 40 +++++++++++++++ spec/xrootd-cmstfc.spec | 78 +++++++++++++++++++++++++++++ 6 files changed, 187 insertions(+), 69 deletions(-) create mode 100644 docker/Dockerfile.rpm create mode 100644 spec/xrootd-cmstfc.spec diff --git a/.dockerignore b/.dockerignore index 2425e8c..3bf32ae 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,4 +2,5 @@ build CMakeFiles tests/**/*.pyc .github -.pytest_cache \ No newline at end of file +.pytest_cache +*.tar.gz \ No newline at end of file diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 933b4cc..40d2b27 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -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 @@ -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 \ No newline at end of file + run: docker push ${{ env.LATEST_TAG }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 93ee0ff..a985daa 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,5 @@ /build /CMakeFiles Makefile -tests/**/*.pyc \ No newline at end of file +tests/**/*.pyc +*.tar.gz \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index c3a84df..7791e6b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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 \ diff --git a/docker/Dockerfile.rpm b/docker/Dockerfile.rpm new file mode 100644 index 0000000..6eb58c8 --- /dev/null +++ b/docker/Dockerfile.rpm @@ -0,0 +1,40 @@ +FROM almalinux:8 +MAINTAINER Sarun Nuntaviriyakul +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 \ No newline at end of file diff --git a/spec/xrootd-cmstfc.spec b/spec/xrootd-cmstfc.spec new file mode 100644 index 0000000..35119da --- /dev/null +++ b/spec/xrootd-cmstfc.spec @@ -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 \ No newline at end of file