Skip to content

Commit

Permalink
fix: keep clas12Tags at 5.4 until 5.6 is ready (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks authored Jan 30, 2024
1 parent 4ceda09 commit 1fa8744
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 65 deletions.
56 changes: 36 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ env:
"eFT_K",
"e_gFT"
]
# default forks and branches
# default forks and branches; if `ref` is an empty string, the highest semver tag will be used
git_upstream: >-
{
"coatjava": { "fork": "JeffersonLab/coatjava", "ref": "development" },
"clas12Tags": { "fork": "gemc/clas12Tags", "ref": "main" },
"clas12Tags": { "fork": "gemc/clas12Tags", "ref": "5.4" },
"clas12-config": { "fork": "JeffersonLab/clas12-config", "ref": "main" },
"clas12-validation": { "fork": "JeffersonLab/clas12-validation", "ref": "main" }
}
Expand Down Expand Up @@ -125,31 +125,47 @@ jobs:
fork_clas12validation: ${{ steps.info.outputs.fork_clas12validation }}
ref_clas12validation: ${{ steps.info.outputs.ref_clas12validation }}
steps:
- uses: actions/checkout@v4
- name: get dependency info
id: info
run: |
echo '${{ env.git_upstream }}' > upstream.json
echo '${{ inputs.git_upstream || env.git_upstream }}' > caller_overrides.json
echo '{ "${{ github.event.repository.name }}": { "fork": "${{ github.event.pull_request.head.repo.full_name || github.repository }}", "ref": "${{ github.head_ref || github.ref_name }}" }}' > source.json
jq -sc add upstream.json caller_overrides.json source.json > deps.json
echo fork_coatjava=$(jq -r '."coatjava".fork' deps.json) >> $GITHUB_OUTPUT
echo ref_coatjava=$(jq -r '."coatjava".ref' deps.json) >> $GITHUB_OUTPUT
echo fork_clas12tags=$(jq -r '."clas12Tags".fork' deps.json) >> $GITHUB_OUTPUT
echo ref_clas12tags=$(jq -r '."clas12Tags".ref' deps.json) >> $GITHUB_OUTPUT
echo fork_clas12config=$(jq -r '."clas12-config".fork' deps.json) >> $GITHUB_OUTPUT
echo ref_clas12config=$(jq -r '."clas12-config".ref' deps.json) >> $GITHUB_OUTPUT
echo fork_clas12validation=$(jq -r '."clas12-validation".fork' deps.json) >> $GITHUB_OUTPUT
echo ref_clas12validation=$(jq -r '."clas12-validation".ref' deps.json) >> $GITHUB_OUTPUT
### get fork names and refs
fork_coatjava=$(jq -r '."coatjava".fork' deps.json)
fork_clas12tags=$(jq -r '."clas12Tags".fork' deps.json)
fork_clas12config=$(jq -r '."clas12-config".fork' deps.json)
fork_clas12validation=$(jq -r '."clas12-validation".fork' deps.json)
ref_coatjava=$(jq -r '."coatjava".ref' deps.json)
ref_clas12tags=$(jq -r '."clas12Tags".ref' deps.json)
ref_clas12config=$(jq -r '."clas12-config".ref' deps.json)
ref_clas12validation=$(jq -r '."clas12-validation".ref' deps.json)
### if any ref names are empty strings, use the highest tag instead
[ "$ref_coatjava" = "" ] && ref_coatjava=$(bin/get_highest_tag.rb $fork_coatjava)
[ "$ref_clas12tags" = "" ] && ref_clas12tags=$(bin/get_highest_tag.rb $fork_clas12tags)
[ "$ref_clas12config" = "" ] && ref_clas12config=$(bin/get_highest_tag.rb $fork_clas12config)
[ "$ref_clas12validation" = "" ] && ref_clas12validation=$(bin/get_highest_tag.rb $fork_clas12validation)
### set output vars
echo fork_coatjava=$fork_coatjava >> $GITHUB_OUTPUT
echo fork_clas12tags=$fork_clas12tags >> $GITHUB_OUTPUT
echo fork_clas12config=$fork_clas12config >> $GITHUB_OUTPUT
echo fork_clas12validation=$fork_clas12validation >> $GITHUB_OUTPUT
echo ref_coatjava=$ref_coatjava >> $GITHUB_OUTPUT
echo ref_clas12tags=$ref_clas12tags >> $GITHUB_OUTPUT
echo ref_clas12config=$ref_clas12config >> $GITHUB_OUTPUT
echo ref_clas12validation=$ref_clas12validation >> $GITHUB_OUTPUT
- name: dispatch summary
run: |
msg=$(echo '${{ github.event.pull_request.title || github.event.head_commit.message }}' | head -n1)
echo '| | | |' >> $GITHUB_STEP_SUMMARY
echo '| --- | --- | --- |' >> $GITHUB_STEP_SUMMARY
echo '| **Triggered By `${{ github.event_name }}`:** | <${{ github.event.pull_request.html_url || github.event.head_commit.url }}> | ' $msg ' |' >> $GITHUB_STEP_SUMMARY
echo '| **`coatjava` Fork and Branch:** | `${{ steps.info.outputs.fork_coatjava }}` | [`${{ steps.info.outputs.ref_coatjava }}`](https://github.com/${{ steps.info.outputs.fork_coatjava }}/tree/${{ steps.info.outputs.ref_coatjava }}) |' >> $GITHUB_STEP_SUMMARY
echo '| **`clas12Tags` Fork and Branch:** | `${{ steps.info.outputs.fork_clas12tags }}` | [`${{ steps.info.outputs.ref_clas12tags }}`](https://github.com/${{ steps.info.outputs.fork_clas12tags }}/tree/${{ steps.info.outputs.ref_clas12tags }}) |' >> $GITHUB_STEP_SUMMARY
echo '| **`clas12-config` Fork and Branch:** | `${{ steps.info.outputs.fork_clas12config }}` | [`${{ steps.info.outputs.ref_clas12config }}`](https://github.com/${{ steps.info.outputs.fork_clas12config }}/tree/${{ steps.info.outputs.ref_clas12config }}) |' >> $GITHUB_STEP_SUMMARY
echo '| **`clas12-validation` Fork and Branch:** | `${{ steps.info.outputs.fork_clas12validation }}` | [`${{ steps.info.outputs.ref_clas12validation }}`](https://github.com/${{ steps.info.outputs.fork_clas12validation }}/tree/${{ steps.info.outputs.ref_clas12validation }}) |' >> $GITHUB_STEP_SUMMARY
echo '| **`coatjava` Fork and Ref:** | `${{ steps.info.outputs.fork_coatjava }}` | [`${{ steps.info.outputs.ref_coatjava }}`](https://github.com/${{ steps.info.outputs.fork_coatjava }}/tree/${{ steps.info.outputs.ref_coatjava }}) |' >> $GITHUB_STEP_SUMMARY
echo '| **`clas12Tags` Fork and Ref:** | `${{ steps.info.outputs.fork_clas12tags }}` | [`${{ steps.info.outputs.ref_clas12tags }}`](https://github.com/${{ steps.info.outputs.fork_clas12tags }}/tree/${{ steps.info.outputs.ref_clas12tags }}) |' >> $GITHUB_STEP_SUMMARY
echo '| **`clas12-config` Fork and Ref:** | `${{ steps.info.outputs.fork_clas12config }}` | [`${{ steps.info.outputs.ref_clas12config }}`](https://github.com/${{ steps.info.outputs.fork_clas12config }}/tree/${{ steps.info.outputs.ref_clas12config }}) |' >> $GITHUB_STEP_SUMMARY
echo '| **`clas12-validation` Fork and Ref:** | `${{ steps.info.outputs.fork_clas12validation }}` | [`${{ steps.info.outputs.ref_clas12validation }}`](https://github.com/${{ steps.info.outputs.fork_clas12validation }}/tree/${{ steps.info.outputs.ref_clas12validation }}) |' >> $GITHUB_STEP_SUMMARY
echo '| | | |' >> $GITHUB_STEP_SUMMARY
# build
Expand Down Expand Up @@ -212,10 +228,10 @@ jobs:
fetch-tags: true
fetch-depth: 0
- name: build
uses: docker://jeffersonlab/gemc:4.4.2-5.1-5.2-5.3-fedora36-cvmfs ##### FIXME: need `latest` tag
uses: docker://jeffersonlab/gemc:4.4.2-5.4-5.5-fedora36 ##### FIXME: need `latest` tag
with:
entrypoint: bin/ci_build_gemc.sh ##### FIXME (in the script): switch to gemc/dev and use ubuntu + cvmfs action
args: clas12Tags/source
entrypoint: bin/ci_gemc.sh ##### FIXME (in the script): switch to gemc/dev and use ubuntu + cvmfs action
args: build clas12Tags/source
- name: tar
run: tar cavf clas12Tags{.tar.zst,}
- uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -441,10 +457,10 @@ jobs:
ls ${{ steps.files.outputs.gemcConfigFile }}
ls ${{ steps.files.outputs.coatjavaConfigFile }}
- name: simulation
uses: docker://jeffersonlab/gemc:4.4.2-5.1-5.2-5.3-fedora36-cvmfs ##### FIXME: need `latest` tag
uses: docker://jeffersonlab/gemc:4.4.2-5.4-5.5-fedora36 ##### FIXME: need `latest` tag
with:
entrypoint: bin/ci_sim.sh ##### FIXME (in the script): switch to gemc/dev and use ubuntu + cvmfs action
args: ${{ steps.files.outputs.gemcConfigFile }} ${{ steps.files.outputs.evgenFile }} ${{ steps.files.outputs.simFile }}
entrypoint: bin/ci_gemc.sh ##### FIXME (in the script): switch to gemc/dev and use ubuntu + cvmfs action
args: sim clas12Tags/source ${{ steps.files.outputs.gemcConfigFile }} ${{ steps.files.outputs.evgenFile }} ${{ steps.files.outputs.simFile }}
- name: check if output exists
run: ls ${{ steps.files.outputs.simFile }}
- name: reconstruction
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ jobs:
"coatjava": "10.0.0",
"gemc": "5.3"
}
# use a specific fork and ref (e.g., branch, commit, tag) of certain repositories (JSON string):
# use a specific fork and ref (e.g., branch, commit, tag) of certain repositories (JSON string);
# if 'ref' is an empty string, the highest semantic-versioned tag will be used
git_upstream: >-
{
"coatjava": { "fork": "UserName/coatjava", "ref": "feature-branch" },
Expand Down
19 changes: 0 additions & 19 deletions bin/ci_build_gemc.sh

This file was deleted.

79 changes: 79 additions & 0 deletions bin/ci_gemc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash
# CI `gemc` wrapper for CI workflow steps when `uses: [CONTAINER]` is used,
# which does not seem to be compatible with multi-line commands

set -e
set -u

### usage
if [ $# -eq 0 ]; then
echo """
USAGE: $0 [command] [ARGS]...
commands:
build compile GEMC
ARGS: [source_dir]
sim run GEMC
ARGS: [source_dir] [config] [input] [output]
""" >&2
exit 2
fi
cmd=$1
shift

### parse arguments
case $cmd in
build)
sourceDir=$1
;;
sim)
sourceDir=$1
gemcConfigFile=$2
evgenFile=$3
simFile=$4
;;
*)
echo "ERROR: unknown command '$cmd'" >&2
exit 1
;;
esac

### source environment, and show available modules
set +u
source /app/localSetup.sh
set -u
echo "=============================="
echo "MODULE AVAIL"
echo "=============================="
module avail --no-pager
echo "=============================="

### compile GEMC in $sourceDir
if [ "$cmd" = "build" ]; then
pushd $sourceDir
scons -j4 OPT=1
popd
fi

### to get the dependencies correct, switch to this tag
##### FIXME: switch to gemc/dev and use ubuntu + cvmfs action
module switch gemc/5.4

### run a simulation or print build info
case $cmd in
sim)
### run a simulation
$sourceDir/gemc \
$gemcConfigFile \
-INPUT_GEN_FILE="LUND, $evgenFile" \
-USE_GUI=0 \
-OUTPUT="hipo, $simFile"
;;
build)
### print build info
echo "### GEMC Build Information:"
$sourceDir/gemc -USE_GUI=0
;;
esac
21 changes: 0 additions & 21 deletions bin/ci_sim.sh

This file was deleted.

25 changes: 21 additions & 4 deletions bin/get_highest_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,29 @@
# gets the tag with the highest semver number
# - "highest" is preferred over "latest", because of backports to old tags may
# cause them to be "later" than "higher" tags
# - must be executed in a directory containing `.git/`
# - while this script may not be used in this repository, it may be used by caller workflows

tag_list = `git tag --list`.split.map{ |tag|
if ARGV.empty?
$stderr.puts "USAGE: #{$0} [repo owner]/[repo name]"
exit 2
end
repo = ARGV[0]

api_args = [
'--silent',
'-L',
'-H "Accept: application/vnd.github+json"',
'-H "X-GitHub-Api-Version: 2022-11-28"',
"https://api.github.com/repos/#{repo}/tags",
]
tag_list_unsorted = `curl #{api_args.join ' '} | jq -r '.[].name'`
unless $?.success?
$stderr.puts "ERROR: failed to get highest tag from repository '#{repo}'"
exit 1
end

tag_list = tag_list_unsorted.split.map{ |tag|
begin
Gem::Version.new tag
Gem::Version.new tag.gsub(/^v/,'')
rescue
nil
end
Expand Down

0 comments on commit 1fa8744

Please sign in to comment.