7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ใ‚ซใƒใƒฌใƒƒใ‚ธใƒฌใƒใƒผใƒˆใ‚’ GitLab Pages ใซใƒ›ใ‚นใƒ†ใ‚ฃใƒณใ‚ฐใ—ใŸ

7
Posted at

ใฏใ˜ใ‚ใซ

ใ‚„ใ‚ŠใŸใ‹ใฃใŸใ“ใจ

ใ‚ณใƒผใƒ‰ใ‚ซใƒใƒฌใƒƒใ‚ธใƒฌใƒใƒผใƒˆใ‚’็ฐกๅ˜ใซ่ฆ‹ใ‚Œใ‚‹ใ‚ˆใ†ใซใ—ใŸใ„ใ€‚

ใ‚ซใƒใƒฌใƒƒใ‚ธใฎใƒใƒƒใ‚ธใ‹ใ‚‰
ใ‚นใ‚ฏใƒชใƒผใƒณใ‚ทใƒงใƒƒใƒˆ 2018-07-28 0.20.44.png

ใ“ใ‚“ใชใƒฌใƒใƒผใƒˆใƒšใƒผใ‚ธใธ

ใ‚นใ‚ฏใƒชใƒผใƒณใ‚ทใƒงใƒƒใƒˆ 2018-07-28 0.23.42.png

ใ‚„ใฃใŸใ“ใจ

  • SimpleCov ใ‚’ไฝฟใฃใฆ Rspec ใฎใ‚ซใƒใƒฌใƒƒใ‚ธใ‚’่จˆๆธฌ & ใƒฌใƒใƒผใƒˆใ‚’ไฝœๆˆ
  • GitLab CI ใ‚’ไฝฟใฃใฆไธŠ่จ˜ใฎใ‚ซใƒใƒฌใƒƒใ‚ธใƒฌใƒใƒผใƒˆใ‚’ GitLab Pages ใซใ€ใƒ›ใ‚นใƒ†ใ‚ฃใƒณใ‚ฐ
    • ใƒใƒƒใ‚ธใ‹ใ‚‰ใฎใƒชใƒณใ‚ฏใ‚’ๅผตใ‚‹

SimpleCov ใ‚’ๅฐŽๅ…ฅใ™ใ‚‹

ใพใšใฏใ‚ซใƒใƒฌใƒƒใ‚ธใƒฌใƒใƒผใƒˆใ‚’็”Ÿๆˆใ™ใ‚‹ใŸใ‚ใซ SimpleCov ใ‚’ๅฐŽๅ…ฅใ™ใ‚‹ใ€‚

  1. SimpleCov ใ‚’ Gemfile ใซ่ฟฝ่จ˜

    Gemfile
    gem 'simplecov', require: false, group: :test
    
  2. spec_helper.rb ใง SimpleCov ใ‚’ใƒญใƒผใƒ‰๏ผ†่ตทๅ‹•

    spec_helper.br
    require 'simplecov'
    SimpleCov.start 'rails'
    
    # Previous content of test helper now starts here
    

ใ“ใ‚Œใงใƒ†ใ‚นใƒˆใ‚’ๅฎŸ่กŒใ™ใ‚‹ใจใ‚ซใƒใƒฌใƒƒใ‚ธใƒฌใƒใƒผใƒˆ (coverage/index.html) ใŒ็”Ÿๆˆใ•ใ‚Œใ‚‹ใ‚ˆใ†ใซใชใ‚‹ใ€‚

GitLab CI ใ‚’ๆง‹ๆˆใ™ใ‚‹

็”Ÿๆˆใ—ใŸใ‚ซใƒใƒฌใƒƒใ‚ธใƒฌใƒใƒผใƒˆใ‚’ GitLab Pages ใซใƒ›ใ‚นใƒ†ใ‚ฃใƒณใ‚ฐใ™ใ‚‹ใŸใ‚ใฎใƒ‘ใ‚คใƒ—ใƒฉใ‚คใƒณใ‚’ไฝœใ‚‹ใ€‚
ๅ…ทไฝ“็š„ใซใฏไปฅไธ‹ใฎใ‚ˆใ†ใช .gitlab-ci.yml ใซใชใ‚‹ใ€‚

.gitlab-ci.yml
...

rspec:
  stage: test
  script:
    - bundle install
    - rspec
  artifacts:
    paths:
      - coverage/

pages:
  stage: deploy
  dependencies:
    - rspec
  script:
    - mv coverage/ public/
  artifacts:
    paths:
      - public
    expire_in: 30 days
  only:
    - master

...
  • rspec ใ‚ธใƒงใƒ–
    • artifacts: ็”Ÿๆˆใ—ใŸใƒฌใƒใƒผใƒˆใ‚’ใ‚นใƒˆใ‚ข
  • pages ใ‚ธใƒงใƒ–
    • dependencies: rspec ใ‚ธใƒงใƒ–ใง็”Ÿๆˆใ—ใŸ artifacts ใ‚’ใƒ€ใ‚ฆใƒณใƒญใƒผใƒ‰
    • GitLab Pages ใฏ public ใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒชๅ†…ใ‚’ๆŽขใ—ใซ่กŒใใฎใงใ€ใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒชๅใฏๅฟ…ใš public ใซ
    • only: master ใƒ–ใƒฉใƒณใƒใฎๆ›ดๆ–ฐๆ™‚ใฎใฟใƒฌใƒใƒผใƒˆใ‚’ใƒ‡ใƒ—ใƒญใ‚คใ™ใ‚‹

ใ‚ซใƒใƒฌใƒƒใ‚ธใƒฌใƒใƒผใƒˆใƒใƒƒใ‚ธใซใƒชใƒณใ‚ฏใ‚’่ฒผใ‚‹

ใ“ใ“ใพใงใงใ€ master ใƒ–ใƒฉใƒณใƒใธใฎใƒžใƒผใ‚ธใฎใŸใณใซ GitLab Pages ใซใ‚ซใƒใƒฌใƒƒใ‚ธใƒฌใƒใƒผใƒˆใŒใƒ‡ใƒ—ใƒญใ‚คใ•ใ‚Œใ‚‹็Šถๆ…‹ใ€‚
ใ‚ใจใฏใ™ใ่ฆ‹ใซ่กŒใ‘ใ‚‹ใ‚ˆใ†ใซใ€ README.md ใฎใ‚ซใƒใƒฌใƒƒใ‚ธใƒใƒƒใ‚ธใ‹ใ‚‰ใฎใƒชใƒณใ‚ฏใ‚’ๅผตใ‚‹ใ€‚

README.md
[![coverage report](https://gitlab.com/APP_NAME/GROUP_NAME/badges/master/coverage.svg?job=rspec)](https://APP_NAME.gitlab.io/GROUP_NAME/)

...
  • Settings > CI /CD > General piplines ใ‹ใ‚‰ใƒใƒƒใ‚ธใฎ Markdown ใ‚’ๅ–ๅพ—
    • ใƒ‡ใƒ•ใ‚ฉใƒซใƒˆใงใฏใƒชใƒณใ‚ฏๅ…ˆใŒ commits ใซใชใฃใฆใ„ใ‚‹ใฎใงใ€ใ“ใ‚Œใ‚’ GitLab Pages ใฎใƒšใƒผใ‚ธใซๅค‰ๆ›ดใ™ใ‚‹
  • job=rspec: ใƒ†ใ‚นใƒˆใ‚’ๅฎŸ่กŒใ™ใ‚‹ใ‚ธใƒงใƒ–ๅใ‚’ rspec ไปฅๅค–ใซใ—ใฆใ„ใŸใ‚‰็ฝฎใๆ›ใˆใ‚‹
    • ไธŠใฎไพ‹ใจๅŒใ˜ใ‚ˆใ†ใซ .gitlab-ci.yml ใ‚’ไฝœๆˆใ—ใฆใ„ใ‚‹ใชใ‚‰ใ“ใฎใพใพใงใ‚ˆใ„

ๅ‚่€ƒ

7
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?