|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
set -u
|
|
|
|
|
|
|
|
|
|
declare -g EXPECTED_DOC_BASE_PATH='/usr/share/nginx/html/octocat/hello-world'
|
|
|
|
|
declare -g VERBOSE='false'
|
|
|
|
@ -18,12 +18,10 @@ run_image() {
|
|
|
|
|
# named 'nginx'. The codefirst-nginx container acts as a SSH server and will
|
|
|
|
|
# be started and stopped automatically. The SSH user, port and authorized
|
|
|
|
|
# keys are already configured.
|
|
|
|
|
local branch=$1
|
|
|
|
|
local image=$2
|
|
|
|
|
local source=$3
|
|
|
|
|
local target=$4
|
|
|
|
|
local branch="$1"
|
|
|
|
|
local image="$2"
|
|
|
|
|
local pubkey=$(<"$root_dir/id_rsa.pub")
|
|
|
|
|
shift 4
|
|
|
|
|
shift 2
|
|
|
|
|
docker network inspect codefirst &> /dev/null || docker network create codefirst
|
|
|
|
|
nginx_id=$(docker run --rm -d -v codefirst-nginx:/usr/share/nginx --net=codefirst -e PUBLIC_KEY="$pubkey" -e USER_NAME=codefirst -e PUID=0 --hostname=nginx codefirst-nginx)
|
|
|
|
|
sleep 2 # Wait to let the container start
|
|
|
|
@ -31,17 +29,18 @@ run_image() {
|
|
|
|
|
--net=codefirst \
|
|
|
|
|
--entrypoint '/bin/sh' \
|
|
|
|
|
--workdir /drone/src \
|
|
|
|
|
--rm $image \
|
|
|
|
|
--rm "$image" \
|
|
|
|
|
-c "$*"
|
|
|
|
|
docker run -v codefirst-docdeployer-drone:/drone/src \
|
|
|
|
|
--net=codefirst \
|
|
|
|
|
-e DRONE_REPO_NAME=hello-world \
|
|
|
|
|
-e DRONE_REPO_OWNER=octocat \
|
|
|
|
|
-e DRONE_REPO=octocat/hello-world \
|
|
|
|
|
-e DRONE_BRANCH=$branch \
|
|
|
|
|
-e "DRONE_BRANCH=$branch" \
|
|
|
|
|
-e DRONE_COMMIT=7fd1a60b01f91b314f59955a4e4d4e80d8edf11d \
|
|
|
|
|
-e PLUGIN_SOURCE=$source \
|
|
|
|
|
-e PLUGIN_TARGET=$target \
|
|
|
|
|
-e "PLUGIN_SOURCE=${plugin[source]}" \
|
|
|
|
|
-e "PLUGIN_TARGET=${plugin[target]}" \
|
|
|
|
|
-e "PLUGIN_TRANSFORM=${plugin[transform]:-none}" \
|
|
|
|
|
--entrypoint '/bin/sh' \
|
|
|
|
|
--workdir /drone/src \
|
|
|
|
|
--rm codefirst-docdeployer \
|
|
|
|
@ -93,9 +92,39 @@ docker build -t codefirst-docdeployer --secret id=ssh_private_key,src="$root_dir
|
|
|
|
|
docker build -t codefirst-nginx "$root_dir/test/nginx"
|
|
|
|
|
|
|
|
|
|
test_deploy() {
|
|
|
|
|
run_image master corentinaltepe/doxygen html code-doc 'doxygen -s -g && doxygen'
|
|
|
|
|
declare -A plugin=(
|
|
|
|
|
[source]='html'
|
|
|
|
|
[target]='code-doc'
|
|
|
|
|
)
|
|
|
|
|
run_image master corentinaltepe/doxygen 'doxygen -s -g && doxygen'
|
|
|
|
|
assert_file_exists 'code-doc/index.html'
|
|
|
|
|
cleanup
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test_swagger() {
|
|
|
|
|
declare -A plugin=(
|
|
|
|
|
[source]='target/swagger.json'
|
|
|
|
|
[target]='api-def'
|
|
|
|
|
[transform]='swagger'
|
|
|
|
|
)
|
|
|
|
|
run_image main busybox 'mkdir target && echo "{}" > target/swagger.json'
|
|
|
|
|
assert_file_exists api-def/index.html
|
|
|
|
|
assert_file_exists api-def/swagger.json
|
|
|
|
|
assert_file_contains api-def/index.html 'swagger.json'
|
|
|
|
|
cleanup
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test_javadoc() {
|
|
|
|
|
declare -A plugin=(
|
|
|
|
|
[source]='./docdeployer/target/site/apidocs'
|
|
|
|
|
[target]='javadoc'
|
|
|
|
|
)
|
|
|
|
|
run_image main maven:3-eclipse-temurin-17-alpine 'mvn archetype:generate -q -DgroupId=fr.uca.iut.codefirst -DartifactId=docdeployer -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false && cd docdeployer && mvn javadoc:javadoc -q'
|
|
|
|
|
assert_file_exists javadoc/index.html
|
|
|
|
|
assert_file_exists javadoc/fr/uca/iut/codefirst/App.html
|
|
|
|
|
cleanup
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test_deploy
|
|
|
|
|
test_swagger
|
|
|
|
|
test_javadoc
|
|
|
|
|