mirror of
https://github.com/tldr-pages/tldr.git
synced 2024-11-02 12:57:57 +01:00
Merge pull request #342 from igorshubovych/travis-integration
Travis CI integration: automatic linting, rebuilding index.json, building pages archive [fixed]
This commit is contained in:
commit
4cd3c29fdb
7 changed files with 99 additions and 5 deletions
|
@ -10,3 +10,7 @@ insert_final_newline = true
|
||||||
|
|
||||||
[*.md]
|
[*.md]
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 8
|
||||||
|
|
16
.travis.yml
Normal file
16
.travis.yml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
language: ruby
|
||||||
|
rvm:
|
||||||
|
- 2.2.2
|
||||||
|
|
||||||
|
gemfile:
|
||||||
|
- Gemfile
|
||||||
|
|
||||||
|
script:
|
||||||
|
- make check
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- bash scripts/build.sh
|
||||||
|
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
secure: PC9nFPE034jPsF0nUn7phCt0RgVouIvd0HsQkOonNSiElh+pkFyaVvDIsQR8lF4x1AxFjz9Yo3qnNGM3txvOMiNqfReDRINfnpvLDkumCeXuKYNO8XyacTHyxMWp0sZM/YhHhJ8qhroSbNOcYYduSW+fTAoyILieRNg+Wwx7b/rdybVKW7d45GDhjmxvx0/cVhLgghXZr7SRMRh89xrGRkT8vRY7xwlmMs83YRSEcs9pkBrdAfSG/16yOCAQVUS1z10zXk/SsRZlNGKzSWsvb1H/OlkHZpxpnawJhmn2iNIy25acqRdyLwv5Oy5P2sQDBjNenTmiv0JL9v7ks5uNtXaIimvSieLKn/vLmGmW/8ArifqwPpEcL/ZmoCH5SzNrvtO06TfuYPCWGrfLKBxySh4jnza8y8YruKlQfjWDm/o5MmiJWvM1mVtIRozO9hDYZ1EMf4e8qlT7K6Y3alWbl3PqZ/DnLHYIUEvtYv5M0H2Ydtqh5JIWj/XRaNSwwmL4Lpcz3AKavP93N4tYAoGIWO9hkVpwCYz3qNH9dIxQJ7ancj01FWVFqqbLcBLPk8MaQsuFSBZpIz9PTLFdtso/YnviqSu5I7GMsFQdvGY8Mth207dMCVs7DRYe9QCjpboQoiCPY8ckmVYvlYdrDMjnfkhQC/OfZLitVLBe6zyEwTs=
|
4
Gemfile
4
Gemfile
|
@ -1,3 +1,5 @@
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
gem 'mdl'
|
group :development, :test do
|
||||||
|
gem 'mdl'
|
||||||
|
end
|
||||||
|
|
|
@ -14,3 +14,6 @@ PLATFORMS
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
mdl
|
mdl
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
1.10.6
|
||||||
|
|
11
Makefile
11
Makefile
|
@ -1,3 +1,5 @@
|
||||||
|
default: check
|
||||||
|
|
||||||
all: setup index
|
all: setup index
|
||||||
|
|
||||||
index:
|
index:
|
||||||
|
@ -14,10 +16,13 @@ hooks:
|
||||||
deps:
|
deps:
|
||||||
@bundle
|
@bundle
|
||||||
@echo "OK"
|
@echo "OK"
|
||||||
|
|
||||||
|
check:
|
||||||
|
@bundle exec mdl --style ./scripts/markdown-style.rb pages
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
@GEM_PATH=.gem find pages -exec .gem/bin/mdl {} --style ./scripts/markdown-style.rb 1>&2 \;
|
@GEM_PATH=.gem find pages -exec mdl {} --style ./scripts/markdown-style.rb 1>&2 \;
|
||||||
|
|
||||||
lint-changed:
|
lint-changed:
|
||||||
@./scripts/lint-changed.sh
|
@./scripts/lint-changed.sh
|
||||||
|
|
||||||
|
|
63
scripts/build.sh
Normal file
63
scripts/build.sh
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -ev
|
||||||
|
|
||||||
|
function initialize {
|
||||||
|
if [ -z "$TLDRHOME" ]; then
|
||||||
|
export TLDRHOME=${TRAVIS_BUILD_DIR:-`pwd`}
|
||||||
|
fi
|
||||||
|
export TLDR_ARCHIVE="tldr.zip"
|
||||||
|
export SITE_HOME="$HOME/site"
|
||||||
|
export SITE_URL="github.com/tldr-pages/tldr-pages.github.io"
|
||||||
|
|
||||||
|
git config --global user.email "travis@travis-ci.org"
|
||||||
|
git config --global user.name "Travis CI"
|
||||||
|
git config --global push.default simple
|
||||||
|
git config --global diff.zip.textconv "unzip -c -a"
|
||||||
|
}
|
||||||
|
|
||||||
|
function rebuild_index {
|
||||||
|
$TLDRHOME/scripts/build_index.rb
|
||||||
|
echo "Rebuilding index is done"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_archive {
|
||||||
|
echo "Removing $TLDR_ARCHIVE if it exists"
|
||||||
|
rm -f $TLDR_ARCHIVE
|
||||||
|
|
||||||
|
echo "Creating an archive $TLDR_ARCHIVE"
|
||||||
|
cd $TLDRHOME/
|
||||||
|
zip -r $TLDR_ARCHIVE pages/ LICENSE.md
|
||||||
|
}
|
||||||
|
|
||||||
|
function upload_assets {
|
||||||
|
echo "Uploading assets to static site"
|
||||||
|
|
||||||
|
git clone --quiet --depth 1 https://${GH_TOKEN}@${SITE_URL} $SITE_HOME
|
||||||
|
mv -f $TLDR_ARCHIVE $SITE_HOME/assets/
|
||||||
|
cp -f $TLDRHOME/pages/index.json $SITE_HOME/assets/
|
||||||
|
|
||||||
|
cd $SITE_HOME
|
||||||
|
git add -A .
|
||||||
|
git commit -m "[TravisCI] uploaded assets after commits ${TRAVIS_COMMIT_RANGE}"
|
||||||
|
if [[ ! `git push -q` ]]; then
|
||||||
|
echo "Cannot push to a static site"
|
||||||
|
else
|
||||||
|
echo "Assets deployed"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
###################################
|
||||||
|
# MAIN
|
||||||
|
###################################
|
||||||
|
|
||||||
|
if [ ! "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||||
|
echo "This is a Pull Request, no index rebuild needed"
|
||||||
|
elif [ ! "$TRAVIS_BRANCH" == "master" ]; then
|
||||||
|
echo "This is not a master branch, no index rebuild needed"
|
||||||
|
else
|
||||||
|
initialize
|
||||||
|
rebuild_index
|
||||||
|
build_archive
|
||||||
|
upload_assets
|
||||||
|
fi
|
|
@ -1,4 +1,5 @@
|
||||||
# This file contains the markdown rules markdownlint will check for
|
# This file contains the markdown rules markdownlint will check for
|
||||||
all
|
all
|
||||||
|
|
||||||
exclude_rule 'MD013' # Lengthy lines (80+ chars)
|
exclude_rule 'MD013' # Lengthy lines (80+ chars)
|
||||||
|
exclude_rule 'MD034' # Allow bare URLs
|
||||||
|
|
Loading…
Reference in a new issue