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 conda environment file and CI #21

Merged
merged 12 commits into from
Nov 10, 2023
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Dockerfile
.github
74 changes: 74 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -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
42 changes: 24 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 && \
Expand Down
13 changes: 13 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: post_processing_agent_py2
channels:
- conda-forge
- defaults
dependencies:
- python=2.7
peterfpeterson marked this conversation as resolved.
Show resolved Hide resolved
- pip
- pytest
- pytest-cov
- pip:
- stompest==2.1.6
# needed for wheel - add when switching to python3
# - build
Loading