Add self-ci-rust
Some checks reported errors
moparisthebest/self-ci/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
Travis Burtrum 2020-11-21 21:31:34 -05:00
parent 022e12a487
commit 9fa6cca726
7 changed files with 67 additions and 7 deletions

21
.jenkins/Jenkinsfile vendored
View File

@ -31,7 +31,7 @@ node {
stage('Build self-ci-java') { stage('Build self-ci-java') {
sh ''' sh '''
set -ex set -ex
exit 0
image_tag="$BRANCH_NAME" image_tag="$BRANCH_NAME"
[ "$image_tag" == "master" ] && image_tag=latest [ "$image_tag" == "master" ] && image_tag=latest
@ -44,6 +44,22 @@ node {
''' '''
} }
stage('Build self-ci-rust') {
sh '''
set -ex
image_tag="$BRANCH_NAME"
[ "$image_tag" == "master" ] && image_tag=latest
cd rust
# build our image
docker build -t "moparisthebest/self-ci-rust:$image_tag" .
cd ..
'''
}
stage('Push to docker hub') { stage('Push to docker hub') {
sh ''' sh '''
set -ex set -ex
@ -53,7 +69,8 @@ node {
# push our images, don't forget to docker login # push our images, don't forget to docker login
docker push "moparisthebest/self-ci-base:$image_tag" docker push "moparisthebest/self-ci-base:$image_tag"
docker push "moparisthebest/self-ci-java:$image_tag" #docker push "moparisthebest/self-ci-java:$image_tag"
docker push "moparisthebest/self-ci-rust:$image_tag"
''' '''
} }

View File

@ -6,11 +6,11 @@ A docker container with every version of the Java JDK 6 to 16 installed in it, a
Meant to be ran in CI something like this: Meant to be ran in CI something like this:
```sh ```sh
docker run --rm -v "$HOME/.m2:/m2" -v "$PWD:/build" -e BRANCH_NAME -e BUILD_UID=$UID -e BUILD_GID=$(id -g) moparisthebest/java-ci:latest docker run --rm -v "$HOME/.m2:/m2" -v "$PWD:/build" -e BRANCH_NAME -e BUILD_UID=$UID -e BUILD_GID=$(id -g) moparisthebest/self-ci-java:latest
``` ```
Without arguments it will execute `.jenkins/build.sh` once for each version of Java installed, setting the env variables JAVA_VERSION (a number), JAVA_HOME, M2_HOME, and PATH appropriately so invocations of `mvn` and `java` *just work*. If you want to call another script each time: Without arguments it will execute `.jenkins/build.sh` once for each version of Java installed, setting the env variables JAVA_VERSION (a number), JAVA_HOME, M2_HOME, and PATH appropriately so invocations of `mvn` and `java` *just work*. If you want to call another script each time:
```sh ```sh
docker run --rm -v "$HOME/.m2:/m2" -v "$PWD:/build" -e BRANCH_NAME -e BUILD_UID=$UID -e BUILD_GID=$(id -g) moparisthebest/java-ci:latest build.sh ./path/to/your/script.sh docker run --rm -v "$HOME/.m2:/m2" -v "$PWD:/build" -e BRANCH_NAME -e BUILD_UID=$UID -e BUILD_GID=$(id -g) moparisthebest/self-ci-java:latest build.sh ./path/to/your/script.sh
``` ```

View File

@ -5,4 +5,4 @@ self-ci
This is one of the steps in fully replacing travis-ci for my own uses, but feel free to use/PR/improve. This is one of the steps in fully replacing travis-ci for my own uses, but feel free to use/PR/improve.
todo: point to self-ci-java etc todo: point to self-ci-java, rust etc

6
run.sh
View File

@ -7,8 +7,10 @@ if [ ! -z "${BUILD_UID:-}" ]
then then
BUILD_GID="${BUILD_GID:-$BUILD_UID}" BUILD_GID="${BUILD_GID:-$BUILD_UID}"
groupadd -r -g "$BUILD_GID" jenkins groupadd -r -g "$BUILD_GID" jenkins
useradd -r -u "$BUILD_UID" -g "$BUILD_GID" -s /bin/bash -m -d /root jenkins additional_groups=''
chown "$BUILD_UID":"$BUILD_GID" /root [ -e /var/run/docker.sock ] && additional_groups="-G $(stat -c '%g' /var/run/docker.sock)"
useradd -r -u "$BUILD_UID" -g "$BUILD_GID" $additional_groups -s /bin/bash -m -d /root jenkins
chown -R "$BUILD_UID":"$BUILD_GID" /root
#exec runuser -m jenkins -- "$@" #exec runuser -m jenkins -- "$@"
exec sudo -E -u jenkins -- "$@" exec sudo -E -u jenkins -- "$@"
fi fi

18
rust/Dockerfile Normal file
View File

@ -0,0 +1,18 @@
FROM moparisthebest/self-ci-base:latest
# set CROSS_DOCKER_IN_DOCKER to inform `cross` that it is executed from within a container
#ENV CROSS_DOCKER_IN_DOCKER=true
RUN mkdir /cargo && ln -sf /cargo/ /root/.cargo && \
pacman -Syu --noconfirm --needed docker rustup gcc && \
rustup install stable && rustup default stable && \
cargo install --root / cross
COPY ./build.sh /usr/bin/
VOLUME [ "/build", "/var/run/docker.sock" ]
WORKDIR /build
ENTRYPOINT ["/usr/bin/run.sh"]
CMD ["/usr/bin/build.sh", "./.jenkins/build.sh"]

7
rust/build.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
set -euo pipefail
for TARGET in ${BUILD_TARGETS:-x86_64-unknown-linux-musl}
do
TARGET="$TARGET" "$@"
done

16
rust/readme.md Normal file
View File

@ -0,0 +1,16 @@
self-ci-rust
------------
A docker container with rustup and [cross](https://github.com/rust-embedded/cross) that runs a script with every variant cross supports.
Meant to be ran in CI something like this:
```sh
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$PWD:/build" -e BRANCH_NAME -e BUILD_UID=$UID -e BUILD_GID=$(id -g) moparisthebest/self-ci-rust:latest
```
Without arguments it will execute `.jenkins/build.sh` once for each docker container cross supports, setting the env variables TARGET and DISABLE_TESTS appropriately so invocations of `cross` and `cargo` *just work*. If you want to call another script each time:
```sh
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$PWD:/build" -e BRANCH_NAME -e BUILD_UID=$UID -e BUILD_GID=$(id -g) moparisthebest/self-ci-rust:latest build.sh ./path/to/your/script.sh
```