diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1822aef --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +Dockerfile +.github diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 0000000..48cef40 --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,74 @@ +name: CI + +on: + pull_request: + push: + branches: main + tags: ['v*'] + workflow_dispatch: + + +jobs: + tests: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Set up MicroMamba + uses: mamba-org/setup-micromamba@v1 + with: + environment-file: environment.yml + condarc: | + channels: + - conda-forge + - default + cache-environment: true + + - name: Unit test with code coverage + shell: bash -l {0} + run: python -m pytest -vv --cov=postprocessing --cov-report=xml --cov-report=term + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + rpm: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Build RPM inside Docker + run: | + docker build --tag postprocess --target=package -f Dockerfile . + fname=`docker run -v $(pwd):/store postprocess ls /root/rpmbuild/RPMS/noarch` + docker run -v `pwd`:/store postprocess mv /root/rpmbuild/RPMS/noarch/$fname /store + one=${fname#*postprocessing-} + two=${one%.noarch*} + echo "::set-output name=version::$two" + echo "::set-output name=fname::$fname" + continue-on-error: false + +# TODO: uncomment this once we have switched to python3 and can conda install the module build +# wheel: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout Repository +# uses: actions/checkout@v2 +# +# - name: Set up MicroMamba +# uses: mamba-org/setup-micromamba@v1 +# with: +# environment-file: environment.yml +# condarc: | +# channels: +# - conda-forge +# - default +# cache-environment: true +# +# - name: Build wheel +# shell: bash -l {0} +# run: python -m build --wheel diff --git a/Dockerfile b/Dockerfile index feb58b5..3c6f51f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,34 @@ -FROM centos:7 +FROM --platform=linux/amd64 centos:7 as package + +RUN yum install -y make rpm-build +# lots of packages don't exist in rhel7 +# the Makefile will print lots of warnings as a result + +WORKDIR /app + +COPY scripts /app/scripts +COPY configuration /app/configuration +COPY postprocessing /app/postprocessing +COPY SPECS /app/SPECS +COPY Makefile /app/ + + +RUN mkdir -p /root/rpmbuild/SOURCES + +RUN make rpm || exit 1 + +FROM --platform=linux/amd64 centos:7 as app +COPY --from=package /root/rpmbuild/RPMS/noarch/postprocessing-*-1.noarch.rpm / + RUN curl http://packages.sns.gov/distros/rhel/7/sns/sns.repo -o /etc/yum.repos.d/sns.repo RUN yum install -y epel-release RUN yum updateinfo -RUN yum install -y \ - python-requests \ - python-twisted-core \ - python-twisted-web \ - python-twisted-words \ - python-stompest \ - python2-stompest-async \ - python-pip \ - nexus \ - nexus-python \ - make \ - numpy - -COPY . . - -RUN make install -RUN cp configuration/post_process_consumer.conf.development /etc/autoreduce/post_processing.conf +RUN yum install -y /postprocessing-*-1.noarch.rpm || exit 1 # This configuration allows it to run with docker-compose from https://github.com/neutrons/data_workflow +COPY configuration/post_process_consumer.conf.development /etc/autoreduce/post_processing.conf RUN sed -i 's/localhost/activemq/' /etc/autoreduce/post_processing.conf RUN echo "#!/bin/bash" > /usr/bin/run_postprocessing && \ diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..a768b24 --- /dev/null +++ b/environment.yml @@ -0,0 +1,13 @@ +name: post_processing_agent_py2 +channels: + - conda-forge + - defaults +dependencies: + - python=2.7 + - pip + - pytest + - pytest-cov + - pip: + - stompest==2.1.6 +# needed for wheel - add when switching to python3 +# - build