Skip to content

Instantly share code, notes, and snippets.

@yokkidack
Last active April 16, 2018 09:32
Show Gist options
  • Save yokkidack/9ba62a44275cbea7434614b4d709050a to your computer and use it in GitHub Desktop.
Save yokkidack/9ba62a44275cbea7434614b4d709050a to your computer and use it in GitHub Desktop.
lab05

Laboratory work V

Данная лабораторная работа посвещена изучению систем непрерывной интеграции на примере сервиса Travis CI

$ open https://travis-ci.org

Tasks

  • 1. Авторизоваться на сервисе Travis CI с использованием GitHub аккаунта
  • 2. Создать публичный репозиторий с названием lab05 на сервисе GitHub
  • 3. Ознакомиться со ссылками учебного материала
  • 4. Включить интеграцию сервиса Travis CI с созданным репозиторием
  • 5. Получить токен для Travis CLI с правами repo и user
  • 6. Получить фрагмент вставки значка сервиса Travis CI в формате Markdown
  • 7. Установить Travis CLI
  • 8. Выполнить инструкцию учебного материала
  • 9. Составить отчет и отправить ссылку личным сообщением в Slack

Tutorial

$ export GITHUB_USERNAME=<имя_пользователя> //создать константу
$ export GITHUB_TOKEN=<полученный_токен> создать константу
$ cd ${GITHUB_USERNAME}/workspace //переходим в директорию
$ pushd .   //Сохраняет имя текущего каталога для команды popd и переходит в другой каталог.
~/yokkidack/workspace ~/yokkidack/workspace
$ source scripts/activate //source выполнит содержание файла
$ \curl -sSL https://get.rvm.io | bash -s -- --ignore-dotfiles
//curl - инструмент для взаимодействия с серерами с синтаксисом URL // -ssl указывает на то чтобы использовался протокол ssl
Turning on ignore dotfiles mode.
Downloading https://github.com/rvm/rvm/archive/master.tar.gz
Upgrading the RVM installation in /home/yokkidack/.rvm/
Upgrade of RVM in /home/yokkidack/.rvm/ is complete.
* No new notes to display.

$ echo "source $HOME/.rvm/scripts/rvm" >> scripts/activate
$ rvm autolibs disable //rvm - иструммент для управления версиями руби
//autolibs - "фича" в rvm преднозначеная для автоматической устаноки зависимостей
$ rvm install ruby-2.4.2 //rvm - иструммент для управления версиями руби
// устанавливанием руби
Searching for binary rubies, this might take some time.
No binary rubies available for: ubuntu/17.10/x86_64/ruby-2.4.2.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Installing Ruby from source to: /home/yokkidack/.rvm/rubies/ruby-2.4.2, this may take a while depending on your cpu(s)...
ruby-2.4.2 - #downloading ruby-2.4.2, this may take a while depending on your connection...
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100 12.0M  100 12.0M    0     0  4103k      0  0:00:03  0:00:03 --:--:-- 3131k
ruby-2.4.2 - #extracting ruby-2.4.2 to /home/yokkidack/.rvm/src/ruby-2.4.2.....
ruby-2.4.2 - #configuring..................................................................
ruby-2.4.2 - #post-configuration..
ruby-2.4.2 - #compiling....................................................................................................................
ruby-2.4.2 - #installing............
ruby-2.4.2 - #making binaries executable..
ruby-2.4.2 - #downloading rubygems-2.7.6
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100  832k  100  832k    0     0   416k      0  0:00:02  0:00:02 --:--:--  372k
ruby-2.4.2 - #extracting rubygems-2.7.6.....
ruby-2.4.2 - #removing old rubygems........
ruby-2.4.2 - #installing rubygems-2.7.6..........................
ruby-2.4.2 - #gemset created /home/yokkidack/.rvm/gems/ruby-2.4.2@global
ruby-2.4.2 - #importing gemset /home/yokkidack/.rvm/gemsets/global.gems.............................................
ruby-2.4.2 - #generating global wrappers.......
ruby-2.4.2 - #gemset created /home/yokkidack/.rvm/gems/ruby-2.4.2
ruby-2.4.2 - #importing gemsetfile /home/yokkidack/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.4.2 - #generating default wrappers.......
ruby-2.4.2 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.4.2 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri

$ rvm use 2.4.2 --default //rvm - иструммент для управления версиями руби
//устанавливаем версию для использования по использования

Using /home/yokkidack/.rvm/gems/ruby-2.4.2

$ gem install travis //gem - менеджер пакедов для руби
Fetching: multipart-post-2.0.0.gem (100%)
Successfully installed multipart-post-2.0.0
Fetching: faraday-0.14.0.gem (100%)
Successfully installed faraday-0.14.0
Fetching: faraday_middleware-0.12.2.gem (100%)
Successfully installed faraday_middleware-0.12.2
Fetching: highline-1.7.10.gem (100%)
Successfully installed highline-1.7.10
Fetching: backports-3.11.2.gem (100%)
Successfully installed backports-3.11.2
Fetching: multi_json-1.13.1.gem (100%)
Successfully installed multi_json-1.13.1
Fetching: addressable-2.4.0.gem (100%)
Successfully installed addressable-2.4.0
Fetching: net-http-persistent-2.9.4.gem (100%)
Successfully installed net-http-persistent-2.9.4
Fetching: net-http-pipeline-1.0.1.gem (100%)
Successfully installed net-http-pipeline-1.0.1
Fetching: gh-0.15.1.gem (100%)
Successfully installed gh-0.15.1
Fetching: launchy-2.4.3.gem (100%)
Successfully installed launchy-2.4.3
Fetching: ffi-1.9.23.gem (100%)
Building native extensions. This could take a while...
Successfully installed ffi-1.9.23
Fetching: ethon-0.11.0.gem (100%)
Successfully installed ethon-0.11.0
Fetching: typhoeus-0.8.0.gem (100%)
Successfully installed typhoeus-0.8.0
Fetching: websocket-1.2.5.gem (100%)
Successfully installed websocket-1.2.5
Fetching: pusher-client-0.6.2.gem (100%)
Successfully installed pusher-client-0.6.2
Fetching: travis-1.8.8.gem (100%)
Successfully installed travis-1.8.8
invalid options: -SHN
(invalid options are ignored)
Parsing documentation for multipart-post-2.0.0
Installing ri documentation for multipart-post-2.0.0
Parsing documentation for faraday-0.14.0
Installing ri documentation for faraday-0.14.0
Parsing documentation for faraday_middleware-0.12.2
Installing ri documentation for faraday_middleware-0.12.2
Parsing documentation for highline-1.7.10
Installing ri documentation for highline-1.7.10
Parsing documentation for backports-3.11.2
Installing ri documentation for backports-3.11.2
Parsing documentation for multi_json-1.13.1
Installing ri documentation for multi_json-1.13.1
Parsing documentation for addressable-2.4.0
Installing ri documentation for addressable-2.4.0
Parsing documentation for net-http-persistent-2.9.4
Installing ri documentation for net-http-persistent-2.9.4
Parsing documentation for net-http-pipeline-1.0.1
Installing ri documentation for net-http-pipeline-1.0.1
Parsing documentation for gh-0.15.1
Installing ri documentation for gh-0.15.1
Parsing documentation for launchy-2.4.3
Installing ri documentation for launchy-2.4.3
Parsing documentation for ffi-1.9.23
Installing ri documentation for ffi-1.9.23
Parsing documentation for ethon-0.11.0
Installing ri documentation for ethon-0.11.0
Parsing documentation for typhoeus-0.8.0
Installing ri documentation for typhoeus-0.8.0
Parsing documentation for websocket-1.2.5
Installing ri documentation for websocket-1.2.5
Parsing documentation for pusher-client-0.6.2
Installing ri documentation for pusher-client-0.6.2
Parsing documentation for travis-1.8.8
Installing ri documentation for travis-1.8.8
Done installing documentation for multipart-post, faraday, faraday_middleware, highline, backports, multi_json, addressable, net-http-persistent, net-http-pipeline, gh, launchy, ffi, ethon, typhoeus, websocket, pusher-client, travis after 17 seconds
17 gems installed
$ git clone https://github.com/${GITHUB_USERNAME}/lab04 projects/lab05 //автоматически настраивает вашу локальную ветку master на отслеживание удалённой ветки master на сервере, с которого вы клонировали
Cloning into 'projects/lab05'...
remote: Counting objects: 28, done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 28 (delta 5), reused 26 (delta 4), pack-reused 0
Unpacking objects: 100% (28/28), done.

$ cd projects/lab05  //переходим в директорию
$ git remote remove origin //remote - управление отслеживаемым репозиторием
$ git remote add origin https://github.com/${GITHUB_USERNAME}/lab05
$ cat > .travis.yml <<EOF// cat выведет содержимое файла
// ">" означает перенаправление вывода их строки в файл
// "<<" указывает на то что считывание будет происходить до появления слова "EOF"

language: cpp
EOF
$ cat >> .travis.yml <<EOF// cat выведет содержимое файла
// ">" означает перенаправление вывода их строки в файл
// "<<" указывает на то что считывание будет происходить до появления слова "EOF"


script:
- cmake -H. -B_build -DCMAKE_INSTALL_PREFIX=_install
- cmake --build _build
- cmake --build _build --target install
EOF
$ cat >> .travis.yml <<EOF // cat выведет содержимое файла
// ">" означает перенаправление вывода их строки в файл
// "<<" указывает на то что считывание будет происходить до появления слова "EOF"


addons:
  apt:
    sources:
      - george-edison55-precise-backports
    packages:
      - cmake
      - cmake-data
EOF
$ travis login --github-token ${GITHUB_TOKEN} //логин в травис с помощью полученного ранее токена
$ travis lint //проверяет файл на предмет возможных ошибок
Warnings for .travis.yml:
[x] value for addons section is empty, dropping
[x] in addons section: unexpected key apt, dropping
$ ex -sc '1i|<фрагмент_вставки_значка>' -cx README.md //ex -редактор 
// -sc чтобы считать из командной строки последовательность ‘…’
// -cx записать в <…>
$ git add .travis.yml // добавить файл и начать отслеживать
$ git add README.md // добавить файл и начать отслеживать
$ git commit -m"added CI" //сделать коммит, -m чтобы добавить сообщение
[master 0eeafd7] added CI
2 files changed, 15 insertions(+)
create mode 100644 .travis.yml
$ git push origin master //отправить на удаленный сервер
Username for 'https://github.com': yokkidack
Password for 'https://yokkidack@github.com':
To https://github.com/yokkidack/lab05
! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/yokkidack/lab05'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$ travis lint //проверяет файл на предмет возможных ошибок
Warnings for .travis.yml:
[x] value for addons section is empty, dropping
[x] in addons section: unexpected key apt, dropping
$ travis accounts //выводит аккаунтыи информацию о их подписке
yokkidack (Yokkidack): subscribed, 11 repositories
$ travis sync //начинает синхрониацию с гит
synchronizing: ... done

$ travis repos // вывод репозиториев, на которые у пользователя есть права
yokkidack/BSTree (active: no, admin: yes, push: yes, pull: yes)
Description: ???

yokkidack/FList (active: no, admin: yes, push: yes, pull: yes)
Description: ???

yokkidack/lab03 (active: no, admin: yes, push: yes, pull: yes)
Description: ???

yokkidack/lab04 (active: no, admin: yes, push: yes, pull: yes)
Description: ???

yokkidack/lab05 (active: yes, admin: yes, push: yes, pull: yes)
Description: ???

yokkidack/lapki (active: no, admin: yes, push: yes, pull: yes)
Description: ???

yokkidack/off (active: no, admin: yes, push: yes, pull: yes)
Description: ???

yokkidack/timp (active: no, admin: yes, push: yes, pull: yes)
Description: ???

yokkidack/vector_example (active: yes, admin: yes, push: yes, pull: yes)
Description: ???

yokkidack/vershinin (active: no, admin: yes, push: yes, pull: yes)
Description: ???

$ travis enable //подключаем травис к проекту из репозитория
Detected repository as yokkidack/lab05, is this correct? |yes| y
yokkidack/lab05: enabled :)
$ travis whatsup //выводит список последних сборок
yokkidack/lab05 passed: #1
yokkidack/vector_example passed: #2
$ travis branches //выводит список последних сборок в каждой из веток
master:  #1    passed     added CI
$ travis history // выводит историю историю сборок проекта
#1 passed:       master added CI
$ travis show //ваводит сборку или работу
Job #1.1:  added CI
State:         passed
Type:          push
Branch:        master
Compare URL:   https://github.com/yokkidack/lab05/compare/4e089c8954d1^...f34dbb5688da
Duration:      41 sec
Started:       2018-04-15 14:38:57
Finished:      2018-04-15 14:39:38
Allow Failure: false
Config:        os: linux

Report

$ popd
$ export LAB_NUMBER=05
$ git clone https://github.com/tp-labs/lab${LAB_NUMBER} tasks/lab${LAB_NUMBER}
$ mkdir reports/lab${LAB_NUMBER}
$ cp tasks/lab${LAB_NUMBER}/README.md reports/lab${LAB_NUMBER}/REPORT.md
$ cd reports/lab${LAB_NUMBER}
$ edit REPORT.md
$ gistup -m "lab${LAB_NUMBER}"

Links

Copyright (c) 2017 Братья Вершинины
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment