From 0afbcf2635164bc0deebb302e3ba211f0d4d7c20 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Wed, 2 Dec 2020 02:05:36 +0300 Subject: [PATCH] Use correct versions of Ruby and Node.js in CI Take example from [Flame CLI](https://github.com/AlexWayfer/flame-cli/pull/57). --- .cirrus.yaml | 92 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 78 insertions(+), 14 deletions(-) diff --git a/.cirrus.yaml b/.cirrus.yaml index 569c31f..0364dbf 100644 --- a/.cirrus.yaml +++ b/.cirrus.yaml @@ -1,3 +1,43 @@ +os_setup: &os_setup + container: + image: debian + os_setup_script: + - apt update && apt upgrade -y && apt install git make gcc -y + +rbenv_cache: &rbenv_cache + rbenv_cache: + folder: $HOME/.rbenv + populate_script: + - git clone https://github.com/rbenv/rbenv.git ~/.rbenv + + ## https://cirrus-ci.com/task/6270527041961984?command=os_setup#L543 + - echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc + ## https://cirrus-ci.com/task/5656294977699840?command=os_setup#L633 + - echo 'eval "$(rbenv init -)"' >> ~/.bashrc + + - source ~/.bashrc + + ## https://github.com/rbenv/ruby-build#installation + - mkdir -p "$(rbenv root)"/plugins + - git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build + +nodenv_cache: &nodenv_cache + nodenv_cache: + folder: $HOME/.nodenv + populate_script: + - git clone https://github.com/nodenv/nodenv.git ~/.nodenv + + ## https://cirrus-ci.com/task/6270527041961984?command=os_setup#L543 + - echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.bashrc + ## https://cirrus-ci.com/task/5656294977699840?command=os_setup#L633 + - echo 'eval "$(nodenv init -)"' >> ~/.bashrc + + - source ~/.bashrc + + ## https://github.com/nodenv/node-build#installation + - mkdir -p "$(nodenv root)"/plugins + - git clone https://github.com/nodenv/node-build.git "$(nodenv root)"/plugins/node-build + bundle_cache: &bundle_cache bundle_cache: folder: /usr/local/bundle @@ -18,12 +58,19 @@ node_modules_cache: &node_modules_cache - cat package.json install_script: npm install + remark_task: - container: - image: node + <<: *os_setup + + always: + <<: *nodenv_cache + <<: *node_modules_cache - lint_script: npm run lint:markdown + lint_script: + - cat ~/.bashrc + - source ~/.bashrc + - npm run lint:markdown only_if: ($CIRRUS_BRANCH == 'master') || changesInclude( @@ -31,11 +78,17 @@ remark_task: ) stylelint_task: - container: - image: node + <<: *os_setup + + always: + <<: *nodenv_cache + <<: *node_modules_cache - lint_script: npm run lint:styles + lint_script: + - cat ~/.bashrc + - source ~/.bashrc + - npm run lint:styles only_if: ($CIRRUS_BRANCH == 'master') || changesInclude( @@ -44,11 +97,17 @@ stylelint_task: ) eslint_task: - container: - image: node + <<: *os_setup + + always: + <<: *nodenv_cache + <<: *node_modules_cache - lint_script: npm run lint:scripts + lint_script: + - cat ~/.bashrc + - source ~/.bashrc + - npm run lint:scripts only_if: ($CIRRUS_BRANCH == 'master') || changesInclude( @@ -57,18 +116,23 @@ eslint_task: ) rubocop_task: - container: - image: ruby:latest - <<: *bundle_cache - - lint_script: bundle exec rubocop --format=json --out=rubocop.json + <<: *os_setup always: + <<: *rbenv_cache + rubocop_artifacts: path: rubocop.json type: text/json format: rubocop + <<: *bundle_cache + + lint_script: + - cat ~/.bashrc + - source ~/.bashrc + - bundle exec rubocop --format=json --out=rubocop.json + only_if: ($CIRRUS_BRANCH == 'master') || changesInclude( '.cirrus.yaml', '.gitignore', 'Gemfile', 'Gemfile.lock', '.rubocop.yml', '**.rb'