Browse Source

Add self-ci-rust

master
Travis Burtrum 2 years ago
parent
commit
9fa6cca726
  1. 21
      .jenkins/Jenkinsfile
  2. 4
      java/readme.md
  3. 2
      readme.md
  4. 6
      run.sh
  5. 18
      rust/Dockerfile
  6. 7
      rust/build.sh
  7. 16
      rust/readme.md

21
.jenkins/Jenkinsfile vendored

@ -31,7 +31,7 @@ node { @@ -31,7 +31,7 @@ node {
stage('Build self-ci-java') {
sh '''
set -ex
exit 0
image_tag="$BRANCH_NAME"
[ "$image_tag" == "master" ] && image_tag=latest
@ -44,6 +44,22 @@ node { @@ -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') {
sh '''
set -ex
@ -53,7 +69,8 @@ node { @@ -53,7 +69,8 @@ node {
# push our images, don't forget to docker login
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"
'''
}

4
java/readme.md

@ -6,11 +6,11 @@ A docker container with every version of the Java JDK 6 to 16 installed in it, a @@ -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:
```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:
```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
```

2
readme.md

@ -5,4 +5,4 @@ self-ci @@ -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.
todo: point to self-ci-java etc
todo: point to self-ci-java, rust etc

6
run.sh

@ -7,8 +7,10 @@ if [ ! -z "${BUILD_UID:-}" ] @@ -7,8 +7,10 @@ if [ ! -z "${BUILD_UID:-}" ]
then
BUILD_GID="${BUILD_GID:-$BUILD_UID}"
groupadd -r -g "$BUILD_GID" jenkins
useradd -r -u "$BUILD_UID" -g "$BUILD_GID" -s /bin/bash -m -d /root jenkins
chown "$BUILD_UID":"$BUILD_GID" /root
additional_groups=''
[ -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 sudo -E -u jenkins -- "$@"
fi

18
rust/Dockerfile

@ -0,0 +1,18 @@ @@ -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

@ -0,0 +1,7 @@ @@ -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

@ -0,0 +1,16 @@ @@ -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
```
Loading…
Cancel
Save