Improve phpDocs auto-generation
This commit is contained in:
parent
32120e5bbc
commit
9a46033141
@ -25,9 +25,10 @@ script:
|
|||||||
after_success:
|
after_success:
|
||||||
- |
|
- |
|
||||||
[[ ",$DEPLOY_PHPDOC_BRANCHES," == *,"$TRAVIS_BRANCH",* ]] && [ "$TRAVIS_PHP_VERSION" == "5.3" ] && (
|
[[ ",$DEPLOY_PHPDOC_BRANCHES," == *,"$TRAVIS_BRANCH",* ]] && [ "$TRAVIS_PHP_VERSION" == "5.3" ] && (
|
||||||
[ "$TRAVIS_PULL_REQUEST" == "false" ] && [ -z "$TRAVIS_TAG" ] && (
|
[ "$TRAVIS_SECURE_ENV_VARS" == "true" ] && [ -z "$TRAVIS_TAG" ] && (
|
||||||
./build/generate-phpdoc.sh . "$TRAVIS_BUILD_DIR/build/phpdoc-master" "Pico 1.0 API Documentation (master@$TRAVIS_COMMIT)"
|
./build/generate-phpdoc.sh . "$TRAVIS_BUILD_DIR/build/phpdoc-master" "Pico 1.0 API Documentation (master@$TRAVIS_COMMIT)"
|
||||||
./build/deploy-phpdoc.sh "$TRAVIS_BUILD_DIR/build/phpdoc-master" "$TRAVIS_REPO_SLUG" "gh-pages" "master@$TRAVIS_COMMIT"
|
printf '\n'
|
||||||
|
./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-master" "master@$TRAVIS_COMMIT" "phpDoc/master" "gh-pages"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,7 +36,8 @@ before_deploy:
|
|||||||
- |
|
- |
|
||||||
[ "$DEPLOY_PHPDOC_TAGS" == "true" ] && (
|
[ "$DEPLOY_PHPDOC_TAGS" == "true" ] && (
|
||||||
./build/generate-phpdoc.sh . "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "Pico 1.0 API Documentation ($TRAVIS_TAG)"
|
./build/generate-phpdoc.sh . "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "Pico 1.0 API Documentation ($TRAVIS_TAG)"
|
||||||
./build/deploy-phpdoc.sh "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "$TRAVIS_REPO_SLUG" "gh-pages" "$TRAVIS_TAG"
|
printf '\n'
|
||||||
|
./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "$TRAVIS_TAG" "phpDoc/$TRAVIS_TAG" "gh-pages"
|
||||||
)
|
)
|
||||||
- composer install --no-dev --optimize-autoloader
|
- composer install --no-dev --optimize-autoloader
|
||||||
- tar -czf "pico-release-$TRAVIS_TAG.tar.gz" README.md LICENSE CONTRIBUTING.md CHANGELOG.md composer.json composer.lock config content-sample lib plugins themes vendor .htaccess index.php
|
- tar -czf "pico-release-$TRAVIS_TAG.tar.gz" README.md LICENSE CONTRIBUTING.md CHANGELOG.md composer.json composer.lock config content-sample lib plugins themes vendor .htaccess index.php
|
||||||
|
@ -7,38 +7,39 @@ set -e
|
|||||||
# GITHUB_OAUTH_TOKEN GitHub authentication token, see https://github.com/settings/tokens
|
# GITHUB_OAUTH_TOKEN GitHub authentication token, see https://github.com/settings/tokens
|
||||||
|
|
||||||
# parameters
|
# parameters
|
||||||
SOURCE_DIR="$1" # absolute local source path
|
GITHUB_SLUG="$1" # GitHub repo (e.g. picocms/Pico)
|
||||||
TARGET_REPO_SLUG="$2" # target repo (e.g. picocms/Pico)
|
SOURCE_DIR="$2" # absolute source path
|
||||||
TARGET_BRANCH="$3" # target branch (e.g. gh-pages)
|
SOURCE_REF="$3" # source reference (either [branch]@[commit], [branch] or [tag])
|
||||||
TARGET_REF="$4" # target reference (either [branch]@[commit], [branch] or [tag])
|
TARGET_DIR="$4" # relative target path
|
||||||
|
TARGET_BRANCH="$5" # target branch (e.g. gh-pages)
|
||||||
|
|
||||||
|
printf 'Deploying phpDocs (%s (%s) --> %s:%s/%s)...\n' "$SOURCE_DIR" "$SOURCE_REF" "$GITHUB_SLUG" "$TARGET_BRANCH" "$TARGET_DIR"
|
||||||
|
|
||||||
# evaluate target reference
|
# evaluate target reference
|
||||||
if git check-ref-format "tags/$TARGET_REF"; then
|
if git check-ref-format "tags/$SOURCE_REF"; then
|
||||||
TARGET_REF_TYPE="tag"
|
SOURCE_REF_TYPE="tag"
|
||||||
TARGET_REF_TAG="$TARGET_REF"
|
SOURCE_REF_TAG="$SOURCE_REF"
|
||||||
TARGET_DIR="$TARGET_REF_TAG"
|
elif [[ "$SOURCE_REF" == *@* ]]; then
|
||||||
elif [[ "$TARGET_REF" == *@* ]]; then
|
SOURCE_REF_TYPE="commit"
|
||||||
TARGET_REF_TYPE="commit"
|
SOURCE_REF_BRANCH="${SOURCE_REF%@*}"
|
||||||
TARGET_REF_BRANCH="${TARGET_REF%@*}"
|
SOURCE_REF_COMMIT="${SOURCE_REF##*@}"
|
||||||
TARGET_REF_COMMIT="${TARGET_REF##*@}"
|
|
||||||
TARGET_DIR="$TARGET_REF_BRANCH"
|
|
||||||
|
|
||||||
if ! git check-ref-format "heads/$TARGET_REF_BRANCH"; then
|
if ! git check-ref-format "heads/$SOURCE_REF_BRANCH"; then
|
||||||
echo "FATAL: $APP_NAME target reference '$TARGET_REF' is invalid" >&2
|
echo "FATAL: $APP_NAME target reference '$SOURCE_REF' is invalid" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
elif git check-ref-format "heads/$TARGET_REF"; then
|
elif git check-ref-format "heads/$SOURCE_REF"; then
|
||||||
TARGET_REF_TYPE="branch"
|
SOURCE_REF_TYPE="branch"
|
||||||
TARGET_REF_BRANCH="$TARGET_REF"
|
SOURCE_REF_BRANCH="$SOURCE_REF"
|
||||||
TARGET_DIR="$TARGET_REF_BRANCH"
|
|
||||||
else
|
else
|
||||||
echo "FATAL: $APP_NAME target reference '$TARGET_REF' is invalid" >&2
|
echo "FATAL: $APP_NAME target reference '$SOURCE_REF' is invalid" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# clone repo
|
# clone repo
|
||||||
|
printf '\nCloning %s branch of %s...\n' "$TARGET_BRANCH" "https://github.com/$GITHUB_SLUG.git"
|
||||||
GIT_DIR="$SOURCE_DIR.git"
|
GIT_DIR="$SOURCE_DIR.git"
|
||||||
git clone -b "$TARGET_BRANCH" "https://github.com/$TARGET_REPO_SLUG.git" "$GIT_DIR"
|
git clone -b "$TARGET_BRANCH" "https://github.com/$GITHUB_SLUG.git" "$GIT_DIR"
|
||||||
|
|
||||||
# setup git
|
# setup git
|
||||||
cd "$GIT_DIR"
|
cd "$GIT_DIR"
|
||||||
@ -47,23 +48,26 @@ git config user.email "travis-ci@picocms.org"
|
|||||||
[ -n "$GITHUB_OAUTH_TOKEN" ] && git config credential.https://github.com.username "$GITHUB_OAUTH_TOKEN"
|
[ -n "$GITHUB_OAUTH_TOKEN" ] && git config credential.https://github.com.username "$GITHUB_OAUTH_TOKEN"
|
||||||
|
|
||||||
# copy phpdoc
|
# copy phpdoc
|
||||||
[ -e "$TARGET_DIR" ] && echo "FATAL: $(basename "$0") target directory '$TARGET_DIR' exists" >&2 && exit 1
|
[ ! -d "$TARGET_DIR" ] || rm -rf "$TARGET_DIR"
|
||||||
[ "${SOURCE_DIR:0:1}" == "/" ] || SOURCE_DIR="$BASE_PWD/$SOURCE_DIR"
|
[ "${SOURCE_DIR:0:1}" == "/" ] || SOURCE_DIR="$BASE_PWD/$SOURCE_DIR"
|
||||||
cp -R "$SOURCE_DIR" "phpDoc/$TARGET_DIR"
|
printf '\nCopying phpDoc (%s --> %s)...\n' "$SOURCE_DIR" "$GIT_DIR/$TARGET_DIR"
|
||||||
|
cp -R "$SOURCE_DIR" "$TARGET_DIR"
|
||||||
|
|
||||||
# commit changes
|
# commit changes
|
||||||
|
printf '\nCommiting changes...\n'
|
||||||
git add "$TARGET_DIR"
|
git add "$TARGET_DIR"
|
||||||
git commit -m "Add phpDocumentor class docs for $TARGET_REF"
|
git commit -m "Add phpDocumentor class docs for $SOURCE_REF"
|
||||||
|
|
||||||
# very simple race condition protection for concurrent Travis builds
|
# very simple race condition protection for concurrent Travis builds
|
||||||
# this is no definite protection (race conditions are still possible during `git push`),
|
# this is no definite protection (race conditions are still possible during `git push`),
|
||||||
# but it should give a basic protection without disabling concurrent builds completely
|
# but it should give a basic protection without disabling concurrent builds completely
|
||||||
if [ "$TARGET_REF_TYPE" == "commit" ]; then
|
if [ "$SOURCE_REF_TYPE" == "commit" ]; then
|
||||||
# get latest commit
|
# get latest commit
|
||||||
LATEST_COMMIT="$(wget -O- "https://api.github.com/repos/$TARGET_REPO_SLUG/git/refs/heads/$TARGET_REF_BRANCH" 2> /dev/null | php -r "
|
printf '\nRetrieving latest commit of %s:%s' "$GITHUB_SLUG" "$SOURCE_REF_BRANCH"
|
||||||
|
LATEST_COMMIT="$(wget -O- "https://api.github.com/repos/$GITHUB_SLUG/git/refs/heads/$SOURCE_REF_BRANCH" 2> /dev/null | php -r "
|
||||||
\$json = json_decode(stream_get_contents(STDIN), true);
|
\$json = json_decode(stream_get_contents(STDIN), true);
|
||||||
if (\$json !== null) {
|
if (\$json !== null) {
|
||||||
if (isset(\$json['ref']) && (\$json['ref'] === 'refs/heads/$TARGET_REF_BRANCH')) {
|
if (isset(\$json['ref']) && (\$json['ref'] === 'refs/heads/$SOURCE_REF_BRANCH')) {
|
||||||
if (isset(\$json['object']) && isset(\$json['object']['sha'])) {
|
if (isset(\$json['object']) && isset(\$json['object']['sha'])) {
|
||||||
echo \$json['object']['sha'];
|
echo \$json['object']['sha'];
|
||||||
}
|
}
|
||||||
@ -72,11 +76,12 @@ if [ "$TARGET_REF_TYPE" == "commit" ]; then
|
|||||||
")"
|
")"
|
||||||
|
|
||||||
# compare target reference against the latest commit
|
# compare target reference against the latest commit
|
||||||
if [ "$LATEST_COMMIT" != "$TARGET_REF_COMMIT" ]; then
|
if [ "$LATEST_COMMIT" != "$SOURCE_REF_COMMIT" ]; then
|
||||||
echo "WARNING: $APP_NAME target reference '$TARGET_REF' doesn't match the latest commit '$LATEST_COMMIT'" >&2
|
echo "WARNING: $APP_NAME target reference '$SOURCE_REF' doesn't match the latest commit '$LATEST_COMMIT'" >&2
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# push changes
|
# push changes
|
||||||
git push "https://github.com/$TARGET_REPO_SLUG.git" "$TARGET_BRANCH:$TARGET_BRANCH"
|
printf '\nPushing changes...\n'
|
||||||
|
git push "https://github.com/$GITHUB_SLUG.git" "$TARGET_BRANCH:$TARGET_BRANCH"
|
||||||
|
@ -7,6 +7,7 @@ PHPDOC_TARGET_DIR="$2"
|
|||||||
PHPDOC_TITLE="$3"
|
PHPDOC_TITLE="$3"
|
||||||
|
|
||||||
# generate phpdoc
|
# generate phpdoc
|
||||||
|
printf 'Generating phpDocs (%s --> %s; "%s")...\n' "$PHPDOC_SOURCE_DIR" "$PHPDOC_TARGET_DIR" "$PHPDOC_TITLE"
|
||||||
phpdoc -d "$PHPDOC_SOURCE_DIR" \
|
phpdoc -d "$PHPDOC_SOURCE_DIR" \
|
||||||
-i 'build/*' -i 'vendor/*' -i 'plugins/*' \
|
-i 'build/*' -i 'vendor/*' -i 'plugins/*' \
|
||||||
-f 'plugins/DummyPlugin.php' \
|
-f 'plugins/DummyPlugin.php' \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user