当Blogの記事自体は、BitBucket
上で管理、
投稿自体は手動で、Mezzanine
に入力という方法を取っておりますが、
書きまつがいをチェックしたいため、
記事チェックイン後に、Wercker
でRedpen
を実行するようにしてみました。
以下、設定手順は以下の通りです。
-
Dockerfile
の作成 -
redpen-conf
の作成 -
wercker.yml
の作成 -
参考にした記事
Dockerfile
の作成
ここで結構な時間はまってしまいました。
Wercker
上でredpen
コマンドを実行するため、以下の条件を満たす。Box
を作成しました。
-
BLOG
が日本語のため、Locale
の設定がja_JP.UTF-8
になっている。
これは、redpenのチェック項目が言語設定で変わってくるためです。 -
java8
がインストールされている。 -
redpen
がインストールされている。
最終的に作成したDockerfile
が以下になります。
-
# Java 1.8 & RedPen Dockerfile # https://github.com/kemsakurai/docker-redpen-UTF-8 # Pull base image. FROM ubuntu:14.04 # maintainer details MAINTAINER Ken Sakurai "sakurai.kem@gmail.com" # Set locale RUN locale-gen ja_JP.UTF-8 ENV LANG ja_JP.UTF-8 ENV LANGUAGE ja_JP:ja ENV LC_ALL ja_JP.UTF-8 # Accecpt Oracle license before installing java RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections RUN echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections # Install java RUN apt-get update RUN apt-get -y install software-properties-common RUN add-apt-repository -y ppa:webupd8team/java RUN apt-get update RUN apt-get -y install oracle-java8-installer oracle-java8-set-default RUN echo "export JAVA_HOME=/usr/lib/jvm/java-8-oracle" >> /etc/environment # DownLoad Redpen WORKDIR /tmp RUN wget -q https://github.com/redpen-cc/redpen/releases/download/redpen-1.5.5/redpen-1.5.5.tar.gz -O - | tar xz && \ cp -av redpen-distribution-1.5.5/* /usr/local/ && \ rm -rf redpen-distribution-1.5.5 RUN export PATH=$PATH:/usr/local/bin WORKDIR /data CMD ["/usr/local/bin/redpen"]
-
参考にした
Dockerfile
というか、ほぼコピー&ペースト
redpen-conf
の作成
Lint
対象のプロジェクト直下に、redpen-conf-ja.xml
を作成、配置しました。
wercker.yml
の作成
以下の通り、wercker.yml
を作成しました。
redpen -c ./redpen-conf-ja.xml -f markdown ./**/*.md
で、redpenコマンドを実行しています。1個でもLint
で引っかかるとビルドがコケます。
wercker.yml
# This references a standard debian container from the # Docker Hub https://registry.hub.docker.com/_/debian/ # Read more about containers on our dev center # http://devcenter.wercker.com/docs/containers/index.html box: kemsakurai/redpen-utf-8 # You can also use services such as databases. Read more on our dev center: # http://devcenter.wercker.com/docs/services/index.html # services: # - postgres # http://devcenter.wercker.com/docs/services/postgresql.html # - mongodb # http://devcenter.wercker.com/docs/services/mongodb.html # This is the build pipeline. Pipelines are the core of wercker # Read more about pipelines on our dev center # http://devcenter.wercker.com/docs/pipelines/index.html build: # Steps make up the actions in your pipeline # Read more about steps on our dev center: # http://devcenter.wercker.com/docs/steps/index.html steps: - script: name: echo start code: | echo "#################################" echo "blog build start" echo "#################################" - script: name: check code: | redpen -c ./redpen-conf-ja.xml -f markdown ./**/*.md - script: name: echo end code: | echo "#################################" echo "blog build end" echo "#################################"
OUTPUT
は以下のように出力されます。
* Wecker
上のコンソールOUTPUT
エラーが大量に出てきていて果たして全て消せるかはまた別の話ですが…
以上です。
コメント