mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[TEST] Scripts to run the tests with docker
This commit is contained in:
parent
3a4dae369d
commit
e82bbbba14
10 changed files with 131 additions and 0 deletions
9
docker/bamboo-env-mapping.sh
Normal file
9
docker/bamboo-env-mapping.sh
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
export IMAGES_TAG=${bamboo_images_tag}
|
||||
|
||||
export WORKING_DIR=${bamboo_working_directory}
|
||||
export PR_NUMBER=${bamboo_PRnumber}
|
||||
export COMPOSER_HOME=${bamboo_composer_home}
|
||||
export GITHUB_TOKEN=${bamboo_github_token_password}
|
||||
export BUILD_RESULT_URL=${bamboo_buildResultsUrl}
|
14
docker/scripts/cleanup.sh
Executable file
14
docker/scripts/cleanup.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# We assume the docker daemon is dedicated to the current job (the jobs runs on isolated docker daemon)
|
||||
# Stop running containers
|
||||
for container in $(docker ps -q)
|
||||
do
|
||||
docker stop $container || true
|
||||
done
|
||||
|
||||
# Removing containers
|
||||
for container in $(docker ps -a -q)
|
||||
do
|
||||
docker rm -v $container || true
|
||||
done
|
7
docker/scripts/fetch-pr.sh
Executable file
7
docker/scripts/fetch-pr.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
docker run \
|
||||
--user $(id -u):$(id -g) \
|
||||
--volume ${WORKING_DIR}:/data \
|
||||
--workdir /data \
|
||||
phpbb/build${IMAGES_TAG} sh -c 'git remote set-url origin "https://github.com/phpbb/phpbb.git" && git fetch origin +refs/pull/'${PR_NUMBER}'/merge && git checkout FETCH_HEAD'
|
17
docker/scripts/generate-archive.sh
Executable file
17
docker/scripts/generate-archive.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bas
|
||||
|
||||
cat <<EOL > generate-archive.sh
|
||||
git remote set-url origin "https://github.com/phpbb/phpbb.git"
|
||||
git fetch origin +refs/pull/${PR_NUMBER}/head
|
||||
last_commit=\$(git rev-parse FETCH_HEAD)
|
||||
echo "\$last_commit" > build/logs/last_commit
|
||||
tar --exclude-backups --exclude-vcs --exclude='.git' --exclude='generate-archive.sh' -p -c -z -f source_code.tar.gz *
|
||||
EOL
|
||||
|
||||
docker run \
|
||||
--user $(id -u):$(id -g) \
|
||||
--volume ${WORKING_DIR}:/data \
|
||||
--workdir /data \
|
||||
phpbb/build{IMAGES_TAG} sh generate-archive.sh
|
||||
|
||||
rm generate-archive.sh
|
16
docker/scripts/get-test-result.sh
Executable file
16
docker/scripts/get-test-result.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ -s build/logs/phpunit.xml ]; then
|
||||
res=$(cat build/logs/sniffs_res 2>/dev/null)
|
||||
if ( grep 'failures="[^0]"' build/logs/phpunit.xml ); then
|
||||
res=1
|
||||
elif ( grep 'errors="[^0]"' build/logs/phpunit.xml ); then
|
||||
res=2
|
||||
else
|
||||
res=0
|
||||
fi
|
||||
else
|
||||
res=2
|
||||
fi
|
||||
|
||||
echo ${res}
|
7
docker/scripts/jobs/sniffer.sh
Executable file
7
docker/scripts/jobs/sniffer.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
docker run \
|
||||
--user $(id -u):$(id -g) \
|
||||
--volume ${WORKING_DIR}:/data \
|
||||
--workdir /data \
|
||||
php:5.6 sh -c 'cd build && ../phpBB/vendor/bin/phing sniff && echo 0 > logs/sniffs_res || echo 1 > logs/sniffs_res'
|
7
docker/scripts/prepare-code.sh
Executable file
7
docker/scripts/prepare-code.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
docker run \
|
||||
--user $(id -u):$(id -g) \
|
||||
--volume ${WORKING_DIR}:/data \
|
||||
--workdir /data \
|
||||
debian tar -p -x -z -f source_code.tar.gz
|
22
docker/scripts/prepare-sources.sh
Executable file
22
docker/scripts/prepare-sources.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Ensure the github oauth token is set
|
||||
docker run \
|
||||
--user $(id -u):$(id -g) \
|
||||
--volume ${WORKING_DIR}:/data \
|
||||
--volume ${COMPOSER_HOME}:/composer/ \
|
||||
--workdir /data \
|
||||
phpbb/build{IMAGES_TAG} sh -c "COMPOSER_HOME=/composer php composer.phar config -g github-oauth.github.com ${GITHUB_TOKEN}"
|
||||
|
||||
docker run \
|
||||
--user $(id -u):$(id -g) \
|
||||
--volume ${WORKING_DIR}:/data \
|
||||
--volume ${COMPOSER_HOME}:/composer/ \
|
||||
--workdir /data \
|
||||
phpbb/build{IMAGES_TAG} sh -c 'cd phpBB; COMPOSER_HOME=/composer php ../composer.phar install --dev'
|
||||
|
||||
docker run \
|
||||
--user $(id -u):$(id -g) \
|
||||
--volume ${WORKING_DIR}:/data \
|
||||
--workdir /data \
|
||||
phpbb/build{IMAGES_TAG} sh -c 'cd build; ../phpBB/vendor/bin/phing clean prepare'
|
23
docker/scripts/set-result-status.sh
Executable file
23
docker/scripts/set-result-status.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
last_commit=$(cat build/logs/last_commit)
|
||||
|
||||
result_file=$1
|
||||
step=$2
|
||||
|
||||
if [ -s build/logs/${result_file} ]; then
|
||||
res=$(cat build/logs/${result_file} 2>/dev/null)
|
||||
else
|
||||
res=2
|
||||
fi
|
||||
|
||||
if [ $res -eq 0 ]; then
|
||||
echo Send success
|
||||
./set-status.sh 'success' 'The Bamboo build is a success' ${step}
|
||||
elif [ $res -eq 1 ]; then
|
||||
echo Send Failure
|
||||
./set-status.sh 'failure' 'The Bamboo build failed' ${step}
|
||||
else
|
||||
echo Send error
|
||||
./set-status.sh 'error' 'The Bamboo build is in error' ${step}
|
||||
fi
|
9
docker/scripts/set-status.sh
Executable file
9
docker/scripts/set-status.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
last_commit=$(cat build/logs/last_commit)
|
||||
|
||||
status=$1
|
||||
description=$2
|
||||
step=$3
|
||||
|
||||
curl -H "Authorization: token ${GITHUB_TOKEN}" --request POST --data '{"state": "'${status}'", "description": "'${description}'", "target_url": "'${BUILD_RESULT_URL}'", "context": "phpBB continuous integration - '${step}'"}' https://api.github.com/repos/phpbb/phpbb/statuses/${last_commit} > /dev/null
|
Loading…
Add table
Reference in a new issue