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 something #4

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions .github/scripts/fetch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
deps=$(spack dependents $1)
deps="edm4hep k4fwcore"
for d in $deps
do
echo $d
done
ls -lah
41 changes: 41 additions & 0 deletions .github/workflows/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Add manually some environment variables because when there is A depends on B depends on C
# dependency and B is an external the dependency A->C is lost in spack
import subprocess
import os
import yaml
import re

CONFIG = '/Package/spack/var/spack/environments/dev/spack.yaml'
CMAKE_PATHS = ['nlohmann-json']
CPATHS = ['vdt']
VERSION = re.compile('\d*\.\d*\.\d*')

with open(CONFIG) as f:
base = yaml.safe_load(f.read())
if 'compilers' not in base['spack']:
path = [x for x in os.environ['CXX'].split(':') if f'/gcc/' in x][0]
if '/bin/g++' in path:
path = path.removesuffix('/bin/g++')
version = re.search(VERSION, path).group(0)
base['spack']['compilers'] = [{'compiler': {'spec': f'gcc@{version}',
'paths': {'cc': os.path.join(path, 'bin/gcc'),
'cxx': os.path.join(path, 'bin/g++'),
'f77': os.path.join(path, 'bin/gfortran'),
'fc': os.path.join(path, 'bin/gfortran')},
'flags': {},
'operating_system': 'centos7',
'target': 'x86_64',
'modules': [],
'environment': {'prepend_path': {'CMAKE_PREFIX_PATH': '/cvmfs/sw.hsf.org/spackages6/nlohmann-json/3.10.5/x86_64-centos7-gcc11.2.0-opt/v3dm7',
'CPATH': '/cvmfs/sw.hsf.org/spackages6/vdt/0.4.3/x86_64-centos7-gcc11.2.0-opt/wth5f/include'}},
'extra_rpaths': []}}]
if 'prepend_path' not in base['spack']['compilers'][0]['compiler']['environment']:
base['spack']['compilers'][0]['compiler']['environment']['prepend_path'] = {'CMAKE_PREFIX_PATH': '', 'CPATH': ''}

paths = [[x for x in os.environ['CMAKE_PREFIX_PATH'].split(':') if f'/{p}/' in x][0] for p in CMAKE_PATHS]
base['spack']['compilers'][0]['compiler']['environment']['prepend_path']['CMAKE_PREFIX_PATH'] = ':'.join(base['spack']['compilers'][0]['compiler']['environment']['prepend_path']['CMAKE_PREFIX_PATH'].split(':')+paths)

paths = [[os.path.join(x, 'include') for x in os.environ['CMAKE_PREFIX_PATH'].split(':') if f'/{p}/' in x][0] for p in CPATHS]
base['spack']['compilers'][0]['compiler']['environment']['prepend_path']['CPATH'] = ':'.join(base['spack']['compilers'][0]['compiler']['environment']['prepend_path']['CPATH'].split(':')+paths)

yaml.dump(base, open(CONFIG, 'w'))
20 changes: 0 additions & 20 deletions .github/workflows/coverity.yml

This file was deleted.

70 changes: 0 additions & 70 deletions .github/workflows/edm4hep.yaml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/externals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add manually some externals so that spack can pick them up
import subprocess
import os
import re
import yaml

PACKAGES = '/root/.spack/packages.yaml'
EXTERNALS = ['root', 'py-cython', 'py-pip', 'libyaml', 'py-setuptools', 'py-wheel', 'py-markupsafe',
'py-jinja2', 'py-pyyaml', 'nlohmann-json', 'intel-tbb', 'boost', 'gaudi', 'dd4hep', 'gdb']
VERSION = re.compile('\d*\.\d*\.\d*')

out = subprocess.check_output(f'spack external {' '.join(EXTERNALS)}'.split()).decode()
print(out)
with open(PACKAGES) as f:
base = yaml.safe_load(f.read())
for p in EXTERNALS:
if f'{p}@' not in out:
path = [x for x in os.environ['CMAKE_PREFIX_PATH'].split(':') if f'/{p}/' in x]
if not path:
print(f'Unable to find external {p}')
continue
path = path[0]
version = re.search(VERSION, path).group(0)
base['packages'][f'{p}'] = {'externals': [{'spec': f'{p}@{version}', 'prefix': f'{path}'}]}
yaml.dump(base, open(PACKAGES, 'w'))
35 changes: 35 additions & 0 deletions .github/workflows/fetch_and_checkout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Clone the list of dependents repo to the current one
# and also an input list of repos in branch other than the default one
# Usage: python3 fetch_and_checkout.py current_repo owner1 repo1 branch1 onwer2 repo2 branch2 ...
import subprocess
import sys
import os

EXCLUDE = ['cepcsw', 'dd4hep', 'gaudi', 'key4hep-stack']

name = sys.argv[1]
if len(sys.argv) == 3:
packages = [x.split() for x in sys.argv[2].split('\n')]
else:
packages = []

# packages.append('jmcarcell podio test'.split())
# print(packages)

out = subprocess.check_output(f'spack dependents {name}'.split()).decode()
for p in out.split():
if p in EXCLUDE:
continue
# if p not in ['podio', 'edm4hep', 'k4edm4hep2lcioconv']:
# continue
# TODO: fix finding the right owner
packages.append(['key4hep', p, None])

pwd = os.getcwd()

for owner, repo, branch in packages:
print(owner, repo, branch)
if branch:
subprocess.check_output(f'git clone https://github.com/{owner}/{repo} --branch {branch} --depth 1', shell=True)
subprocess.check_output(f'spack develop --no-clone --path {os.path.join(pwd, repo)} {repo}@master', shell=True)
subprocess.check_output(f'spack add {repo}@master', shell=True)
44 changes: 0 additions & 44 deletions .github/workflows/key4hep.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/parse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import re
import sys
import json
import requests

URL_PATTERN = r'https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)'

# text = sys.argv[1]
text = """blablablablaaoeu aoeuh assoehu saoetu hasoeuh
important pRPRP this is atoeut haetu.
asaeu depends on https://github.com/jmcarcell/k4FWCore/pull/1"""

# print('Parsing text in the PR to find other branches that will be compiled together...')
res = re.search(f'[dD]epends +(?:on)? *{URL_PATTERN}', text)
if not res:
print('No linked PRs could be found, the current branch will be compiled with the master branches of other packages')
exit()
# print(res.groups())
for group in res.groups():
ls = group.split('/')
owner = ls[1]
repo = ls[2]
number = ls[4]
response = requests.get(f'https://api.github.com/repos/{owner}/{repo}/pulls/{number}')
js = response.json()
_, branch = js['head']['label'].split(':')
print(owner, repo, branch)
print(owner, repo, branch)
42 changes: 0 additions & 42 deletions .github/workflows/pre-commit.yml

This file was deleted.

74 changes: 74 additions & 0 deletions .github/workflows/prs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: linux

on: pull_request

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cvmfs_base: ['sw-nightlies.hsf.org']
ENVIRONMENT: ['key4hep']
steps:
- uses: actions/checkout@v3
- uses: cvmfs-contrib/github-action-cvmfs@v3

- name: Start container
run: |
docker run -it --name CI_container -v ${GITHUB_WORKSPACE}:/Package/main -v /cvmfs:/cvmfs:shared -d centos:7 /bin/bash
- name: CMake Configure
run: |
docker exec CI_container /bin/bash -c 'cd ./Package/main;\
echo "BODY: " ;\
echo ${{ github.event.pull_request.body }};\
mkdir -p build install;\
source /cvmfs/${{ matrix.cvmfs_base }}/${{ matrix.ENVIRONMENT }}/setup.sh;\
cd build;\
cmake -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS=" -fdiagnostics-color=always " -G Ninja ..;\
'
# ninja -k0 install'
- name: Fetch dependents
run: |
docker exec CI_container /bin/bash -c 'cd ./Package;\
# Lower caps name
name=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]');\
pip3 install --user requests
./main/.github/scripts/fetch.sh $1;\
ls -lah;\

name=podio
yum install -y glibc-devel git
cd Package
source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh;\
git clone https://github.com/spack/spack --depth 1;\
source spack/share/spack/setup-env.sh;\
git clone https://github.com/key4hep/key4hep-spack --depth 1;\
cd key4hep-spack;\
spack repo add .;\
cd ..;\
python3 /Package/main/.github/workflows/externals.py
branch_packages=$(python3 /Package/main/.github/workflows/parse.py ${{ github.event.pull_request.body }})
branch_packages=""
spack env create dev
spack env activate dev
python3 /Package/main/.github/workflows/config.py
python3 /Package/main/.github/workflows/fetch_and_checkout.py $name $branch_packages
cd main
spack develop --no-clone --path $PWD $name@master
spack add $name@master
spack concretize -f

'
# - name: Test
# run: |
# docker exec CI_container /bin/bash -c 'cd ./Package;\
# source /cvmfs/${{ matrix.cvmfs_base }}/${{ matrix.ENVIRONMENT }}/setup.sh;\
# cd build;\
# ninja -k0 && ctest --output-on-failure;'
# - name: Install
# run: |
# docker exec CI_container /bin/bash -c 'cd ./Package;\
# source /cvmfs/${{ matrix.cvmfs_base }}/${{ matrix.ENVIRONMENT }}/setup.sh;\
# cd build;\
# ninja -k0 install;'
Loading