From 1d3b69d3f5ee609c8d9dc2d56a1b8eb39edc5dfe Mon Sep 17 00:00:00 2001 From: michele Date: Mon, 16 Sep 2019 13:43:21 +0200 Subject: [PATCH] github actions setup --- .github/workflows/maven.yml | 54 ++++++++++++++++++++++++++++++++++ README.md | 3 +- docker/start_db_cluster.sh | 58 +++++++++++++++++++++++++++++++++++++ docker/start_db_single.sh | 21 ++++++++++++++ 4 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/maven.yml create mode 100755 docker/start_db_cluster.sh create mode 100755 docker/start_db_single.sh diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 000000000..ea8edd692 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,54 @@ +name: Java CI + +on: + pull_request: + branches: + - master + - 2.3.x + push: + branches: + - master + - 2.3.x + +jobs: + package: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Package + run: mvn --no-transfer-progress -DskipTests=true package + + test: + + runs-on: ubuntu-latest + + strategy: + matrix: + docker-img: + - docker.io/arangodb:3.3.23 + - docker.io/arangodb:3.4.8 + - docker.io/arangodb:3.5.0 + - docker.io/arangodb/enterprise:3.4.8 + - docker.io/arangodb/enterprise:3.5.0 + topology: + - single + - cluster + + steps: + - uses: actions/checkout@v1 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Start Database + run: ./docker/start_db_${{ matrix.topology }}.sh ${{ matrix.docker-img }} + env: + ARANGO_LICENSE_KEY: ${{ secrets.ARANGO_LICENSE_KEY }} + - name: Test + run: mvn --no-transfer-progress test diff --git a/README.md b/README.md index 59e102bd3..5e0d53fec 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ # Spring Data ArangoDB [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.arangodb/arangodb-spring-data/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.arangodb/arangodb-spring-data) +[![Actions Status](https://github.com/arangodb/spring-data/workflows/Java%20CI/badge.svg)](https://github.com/arangodb/spring-data/actions) - [Getting Started](docs/Drivers/SpringData/GettingStarted/README.md) - [Reference](docs/Drivers/SpringData/Reference/README.md) @@ -13,4 +14,4 @@ - [ArangoDB](https://www.arangodb.com/) - [Demo](https://github.com/arangodb/spring-data-demo) - [Changelog](ChangeLog.md) -- [JavaDoc](http://arangodb.github.io/spring-data/javadoc-3_1) +- [JavaDoc](http://arangodb.github.io/spring-data/javadoc-3_2) diff --git a/docker/start_db_cluster.sh b/docker/start_db_cluster.sh new file mode 100755 index 000000000..27089565e --- /dev/null +++ b/docker/start_db_cluster.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# USAGE: +# export ARANGO_LICENSE_KEY= +# ./start_db_cluster.sh + +# EXAMPLE: +# ./start_db_cluster.sh docker.io/arangodb:3.5.0 + +docker pull "$1" + +LOCATION=$(pwd)/$(dirname "$0") + +docker network create arangodb --subnet 172.28.0.0/16 + +echo "Averysecretword" > "$LOCATION"/jwtSecret +docker run --rm -v "$LOCATION"/jwtSecret:/jwtSecret "$1" arangodb auth header --auth.jwt-secret /jwtSecret > "$LOCATION"/jwtHeader +AUTHORIZATION_HEADER=$(cat "$LOCATION"/jwtHeader) + +docker run -d --rm -v "$LOCATION"/jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY="$ARANGO_LICENSE_KEY" --network arangodb --ip 172.28.1.1 --name agent1 "$1" arangodb --cluster.start-dbserver false --cluster.start-coordinator false --auth.jwt-secret /jwtSecret +docker run -d --rm -v "$LOCATION"/jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY="$ARANGO_LICENSE_KEY" --network arangodb --ip 172.28.1.2 --name agent2 "$1" arangodb --cluster.start-dbserver false --cluster.start-coordinator false --starter.join agent1 --auth.jwt-secret /jwtSecret +docker run -d --rm -v "$LOCATION"/jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY="$ARANGO_LICENSE_KEY" --network arangodb --ip 172.28.1.3 --name agent3 "$1" arangodb --cluster.start-dbserver false --cluster.start-coordinator false --starter.join agent1 --auth.jwt-secret /jwtSecret + +docker run -d --rm -v "$LOCATION"/jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY="$ARANGO_LICENSE_KEY" --network arangodb --ip 172.28.2.1 --name dbserver1 "$1" arangodb --cluster.start-dbserver true --cluster.start-coordinator false --starter.join agent1 --auth.jwt-secret /jwtSecret +docker run -d --rm -v "$LOCATION"/jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY="$ARANGO_LICENSE_KEY" --network arangodb --ip 172.28.2.2 --name dbserver2 "$1" arangodb --cluster.start-dbserver true --cluster.start-coordinator false --starter.join agent1 --auth.jwt-secret /jwtSecret +docker run -d --rm -v "$LOCATION"/jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY="$ARANGO_LICENSE_KEY" --network arangodb --ip 172.28.2.3 --name dbserver3 "$1" arangodb --cluster.start-dbserver true --cluster.start-coordinator false --starter.join agent1 --auth.jwt-secret /jwtSecret + +docker run -d --rm -v "$LOCATION"/jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY="$ARANGO_LICENSE_KEY" --network arangodb --ip 172.28.3.1 --name coordinator1 -p 8529:8529 "$1" arangodb --cluster.start-dbserver false --cluster.start-coordinator true --starter.join agent1 --auth.jwt-secret /jwtSecret +docker run -d --rm -v "$LOCATION"/jwtSecret:/jwtSecret -e ARANGO_LICENSE_KEY="$ARANGO_LICENSE_KEY" --network arangodb --ip 172.28.3.2 --name coordinator2 "$1" arangodb --cluster.start-dbserver false --cluster.start-coordinator true --starter.join agent1 --auth.jwt-secret /jwtSecret + +wait_server() { + # shellcheck disable=SC2091 + until $(curl --output /dev/null --silent --head --fail -i -H "$AUTHORIZATION_HEADER" "http://$1/_api/version"); do + printf '.' + sleep 1 + done +} + +# Wait for agents: +for a in 172.28.1.1:8531 \ + 172.28.1.2:8531 \ + 172.28.1.3:8531 \ + 172.28.2.1:8530 \ + 172.28.2.2:8530 \ + 172.28.2.3:8530 \ + 172.28.3.1:8529 \ + 172.28.3.2:8529 ; do + wait_server $a +done + +# wait for port mappings +wait_server 127.0.0.1:8529 + +docker exec coordinator1 arangosh --server.authentication=false --javascript.execute-string='require("org/arangodb/users").update("root", "test")' + +rm "$LOCATION"/jwtHeader "$LOCATION"/jwtSecret + +echo "Done, your cluster is ready." diff --git a/docker/start_db_single.sh b/docker/start_db_single.sh new file mode 100755 index 000000000..652f26d8f --- /dev/null +++ b/docker/start_db_single.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# USAGE: +# export ARANGO_LICENSE_KEY= +# ./start_db_single.sh + +# EXAMPLE: +# ./start_db_single.sh docker.io/arangodb:3.5.0 + +docker pull "$1" + +docker run -d -e ARANGO_ROOT_PASSWORD=test -e ARANGO_LICENSE_KEY="$ARANGO_LICENSE_KEY" -p 8529:8529 "$1" + +echo "waiting for arangodb ..." + +# shellcheck disable=SC2091 +until $(curl --output /dev/null --silent --head --fail -i -u root:test 'http://localhost:8529/_api/version'); do + printf '.' + sleep 1 +done +echo "READY!"