Skip to content

Commit

Permalink
User docker files for the CI (java-native-access#113)
Browse files Browse the repository at this point in the history
Motivation:

We should use the same docker / docker-compose file for the CI as we do when we build locally. This helps to keep things consistent and easy to reproduce

Modifications:

- Add new workflow that uses docker / docker-compose
- Adjust dockerfile to pre-download all dependencies
- Adjust dockerfile to pre-build quiche
- Add new docker-compose task that can be used to run the build against the pre-build quiche and so save time

Result:

Better CI setup
  • Loading branch information
normanmaurer authored Dec 19, 2020
1 parent df06b6e commit a3b15ac
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 40 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build project

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

schedule:
- cron: '30 7 * * 1' # At 07:30 on Monday, every Monday.

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
# http://man7.org/linux/man-pages/man1/date.1.html
- name: Create Cache Key
id: cache-key
run: |
echo "::set-output name=key::$(/bin/date -u "+%Y%U")"
shell: bash

- uses: actions/checkout@v2

# Enable caching of Docker layers
- uses: satackey/[email protected]
continue-on-error: true
with:
key: docker-cache-${{ steps.cache-key.outputs.key }}-{hash}
restore-keys: |
docker-cache-${{ steps.cache-key.outputs.key }}-
- name: Run docker-compose
run: docker-compose -f docker/docker-compose.centos-6.yaml -f docker/docker-compose.centos-6.18.yaml run build

- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: target
path: target/ # or path/to/artifact
27 changes: 0 additions & 27 deletions .github/workflows/maven.yml

This file was deleted.

17 changes: 14 additions & 3 deletions docker/Dockerfile.centos6
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,28 @@ run echo 'export C_INCLUDE_PATH="$HOME/.include/"' >> ~/.bashrc
# Needed to compile against old glibc
run echo 'export LDFLAGS=-lrt' >> ~/.bashrc

RUN rm -rf $SOURCE_DIR

ARG java_version=1.8
ENV JAVA_VERSION $java_version
# installing java with jabba
RUN curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | JABBA_COMMAND="install $JAVA_VERSION -o /jdk" bash


RUN echo 'export JAVA_HOME="/jdk"' >> ~/.bashrc
RUN echo 'PATH=/jdk/bin:$PATH' >> ~/.bashrc

# install rust and setup PATH
run curl https://sh.rustup.rs -sSf | sh -s -- -y
RUN echo 'PATH=$PATH:$HOME/.cargo/bin' >> ~/.bashrc

WORKDIR /opt
RUN curl https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz | tar -xz

# Prepare our own build
ENV PATH /opt/apache-maven-3.6.3/bin/:$PATH
ENV JAVA_HOME /jdk/

COPY ./pom.xml $SOURCE_DIR/pom.xml
WORKDIR $SOURCE_DIR
RUN /bin/bash -c 'source $HOME/.bashrc && mvn dependency:go-offline surefire:test -ntp'

# Pre-build quiche
RUN /bin/bash -c 'source $HOME/.bashrc && mvn antrun:run@build-quiche -DquicheCheckoutDir=$SOURCE_DIR/quiche'
9 changes: 6 additions & 3 deletions docker/docker-compose.centos-6.18.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ version: "3"
services:

runtime-setup:
image: netty-codec-quic-centos:centos-6-1.8
image: netty-codec-quic-centos6:centos-6-1.8
build:
args:
java_version : "[email protected]"

build:
image: netty-codec-quic-centos:centos-6-1.8
image: netty-codec-quic-centos6:centos-6-1.8

build-clean:
image: netty-codec-quic-centos6:centos-6-1.8

shell:
image: netty-codec-quic-centos:centos-6-1.8
image: netty-codec-quic-centos6:centos-6-1.8
12 changes: 8 additions & 4 deletions docker/docker-compose.centos-6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ version: "3"
services:

runtime-setup:
image: netty-codec-quic-centos:default
image: netty-codec-quic-centos6:default
build:
context: .
dockerfile: Dockerfile.centos6
context: ../
dockerfile: docker/Dockerfile.centos6

common: &common
image: netty-codec-quic-centos:default
image: netty-codec-quic-centos6:default
depends_on: [runtime-setup]
volumes:
- ~/.ssh:/root/.ssh:delegated
Expand All @@ -18,6 +18,10 @@ services:
working_dir: /code

build:
<<: *common
command: /bin/bash -cl "mvn clean package -DquicheCheckoutDir=$HOME/source/quiche"

build-clean:
<<: *common
command: /bin/bash -cl "./mvnw clean package"

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
<executions>
<!-- unpack netty-jni-util files -->
<execution>
Expand Down Expand Up @@ -273,11 +274,11 @@
<target>
<!-- Copy all of the c code -->
<delete dir="${generatedSourcesDir}" quiet="true" />
<copy todir="${generatedSourcesDir}/c" verbose="true">
<copy todir="${generatedSourcesDir}/c">
<fileset dir="${project.basedir}/src/main/c" />
</copy>

<copy todir="${generatedSourcesDir}/c" verbose="true">
<copy todir="${generatedSourcesDir}/c">
<fileset dir="${jniUtilIncludeDir}" />
</copy>
</target>
Expand Down Expand Up @@ -489,7 +490,6 @@
This hack will make the hawtjni plugin to put the native library
under 'META-INF/native' rather than 'META-INF/native/${platform}'. -->
<platform>.</platform>
<verbose>true</verbose>
<configureArgs>
<configureArg>${extraConfigureArg}</configureArg>
<configureArg>CFLAGS=${cflags}</configureArg>
Expand Down

0 comments on commit a3b15ac

Please sign in to comment.