当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
エラーが大量に出てきていて果たして全て消せるかはまた別の話ですが…
以上です。
コメント