Skip to content

Commit 986a9e8

Browse files
committed
CI: catch up with that of memo
Use rmkdir and NPROC.
1 parent eb210aa commit 986a9e8

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

.gitlab-ci.yml

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,22 @@ before_script:
2222
# Use a tmp to avoid partial uploads when interrupted.
2323
# A single call to ssh, rather than scp and then ssh.
2424
- function smv { dst=$3/$(basename "$1") && time ssh "$2" "cat > '$dst.tmp' && mv -f '$dst.tmp' '$dst'" < "$1" && rm -f "$1"; }
25+
# rmkdir DIR -- remove and recreate a directory, which is possibly a symlink.
26+
# realpath about everywhere, readlink -f on CentOS
27+
- function rmkdir { dir=$(realpath "$1" || readlink -f "$1") 2>/dev/null && rm -rf "$dir" && mkdir -p "$dir"; }
28+
# nproc on GNU/Linux, sysctl on macOS
29+
- NPROC=$((nproc || sysctl -n hw.physicalcpu) 2>/dev/null)
2530

2631
x86_64-centos6-gcc4:
2732
stage: build
2833
script:
2934
- time scl enable devtoolset-4 rh-python34 "./buildenv --pick-build-tree --branch \"$CI_BUILD_REF_NAME\" --link-build-tree \"$BUILD_DIR\" --build-trees-root \"/cache/$CI_PROJECT_NAME\""
30-
- if test -n "$FROM_SCRATCH"; then dir=$(readlink -f $BUILD_DIR); rm -rf "$dir" && mkdir -p "$dir"; else time scl enable devtoolset-4 rh-python34 "./buildenv --cache-download-build-tree --exclude='*.deb,*.rpm,*.tbz' --branch \"$CI_BUILD_REF_NAME\" --build-trees-root \"/cache/$CI_PROJECT_NAME\" --cache-namespace \"$CI_RUNNER_DESCRIPTION/$CI_PROJECT_NAME\" --cache-id \"$CI_RUNNER_ID\" --verbose"; fi
35+
- if test -n "$FROM_SCRATCH"; then rmkdir "$BUILD_DIR"; else time scl enable devtoolset-4 rh-python34 "./buildenv --cache-download-build-tree --exclude='*.deb,*.rpm,*.tbz' --branch \"$CI_BUILD_REF_NAME\" --build-trees-root \"/cache/$CI_PROJECT_NAME\" --cache-namespace \"$CI_RUNNER_DESCRIPTION/$CI_PROJECT_NAME\" --cache-id \"$CI_RUNNER_ID\" --verbose"; fi
3136
- scl enable devtoolset-4 rh-python34 "farm/configure --arch x86_64 --os centos6 --compiler gcc4 --project $PROJECT --source-dir \"$SOURCE_DIR\" --build-dir \"$BUILD_DIR\" --install-dir \"$INSTALL_DIR\""
3237
- cd "$BUILD_DIR"
33-
- scl enable devtoolset-4 rh-python34 "python3 drake -j $(nproc) //build"
34-
- scl enable devtoolset-4 rh-python34 "python3 drake -j $(nproc) //check"
35-
- scl enable devtoolset-4 rh-python34 "python3 drake -j $(nproc) //install"
38+
- scl enable devtoolset-4 rh-python34 "python3 drake -j $NPROC //build"
39+
- scl enable devtoolset-4 rh-python34 "python3 drake -j $NPROC //check"
40+
- scl enable devtoolset-4 rh-python34 "python3 drake -j $NPROC //install"
3641
- TARBALL="$PROJECT-x86_64-centos6-gcc4-$DESC.tbz"
3742
- tar $TARFLAGS -cjf "$TARBALL" -C "$INSTALL_DIR" . --show-transformed-names --transform "s,^\\./,$PROJECT-$DESC/,"
3843
- smv "$TARBALL" [email protected] tmp
@@ -47,17 +52,17 @@ x86_64-ubuntu-gcc4:
4752
stage: build
4853
script:
4954
- time ./buildenv --pick-build-tree --branch "$CI_BUILD_REF_NAME" --link-build-tree "$BUILD_DIR" --build-trees-root "/cache/$CI_PROJECT_NAME"
50-
- if test -n "$FROM_SCRATCH"; then dir=$(realpath $BUILD_DIR); rm -rf "$dir" && mkdir -p "$dir"; else time ./buildenv --cache-download-build-tree --exclude='*.deb,*.rpm,*.tbz' --branch "$CI_BUILD_REF_NAME" --build-trees-root "/cache/$CI_PROJECT_NAME" --cache-namespace "$CI_RUNNER_DESCRIPTION/$CI_PROJECT_NAME" --cache-id "$CI_RUNNER_ID" --verbose; fi
55+
- if test -n "$FROM_SCRATCH"; then rmkdir "$BUILD_DIR"; else time ./buildenv --cache-download-build-tree --exclude='*.deb,*.rpm,*.tbz' --branch "$CI_BUILD_REF_NAME" --build-trees-root "/cache/$CI_PROJECT_NAME" --cache-namespace "$CI_RUNNER_DESCRIPTION/$CI_PROJECT_NAME" --cache-id "$CI_RUNNER_ID" --verbose; fi
5156
- farm/configure --arch x86_64 --os trusty --compiler gcc4 --project $PROJECT --source-dir "$SOURCE_DIR" --build-dir "$BUILD_DIR" --install-dir "$INSTALL_DIR"
5257
- cd "$BUILD_DIR"
5358
- export ELLE_LOG_CHECK_FORMATS=1
54-
- python3 drake -j $(nproc) //build
55-
- python3 drake -j $(($(nproc) / 4)) //check
56-
- python3 drake -j $(nproc) //install
59+
- python3 drake -j $NPROC //build
60+
- python3 drake -j $(($NPROC / 4)) //check
61+
- python3 drake -j $NPROC //install
5762
- TARBALL="$BUILD_DIR/$PROJECT-x86_64-ubuntu-gcc4-$DESC.tbz"
5863
- tar $TARFLAGS -cjf "$TARBALL" -C "$INSTALL_DIR" . --show-transformed-names --transform "s,^\\./,$PROJECT-$DESC/,"
5964
- smv "$TARBALL" [email protected] tmp
60-
- python3 drake -j $(nproc) //docker
65+
- python3 drake -j $NPROC //docker
6166
- docker tag $PROJECT:${DESC} mefyl/$PROJECT:${DESC}
6267
- docker push mefyl/$PROJECT:${DESC}
6368
- docker rmi {,mefyl/}$PROJECT:${DESC}
@@ -72,12 +77,12 @@ x86_64-jessie-gcc4:
7277
stage: build
7378
script:
7479
- time ./buildenv --pick-build-tree --branch "$CI_BUILD_REF_NAME" --link-build-tree "$BUILD_DIR" --build-trees-root "/cache/$CI_PROJECT_NAME"
75-
- if test -n "$FROM_SCRATCH"; then dir=$(realpath $BUILD_DIR); rm -rf "$dir" && mkdir -p "$dir"; else time ./buildenv --cache-download-build-tree --exclude='*.deb,*.rpm,*.tbz' --branch "$CI_BUILD_REF_NAME" --build-trees-root "/cache/$CI_PROJECT_NAME" --cache-namespace "$CI_RUNNER_DESCRIPTION/$CI_PROJECT_NAME" --cache-id "$CI_RUNNER_ID" --verbose; fi
80+
- if test -n "$FROM_SCRATCH"; then rmkdir "$BUILD_DIR"; else time ./buildenv --cache-download-build-tree --exclude='*.deb,*.rpm,*.tbz' --branch "$CI_BUILD_REF_NAME" --build-trees-root "/cache/$CI_PROJECT_NAME" --cache-namespace "$CI_RUNNER_DESCRIPTION/$CI_PROJECT_NAME" --cache-id "$CI_RUNNER_ID" --verbose; fi
7681
- farm/configure --arch x86_64 --os jessie --compiler gcc4 --project $PROJECT --source-dir "$SOURCE_DIR" --build-dir "$BUILD_DIR" --install-dir "$INSTALL_DIR"
7782
- cd "$BUILD_DIR"
78-
- python3 drake -j $(nproc) //build
79-
- python3 drake -j $(nproc) //check
80-
- python3 drake -j $(nproc) //install
83+
- python3 drake -j $NPROC //build
84+
- python3 drake -j $NPROC //check
85+
- python3 drake -j $NPROC //install
8186
- TARBALL="$BUILD_DIR/$PROJECT-x86_64-jessie-gcc4-$DESC.tbz"
8287
- tar $TARFLAGS -cjf "$TARBALL" -C "$INSTALL_DIR" . --show-transformed-names --transform "s,^\\./,$PROJECT-$DESC/,"
8388
- smv "$TARBALL" [email protected] tmp
@@ -92,12 +97,12 @@ x86_64-alpine-gcc:
9297
stage: build
9398
script:
9499
- time ./buildenv --pick-build-tree --branch "$CI_BUILD_REF_NAME" --link-build-tree "$BUILD_DIR" --build-trees-root "/cache/$CI_PROJECT_NAME"
95-
- if test -n "$FROM_SCRATCH"; then dir=$(realpath $BUILD_DIR); rm -rf "$dir" && mkdir -p "$dir"; else time ./buildenv --cache-download-build-tree --exclude='*.deb,*.rpm,*.tbz' --branch "$CI_BUILD_REF_NAME" --build-trees-root "/cache/$CI_PROJECT_NAME" --cache-namespace "$CI_RUNNER_DESCRIPTION/$CI_PROJECT_NAME" --cache-id "$CI_RUNNER_ID" --verbose; fi
100+
- if test -n "$FROM_SCRATCH"; then rmkdir "$BUILD_DIR"; else time ./buildenv --cache-download-build-tree --exclude='*.deb,*.rpm,*.tbz' --branch "$CI_BUILD_REF_NAME" --build-trees-root "/cache/$CI_PROJECT_NAME" --cache-namespace "$CI_RUNNER_DESCRIPTION/$CI_PROJECT_NAME" --cache-id "$CI_RUNNER_ID" --verbose; fi
96101
- farm/configure --arch x86_64 --os alpine --compiler gcc4 --project $PROJECT --source-dir "$SOURCE_DIR" --build-dir "$BUILD_DIR" --install-dir "$INSTALL_DIR"
97102
- cd "$BUILD_DIR"
98-
- python3 drake -j $(nproc) //build
99-
- python3 drake -j $(nproc) //check
100-
- python3 drake -j $(nproc) //install
103+
- python3 drake -j $NPROC //build
104+
- python3 drake -j $NPROC //check
105+
- python3 drake -j $NPROC //install
101106
- TARBALL="$BUILD_DIR/$PROJECT-x86_64-alpine-gcc-$DESC.tbz"
102107
- tar $TARFLAGS -cjf "$TARBALL" -C "$INSTALL_DIR" . --show-transformed-names --transform "s,^\\./,$PROJECT-$DESC/,"
103108
- smv "$TARBALL" [email protected] tmp
@@ -112,12 +117,12 @@ i386-jessie-gcc4:
112117
stage: build
113118
script:
114119
- time ./buildenv --pick-build-tree --branch "$CI_BUILD_REF_NAME" --link-build-tree "$BUILD_DIR" --build-trees-root "/cache/$CI_PROJECT_NAME"
115-
- if test -n "$FROM_SCRATCH"; then dir=$(realpath $BUILD_DIR); rm -rf "$dir" && mkdir -p "$dir"; else time ./buildenv --cache-download-build-tree --exclude='*.deb,*.rpm,*.tbz' --branch "$CI_BUILD_REF_NAME" --build-trees-root "/cache/$CI_PROJECT_NAME" --cache-namespace "$CI_RUNNER_DESCRIPTION/$CI_PROJECT_NAME" --cache-id "$CI_RUNNER_ID" --verbose; fi
120+
- if test -n "$FROM_SCRATCH"; then rmkdir "$BUILD_DIR"; else time ./buildenv --cache-download-build-tree --exclude='*.deb,*.rpm,*.tbz' --branch "$CI_BUILD_REF_NAME" --build-trees-root "/cache/$CI_PROJECT_NAME" --cache-namespace "$CI_RUNNER_DESCRIPTION/$CI_PROJECT_NAME" --cache-id "$CI_RUNNER_ID" --verbose; fi
116121
- farm/configure --arch i386 --os jessie --compiler gcc4 --project $PROJECT --source-dir "$SOURCE_DIR" --build-dir "$BUILD_DIR" --install-dir "$INSTALL_DIR"
117122
- cd "$BUILD_DIR"
118-
- python3 drake -j $(nproc) //build
119-
- python3 drake -j $(nproc) //check
120-
- python3 drake -j $(nproc) //install
123+
- python3 drake -j $NPROC //build
124+
- python3 drake -j $NPROC //check
125+
- python3 drake -j $NPROC //install
121126
- TARBALL="$BUILD_DIR/$PROJECT-i386-jessie-gcc4-$DESC.tbz"
122127
- tar $TARFLAGS -cjf "$TARBALL" -C "$INSTALL_DIR" . --show-transformed-names --transform "s,^\\./,$PROJECT-$DESC/,"
123128
- smv "$TARBALL" [email protected] tmp
@@ -132,12 +137,12 @@ x86_64-windows-mingw4:
132137
stage: build
133138
script:
134139
- time ./buildenv --pick-build-tree --branch "$CI_BUILD_REF_NAME" --link-build-tree "$BUILD_DIR" --build-trees-root "/cache/$CI_PROJECT_NAME"
135-
- if test -n "$FROM_SCRATCH"; then dir=$(realpath $BUILD_DIR); rm -rf "$dir" && mkdir -p "$dir"; else time ./buildenv --cache-download-build-tree --exclude='*.deb,*.rpm,*.tbz' --branch "$CI_BUILD_REF_NAME" --build-trees-root "/cache/$CI_PROJECT_NAME" --cache-namespace "$CI_RUNNER_DESCRIPTION/$CI_PROJECT_NAME" --cache-id "$CI_RUNNER_ID" --verbose; fi
140+
- if test -n "$FROM_SCRATCH"; then rmkdir "$BUILD_DIR"; else time ./buildenv --cache-download-build-tree --exclude='*.deb,*.rpm,*.tbz' --branch "$CI_BUILD_REF_NAME" --build-trees-root "/cache/$CI_PROJECT_NAME" --cache-namespace "$CI_RUNNER_DESCRIPTION/$CI_PROJECT_NAME" --cache-id "$CI_RUNNER_ID" --verbose; fi
136141
- farm/configure --arch x86_64 --os windows --compiler mingw4 --project $PROJECT --source-dir "$SOURCE_DIR" --build-dir "$BUILD_DIR" --install-dir "$INSTALL_DIR"
137142
- cd "$BUILD_DIR"
138-
- python3 drake -j $(nproc) //build
139-
- python3 drake -j $(nproc) //check
140-
- python3 drake -j $(nproc) //install
143+
- python3 drake -j $NPROC //build
144+
- python3 drake -j $NPROC //check
145+
- python3 drake -j $NPROC //install
141146
- TARBALL="$BUILD_DIR/$PROJECT-x86_64-windows-mingw4-$DESC.tbz"
142147
- tar $TARFLAGS -cjf "$TARBALL" -C "$INSTALL_DIR" . --show-transformed-names --transform "s,^\\./,$PROJECT-$DESC/,"
143148
- smv "$TARBALL" [email protected] tmp
@@ -156,9 +161,9 @@ x86_64-osx-clang:
156161
- INSTALL_DIR=$SOURCE_DIR/../$PROJECT-install
157162
- if test -n "$FROM_SCRATCH"; then rm -rf $BUILD_DIR; fi
158163
- farm/configure --arch x86_64 --os osx --compiler clang --project $PROJECT --source-dir $SOURCE_DIR --build-dir $BUILD_DIR --install-dir $INSTALL_DIR
159-
- cd $BUILD_DIR && python3 drake -j 4 //build
160-
- cd $BUILD_DIR && python3 drake -j 4 //check
161-
- cd $BUILD_DIR && python3 drake -j 4 //install
164+
- cd $BUILD_DIR && python3 drake -j $NPROC //build
165+
- cd $BUILD_DIR && python3 drake -j $NPROC //check
166+
- cd $BUILD_DIR && python3 drake -j $NPROC //install
162167
- TARBALL=../$PROJECT-x86_64-osx-clang3-$DESC.tbz
163168
- gtar $TARFLAGS -cjf "$TARBALL" -C $INSTALL_DIR . --show-transformed-names --transform "s,^\\./,$PROJECT-$DESC/,"
164169
- smv "$TARBALL" [email protected] tmp

0 commit comments

Comments
 (0)