Skip to content

Commit 25b4166

Browse files
c-dilkstongtongcao
authored andcommitted
fix: require git-lfs for build option --lfs (#965)
Without this check, if the user lacks `git-lfs`, then `--lfs` will only get the stub files.
1 parent abdaee8 commit 25b4166

File tree

3 files changed

+31
-32
lines changed

3 files changed

+31
-32
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,8 @@ jobs:
8787
run: libexec/version-bump.sh ${{ github.ref_name }}
8888
- name: build
8989
run: |
90-
git lfs install
91-
git submodule update --init ./etc/data/magfield
92-
./build-coatjava.sh --cvmfs --no-progress -T${{ env.nthreads }}
93-
./install-clara -b -c ./coatjava ./clara
90+
./build-coatjava.sh --lfs --no-progress -T${{ env.nthreads }}
91+
./install-clara -b -c ./coatjava ./clara
9492
- name: tar # tarball to preserve permissions
9593
run: |
9694
tar czvf coatjava.tar.gz coatjava

.gitlab-ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ build:
5050
optional: true
5151
script:
5252
- git config --global --add safe.directory $CI_PROJECT_DIR
53-
- git lfs install
54-
- git submodule update --init etc/data/magfield
55-
- ./build-coatjava.sh --clara -T$JL_RUNNER_AVAIL_CPU --quiet --no-progress
53+
- ./build-coatjava.sh --lfs --clara -T$JL_RUNNER_AVAIL_CPU --quiet --no-progress
5654
- tar -czf coatjava.tar.gz coatjava
5755
- tar -czf clara.tar.gz clara
5856
artifacts:

build-coatjava.sh

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,27 @@ set -o pipefail
88
usage='''build-coatjava.sh [OPTIONS]... [MAVEN_OPTIONS]...
99
1010
OPTIONS
11-
11+
--clara install clara too
1212
--clean clean up built objects and exit (does not compile)
13+
--quiet run more quietly
14+
--no-progress no download progress printouts
15+
--help show this message
1316
17+
OPTIONS FOR MAGNETIC FIELD MAPS
18+
--lfs use git-lfs for field maps and test data
19+
--cvmfs use cvmfs to download field maps
20+
--xrootd use xrootd to download field maps
1421
--nomaps do not download field maps
1522
23+
OPTIONS FOR TESTING
1624
--spotbugs also run spotbugs plugin
1725
--unittests also run unit tests
18-
1926
--depana run dependency analysis (only)
20-
21-
--quiet run more quietly
22-
--no-progress no download progress printouts
23-
24-
--xrootd use xrootd to download field maps
25-
--cvmfs use cvmfs to download field maps
26-
--lfs use lfs for field maps and test data
27-
28-
--clara install clara too
2927
--data download test data (requires lfs)
3028
31-
--help show this message
32-
3329
MAVEN_OPTIONS
34-
35-
all other arguments will be passed to `mvn`, e.g., -T4 will build with 4 parallel threads
30+
all other arguments will be passed to `mvn`; for example,
31+
-T4 will build with 4 parallel threads
3632
'''
3733

3834
cleanBuild="no"
@@ -79,7 +75,7 @@ done
7975

8076
if $downloadData && ! $useLfs; then
8177
echo "$usage"
82-
echo "ERROR::::::::::: --data requires --lfs"
78+
echo "ERROR::::::::::: --data requires --lfs" >&2
8379
exit 2
8480
fi
8581

@@ -110,10 +106,16 @@ download () {
110106
xrdcp $1 ./
111107
ret=$?
112108
elif $useLfs; then
113-
cd $src_dir
114-
git submodule update --init etc/data/magfield
115-
if $downloadData; then git submodule update --init validation/advanced-tests/data; fi
116-
cd - > /dev/null
109+
if command_exists git-lfs ; then
110+
cd $src_dir > /dev/null
111+
git lfs install
112+
git submodule update --init etc/data/magfield
113+
if $downloadData; then git submodule update --init validation/advanced-tests/data; fi
114+
cd - > /dev/null
115+
else
116+
echo 'ERROR: `git-lfs` not found; please install it, or use a different option other than `--lfs`' >&2
117+
ret=1
118+
fi
117119
elif $useCvmfs; then
118120
cp -v $1 ./
119121
ret=$?
@@ -127,7 +129,7 @@ download () {
127129
fi
128130
else
129131
ret=1
130-
echo ERROR::::::::::: Could not find wget nor curl.
132+
echo "ERROR::::::::::: Could not find wget nor curl." >&2
131133
fi
132134
return $ret
133135
}
@@ -148,11 +150,12 @@ if [ $cleanBuild == "no" ] && [ $downloadMaps == "yes" ]; then
148150
do
149151
download $webDir/$map
150152
if [ $? -ne 0 ]; then
151-
echo ERROR::::::::::: Could not download field map:
152-
echo $webDir/$map
153-
echo One option is to download manually into etc/data/magfield and then run this build script with --nomaps
153+
echo "ERROR::::::::::: Could not download field map:" >&2
154+
echo "$webDir/$map" >&2
155+
echo "One option is to download manually into etc/data/magfield and then run this build script with --nomaps" >&2
154156
exit 1
155157
fi
158+
$useLfs && break
156159
done
157160
cd -
158161
fi
@@ -208,7 +211,7 @@ if [ $runSpotBugs == "yes" ]; then
208211
$mvn com.github.spotbugs:spotbugs-maven-plugin:check # check goal produces a report and produces build failed if bugs
209212
# the spotbugsXml.xml file is easiest read in a web browser
210213
# see http://spotbugs.readthedocs.io/en/latest/maven.html and https://spotbugs.github.io/spotbugs-maven-plugin/index.html for more info
211-
if [ $? != 0 ] ; then echo "spotbugs failure" ; exit 1 ; fi
214+
if [ $? != 0 ] ; then echo "spotbugs failure" >&2 ; exit 1 ; fi
212215
fi
213216

214217
# installation

0 commit comments

Comments
 (0)