Skip to content

Commit

Permalink
Merge pull request #35 from KSkwarczynski/feature_CI
Browse files Browse the repository at this point in the history
CI/CD to make nuwro containers
  • Loading branch information
jsobczyk authored Nov 16, 2024
2 parents cf1d497 + f68fbff commit 1fb778b
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/CDImage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
# Update NuWro container image registry with newest updates
name: Image CD

# The events that trigger the workflow
on:
push:
branches:
- master
tags:
- 'v*'

permissions:
contents: read
packages: write

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false # KS: Prevents cancellation of remaining jobs if one fails
matrix:
include:
- os: alma9
file: doc/docker/alma9/Dockerfile
tag_latest: alma9latest

name: Image CD ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build Docker image
run: |
if [ "${{ github.ref_type }}" == "tag" ]; then
docker build . \
--file "${{ matrix.file }}" \
--tag "ghcr.io/${{ github.repository_owner }}/nuwro:${{ matrix.os }}${{ github.ref_name }}" \
--build-arg NUWRO_VERSION="${{ github.ref_name }}" \
else
docker build . \
--file "${{ matrix.file }}" \
--tag "ghcr.io/${{ github.repository_owner }}/nuwro:${{ matrix.tag_latest }}" \
--build-arg NUWRO_VERSION="develop" \
fi
- name: Push Docker image
run: |
if [ "${{ github.ref_type }}" == "tag" ]; then
docker push "ghcr.io/${{ github.repository_owner }}/nuwro:${{ matrix.os }}${{ github.ref_name }}"
else
docker push "ghcr.io/${{ github.repository_owner }}/nuwro:${{ matrix.tag_latest }}"
fi
- name: Delete old images
uses: actions/delete-package-versions@v5
with:
package-name: 'nuwro'
package-type: 'container'
min-versions-to-keep: 5
delete-only-untagged-versions: 'true'
35 changes: 35 additions & 0 deletions .github/workflows/CIBuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
# Check if NuWro compiles correctly

name: Build CI

# The events that trigger the workflow
on:
pull_request:
branches: [ master ]

permissions:
contents: read
packages: write

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false # KS: Prevents cancellation of remaining jobs if one fails
matrix:
include:
- os: alma9
file: doc/docker/alma9/Dockerfile
tag: alma9latest

name: Build CI ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build the Docker image
run: docker build . --file ${{ matrix.file }} --tag ghcr.io/${{ github.repository_owner }}/nuwro:${{ matrix.tag }} --build-arg NUWRO_VERSION=${{ github.head_ref }}
36 changes: 36 additions & 0 deletions doc/docker/alma9/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM picker24/root_v6_26_10:alma9 AS nuwro_build
WORKDIR /

ARG NUWRO_VERSION=master
ENV NUWRO_VERSION=${NUWRO_VERSION}

ENV NUWRO_WORK_DIR=/opt/nuwro-src/

WORKDIR /opt/
RUN --mount=type=ssh git clone https://github.com/NuWro/nuwro.git ${NUWRO_WORK_DIR}
WORKDIR /opt/nuwro-src
RUN git checkout ${NUWRO_VERSION}

RUN sed -i "s:-lPythia6:-L${PYTHIA6} -lPythia6:g" Makefile
RUN make -j4

FROM picker24/root_v6_26_10:alma9
WORKDIR /

RUN mkdir -p /opt/nuwro/build/src/dis
RUN mkdir -p /opt/nuwro/build/src/espp
RUN mkdir -p /opt/nuwro/build/src/sf
RUN mkdir -p /opt/nuwro/build/src/rpa
RUN mkdir -p /opt/nuwro/build/src/rew
COPY --from=nuwro_build /opt/nuwro-src/data /opt/nuwro/build/data
COPY --from=nuwro_build /opt/nuwro-src/bin /opt/nuwro/build/bin
COPY --from=nuwro_build /opt/nuwro-src/src/*.h /opt/nuwro/build/src/
COPY --from=nuwro_build /opt/nuwro-src/src/dis/*.h /opt/nuwro/build/src/dis/
COPY --from=nuwro_build /opt/nuwro-src/src/espp/*.h /opt/nuwro/build/src/espp/
COPY --from=nuwro_build /opt/nuwro-src/src/sf/*.h /opt/nuwro/build/src/sf/
COPY --from=nuwro_build /opt/nuwro-src/src/rpa/*.h /opt/nuwro/build/src/rpa/
COPY --from=nuwro_build /opt/nuwro-src/src/rew/*.h /opt/nuwro/build/src/rew/

ENV NUWRO=/opt/nuwro/build
ENV PATH=${NUWRO}/bin:${PATH}
ENV ROOT_INCLUDE_PATH=${NUWRO}/src:${ROOT_INCLUDE_PATH}

0 comments on commit 1fb778b

Please sign in to comment.