diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..1540ed7 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,48 @@ +variables: + GIT_SUBMODULE_STRATEGY: recursive + +lint: + image: + name: docker/compose:1.24.1 + entrypoint: + - /bin/sh + - "-c" + services: + - docker:dind + variables: + DOCKER_HOST: "tcp://docker:2375/" + DOCKER_DRIVER: overlay2 + script: + - docker-compose run xo-js-lint + - docker-compose run xo-html-lint + - docker-compose run sass-lint +build: + image: + name: klakegg/hugo:0.55.6-ext-alpine + entrypoint: + - /bin/sh + - "-c" + script: + - hugo --minify + artifacts: + paths: + - public + expire_in: 3 months + only: + - master + +test: + image: + name: klakegg/hugo:0.55.6-ext-alpine + entrypoint: + - /bin/sh + - "-c" + script: + - hugo_output=$(hugo --path-warnings --i18n-warnings) + - echo "$hugo_output" + - if echo "$hugo_output" | grep -q 'i18n|MISSING_TRANSLATION'; then false; else true; fi + - if echo "$hugo_output" | grep -q 'WARN.*Duplicate target paths'; then false; else true; fi + artifacts: + paths: + - public + expire_in: 1 month diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..51fbddf --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +lint: + docker-compose run xo-js-lint + docker-compose run xo-html-lint + docker-compose run sass-lint + +build: + docker-compose run xo-js-lint + docker-compose run xo-html-lint + docker-compose run sass-lint + hugo + +serve: + hugo server & diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f58ccdc --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: '2' + +services: + xo-js-lint: + build: linting/js + image: patek-devs/xo + command: . --env=browser --extend=/eslintrc.yml + volumes: + - ./themes/patek/assets/js:/src:ro + - ./linting/js/eslintrc.yml:/eslintrc.yml:ro + xo-html-lint: + image: patek-devs/xo + command: \*.html --plugin=html --extension=html + volumes: + - ./:/src:ro + sass-lint: + build: linting/sass + image: patek-devs/sass-lint + command: ./**/*.scss --config /sass-lint.yml + volumes: + - ./themes/patek/assets/css:/src:ro + - ./linting/sass/sass-lint.yml:/sass-lint.yml:ro + diff --git a/linting/js/Dockerfile b/linting/js/Dockerfile new file mode 100644 index 0000000..7ee0de1 --- /dev/null +++ b/linting/js/Dockerfile @@ -0,0 +1,22 @@ +FROM node:12-alpine + +RUN mkdir /src + +# Hack to upgrade NPM: +# - install local version +# - replace old global verson with new one + +RUN npm install npm@5.3 && \ + rm -rf /usr/local/lib/node_modules/npm && \ + mv /node_modules/npm /usr/local/lib/node_modules + +RUN npm install -g xo@0.24.0 + +RUN npm install -g eslint-plugin-html@6.0.0 + +# Cleanup +RUN rm -fr /root/.npm /node_modules + +WORKDIR /src + +ENTRYPOINT ["/usr/local/bin/xo"] diff --git a/linting/js/eslintrc.yml b/linting/js/eslintrc.yml new file mode 100644 index 0000000..4f337a4 --- /dev/null +++ b/linting/js/eslintrc.yml @@ -0,0 +1,6 @@ +rules: + quotes: + - error + - double + unicorn/prefer-query-selector: off + no-negated-condition: off diff --git a/linting/sass/Dockerfile b/linting/sass/Dockerfile new file mode 100644 index 0000000..4703d9f --- /dev/null +++ b/linting/sass/Dockerfile @@ -0,0 +1,17 @@ +FROM node:12-alpine + +RUN mkdir /src + +RUN npm install npm@5.3 && \ + rm -rf /usr/local/lib/node_modules/npm && \ + mv /node_modules/npm /usr/local/lib/node_modules + +RUN npm install -g sass-lint + +# Cleanup +RUN rm -fr /root/.npm /node_modules + +WORKDIR /src + +ENTRYPOINT ["/usr/local/bin/sass-lint"] + diff --git a/linting/sass/sass-lint.yml b/linting/sass/sass-lint.yml new file mode 100644 index 0000000..5c05377 --- /dev/null +++ b/linting/sass/sass-lint.yml @@ -0,0 +1,3 @@ +files: + ignore: + - 'bulma/**/*.*'