Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 51 additions & 22 deletions .github/workflows/build-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,69 @@ on:
- '*'

jobs:
ROOT5:
build:
if: github.repository_owner == 'star-bnl'
runs-on: ubuntu-latest
strategy:
matrix:
starenv: [root5]
compiler: [gcc485]
env:
STARENV: ${{ matrix.starenv }}-${{ matrix.compiler }}
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v4.8
uses: tj-actions/branch-names@v6

- name: Define complete image tag
run: |
echo "TAG=${{ steps.branch-name.outputs.current_branch || steps.branch-name.outputs.tag }}-${{ env.STARENV }}" >> $GITHUB_ENV

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Rebuild up to base-stage
uses: docker/build-push-action@v2
with:
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/star-sw-root5-base:cache
file: docker/Dockerfile.root5
target: base-stage
push: true
tags: ghcr.io/${{ github.repository_owner }}/star-sw-root5-base:${{ steps.branch-name.outputs.current_branch }}_latest
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/star-sw-root5-base:cache,mode=max

- name: Build release container
if: steps.branch-name.outputs.is_tag == 'true'
uses: docker/build-push-action@v2
- name: Build a release container
uses: docker/build-push-action@v3
with:
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/star-sw-root5-base:cache
file: docker/Dockerfile.root5
target: build-stage
push: true
tags: ghcr.io/${{ github.repository_owner }}/star-sw-root5-build:${{ steps.branch-name.outputs.tag }}
build-args: |
starenv=${{ matrix.starenv }}
compiler=${{ matrix.compiler }}
load: true
tags: ghcr.io/${{ github.repository_owner }}/star-sw:${{ env.TAG }}

- name: Push container image
run: |
docker push ghcr.io/${{ github.repository_owner }}/star-sw:${{ env.TAG }}

- name: Create latest tag for default branch
if: ${{ steps.branch-name.outputs.is_tag == 'false' && steps.branch-name.outputs.is_default == 'true' && env.STARENV == 'root5-gcc485' }}
run: |
docker tag ghcr.io/${{ github.repository_owner }}/star-sw:${{ env.TAG }} ghcr.io/${{ github.repository_owner }}/star-sw:latest
docker push ghcr.io/${{ github.repository_owner }}/star-sw:latest

- name: Create latest tag for SL* branches
if: ${{ steps.branch-name.outputs.is_tag == 'false' && steps.branch-name.outputs.is_default == 'false' && env.STARENV == 'root5-gcc485' }}
run: |
docker tag ghcr.io/${{ github.repository_owner }}/star-sw:${{ env.TAG }} ghcr.io/${{ github.repository_owner }}/star-sw:${{ steps.branch-name.outputs.current_branch }}
docker push ghcr.io/${{ github.repository_owner }}/star-sw:${{ steps.branch-name.outputs.current_branch }}

- name: Create image tag based on pushed tag
if: ${{ steps.branch-name.outputs.is_tag == 'true' && env.STARENV == 'root5-gcc485' }}
run: |
docker tag ghcr.io/${{ github.repository_owner }}/star-sw:${{ env.TAG }} ghcr.io/${{ github.repository_owner }}/star-sw:${{ steps.branch-name.outputs.tag }}
docker push ghcr.io/${{ github.repository_owner }}/star-sw:${{ steps.branch-name.outputs.tag }}

build-cleanup:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
- run: .github/workflows/delete_untagged.py ${{ secrets.STAR_BNL_STAR_SW_TOKEN }}
117 changes: 117 additions & 0 deletions .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Build Pull Request

on:
pull_request:
paths-ignore:
- '.github/**'
- 'docs/**'
- '!.github/workflows/**'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
starenv: [root5]
compiler: [gcc485]
env:
STARENV: ${{ matrix.starenv }}-${{ matrix.compiler }}
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=10000000

- name: Build with Docker
uses: docker/build-push-action@v3
with:
build-args: |
starenv=${{ matrix.starenv }}
compiler=${{ matrix.compiler }}
tags: ghcr.io/star-bnl/star-sw-${{ env.STARENV }}
outputs: type=docker,dest=/tmp/star-sw-${{ env.STARENV }}.tar

- name: Save built image for test jobs
uses: actions/upload-artifact@v3
with:
name: star-sw-${{ env.STARENV }}
path: /tmp/star-sw-${{ env.STARENV }}.tar

ROOT5_test:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
test_id: [10, 11, 22, 23, 24, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 59, 60, 76, 77, 78, 90, 91, 92, 101, 112, 113, 114, 115]
compiler: [gcc485]
env:
STARENV: root5-${{ matrix.compiler }}
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: star-sw-${{ env.STARENV }}
path: /tmp

- run: docker load --input /tmp/star-sw-${{ env.STARENV }}.tar
- run: docker run --name star-test-data --volume /star ghcr.io/star-bnl/star-test-data:v7
- run: |
TEST_CMD=$(docker run --rm ghcr.io/star-bnl/star-sw-${{ env.STARENV }} tests/executest.py -c ${{ matrix.test_id }})
# Workaround https://sft.its.cern.ch/jira/browse/ROOT-7660 in ROOT 5 by checking the output log
docker run --volumes-from star-test-data ghcr.io/star-bnl/star-sw-${{ env.STARENV }} \
sh -c "set -e; MALLOC_CHECK_=3 $TEST_CMD 2>&1 | tee log; grep 'Run completed' log"

ROOT5_test_doEvents:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
test_id: [121, 122]
compiler: [gcc485]
env:
STARENV: root5-${{ matrix.compiler }}
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: star-sw-${{ env.STARENV }}
path: /tmp

- run: docker load --input /tmp/star-sw-${{ env.STARENV }}.tar
- run: docker run --name star-test-data --volume /star ghcr.io/star-bnl/star-test-data:v7
- run: |
TEST_FILE=$(echo "$(docker run --rm ghcr.io/star-bnl/star-sw-${{ env.STARENV }} tests/executest.py ${{ matrix.test_id }} -a fullpath)" | sed -E 's/\.(daq|fzd)$/.event.root/')
TEST_CMD="root4star -b -q -l 'StRoot/macros/analysis/doEvents.C(100, \"$TEST_FILE\")'"
docker run --volumes-from star-test-data ghcr.io/star-bnl/star-sw-${{ env.STARENV }} \
sh -c "set -e; $TEST_CMD 2>&1 | tee log; grep '<StIOMaker::Finish> IO:' log"

ROOT5_test_find_vertex:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
test_id: [102, 121, 122]
compiler: [gcc485]
env:
STARENV: root5-${{ matrix.compiler }}
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: star-sw-${{ env.STARENV }}
path: /tmp

- run: docker load --input /tmp/star-sw-${{ env.STARENV }}.tar
- run: docker run --name star-test-data --volume /star ghcr.io/star-bnl/star-test-data:v7
- run: |
TEST_FILE=$(echo "$(docker run --rm ghcr.io/star-bnl/star-sw-${{ env.STARENV }} tests/executest.py ${{ matrix.test_id }} -a fullpath)" | sed -E 's/\.(daq|fzd)$/.event.root/')
TEST_CMD="root4star -b -q -l 'StRoot/macros/analysis/find_vertex.C(\"$TEST_FILE\")'"
docker run --volumes-from star-test-data ghcr.io/star-bnl/star-sw-${{ env.STARENV }} \
sh -c "set -e; $TEST_CMD 2>&1 | tee log; grep '<StIOMaker::Finish> StIO:' log"
56 changes: 0 additions & 56 deletions .github/workflows/ci-build.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/delete_untagged.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3

import argparse
import json
import requests
import types

parser = argparse.ArgumentParser()
parser.add_argument("token", help="GitHub token")
args = parser.parse_args()

domain = "api.github.com"
org = "star-bnl"
package_type = "container"
package_name = "star-sw"

api_url = f"https://{domain}/orgs/{org}/packages/{package_type}/{package_name}/versions"

respjson = requests.get(api_url, auth=("token", args.token))
entries = json.loads(respjson.text, object_hook=lambda d: types.SimpleNamespace(**d))

for e in entries:
if not e.metadata.container.tags:
response = requests.delete(api_url + f"/{e.id}", auth=("token", args.token))
print("delete", e.id, e.html_url, e.name, response.url, response.status_code)
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# syntax=docker/dockerfile:latest

ARG starenv=root5

# Pick one from [gcc485, gcc11]
ARG compiler=gcc485

FROM ghcr.io/star-bnl/star-spack:v0.2.3-${starenv}-${compiler}

ARG compiler

ENV NODEBUG=yes
ENV STAR=/star-sw
ENV STAR_LIB=$STAR/.${STAR_HOST_SYS}/LIB
ENV STAR_BIN=$STAR/.${STAR_HOST_SYS}/BIN
ENV STAR_SYS=x8664_sl7
ENV PATH=$STAR_BIN:$STAR/mgr:$PATH
ENV LD_LIBRARY_PATH=$STAR_LIB:$LD_LIBRARY_PATH
ENV ROOT_INCLUDE_PATH=$STAR/.${STAR_HOST_SYS}/include

WORKDIR ${STAR}
COPY . ${STAR}

SHELL ["/bin/bash", "-l", "-c"]

RUN <<EOF
set -e
SKIP_DIRS="pams/sim/g2r OnlTools StRoot/StShadowMaker StRoot/RTS/EventTracker" cons
find .$STAR_HOST_SYS -name *.o -exec rm '{}' \;
EOF

COPY --chmod=0755 <<-"EOF" /opt/entrypoint.sh
#!/bin/bash -l
set -e
install $STAR/StRoot/macros/.rootrc .
exec "$@"
EOF

ENTRYPOINT ["/opt/entrypoint.sh"]
CMD ["/bin/bash"]
5 changes: 3 additions & 2 deletions StRoot/StDaqLib/SC/SC_Reader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <assert.h>
#include <math.h>
#include <ctime>

using namespace OLDEVP;

Expand Down Expand Up @@ -97,8 +98,8 @@ SC_Reader::SC_Reader(EventReader *er) {
//Keep BBCBkg scalers flipped as theyStRoot/StDaqLib/SC/SC_Reader.cxx were historically before 2009
//Note that new DAQ reader leads to UTime = 0, or tm_year=70 (1970)
//but new DAQ reader only gets used for 2009+ anyhow
unsigned int UTime = er->getEventInfo().UnixTime;
struct tm *time=gmtime((time_t*) &UTime);
std::time_t utime = er->getEventInfo().UnixTime;
std::tm *time = gmtime(&utime);
flipBBCBkg = (time->tm_year > 95 && time->tm_year < 109 ? 1 : 0) ;

// LDate = (((1900+time->tm_year)*100 + 1 + time->tm_mon)*100 + time->tm_mday)*100;
Expand Down
5 changes: 3 additions & 2 deletions StRoot/StDaqLib/SSD/SSD_Reader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <assert.h>
#include <math.h>
#include <ctime>

static unsigned short log8to10_table[256] = {
0, 1, 2, 3, 4, 5, 6, 7,
Expand Down Expand Up @@ -118,8 +119,8 @@ SSD_Reader::SSD_Reader(EventReader *er) {
datap=er->getDATAP();
if (datap) {

unsigned int UTime = er->getEventInfo().UnixTime;
struct tm *time=gmtime((time_t*) &UTime);
std::time_t utime = er->getEventInfo().UnixTime;
std::tm *time = gmtime(&utime);

//LDate = (((1900+time->tm_year)*100 + 1 + time->tm_mon)*100 + time->tm_mday)*100;
//LDate = yyyymmdd
Expand Down
4 changes: 3 additions & 1 deletion StRoot/StEEmcUtil/EEfeeRaw/RootWrapper.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <cstdlib>
#include <cstdio>
#include <ctime>

#include "TROOT.h"
#include "TFile.h"
Expand Down Expand Up @@ -57,7 +58,8 @@ eemcfeerootopen_(long& run, long& runtime, char *chfile, int &nAuto, int len)
char *idt = strchr(basefile,'.'); *idt = 0x00; // locate first dot
}
sprintf(filename,"%s/%s.ez.root",rootdir,basefile);
sprintf(comment,"run:%05ld, time:%s ",run,ctime((time_t *)&runtime));
std::time_t utime = runtime;
sprintf(comment,"run:%05ld, time:%s ",run,ctime(&utime));

file = new TFile(filename,"RECREATE");
tree = new TTree("ezstar","A tree with FEE events");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <stdio.h>
#include <math.h>
#include <curses.h>

#include "StFgtAlignmentMaker.h"
#include "StEventTypes.h"
Expand Down
Loading