Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/github-actions-demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: GitHub Actions Demo
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: run sitespeedio test
uses: docker://sitespeedio/sitespeed.io:latest
with:
args: http://7756-46-242-27-51.ngrok.io -n 1 --budget.configPath homeBudget.json
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end
gem "actionpack-action_caching", "~> 1.2"
gem "active_record_union", "~> 1.3"
gem "acts-as-taggable-on", "~> 5.0"
gem "acts_as_follower", github: "thepracticaldev/acts_as_follower", branch: "master"
gem "acts_as_follower"
gem "addressable", "~> 2.5", ">= 2.5.2"
gem "administrate", "~> 0.11"
gem "ahoy_email", "~> 0.5"
Expand Down Expand Up @@ -122,7 +122,7 @@ group :development, :test do
gem "derailed", "~> 0.1"
gem "erb_lint", "~> 0.0", require: false
gem "faker", git: "https://github.com/stympy/faker.git", branch: "master"
gem "fix-db-schema-conflicts", github: "thepracticaldev/fix-db-schema-conflicts", branch: "master"
gem "fix-db-schema-conflicts"
gem "memory_profiler", "~> 0.9"
gem "parallel_tests", "~> 2.27"
gem "pry-byebug", "~> 3.7"
Expand Down
33 changes: 10 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
GIT
remote: https://github.com/stympy/faker.git
revision: 9910aa58d92c018abab25d491191576fcc1a7707
revision: f7221ec2e01b50362e94cb9fb61b6a2eced85328
branch: master
specs:
faker (1.9.1)
i18n (>= 0.7)

GIT
remote: https://github.com/thepracticaldev/acts_as_follower.git
revision: 288690cd99bc470eaee493fce5bfa9fe23157692
branch: master
specs:
acts_as_follower (0.2.1)
activerecord (>= 4.0)

GIT
remote: https://github.com/thepracticaldev/fix-db-schema-conflicts.git
revision: 4172392392e1a8d907f7ab673cb5ddd9a4a31940
branch: master
specs:
fix-db-schema-conflicts (3.0.2)
rubocop (>= 0.38.0)
faker (2.19.0)
i18n (>= 1.8.11, < 2)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -74,6 +58,7 @@ GEM
tzinfo (~> 1.1)
acts-as-taggable-on (5.0.0)
activerecord (>= 4.2.8)
acts_as_follower (0.2.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
administrate (0.11.0)
Expand Down Expand Up @@ -212,7 +197,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.5)
concurrent-ruby (1.1.9)
connection_pool (2.2.2)
counter_culture (2.1.2)
activerecord (>= 3.0.0)
Expand Down Expand Up @@ -322,6 +307,8 @@ GEM
thor (~> 0.14)
fission (0.5.0)
CFPropertyList (~> 2.2)
fix-db-schema-conflicts (3.0.3)
rubocop (>= 0.38.0)
fog (1.41.0)
fog-aliyun (>= 0.1.0)
fog-atmos
Expand Down Expand Up @@ -536,7 +523,7 @@ GEM
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
httpclient (2.8.3)
i18n (1.6.0)
i18n (1.8.11)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
inflecto (0.0.2)
Expand Down Expand Up @@ -948,7 +935,7 @@ DEPENDENCIES
actionpack-action_caching (~> 1.2)
active_record_union (~> 1.3)
acts-as-taggable-on (~> 5.0)
acts_as_follower!
acts_as_follower
addressable (~> 2.5, >= 2.5.2)
administrate (~> 0.11)
ahoy_email (~> 0.5)
Expand Down Expand Up @@ -992,7 +979,7 @@ DEPENDENCIES
fastly-rails (~> 0.8)
feedjira (~> 2.2)
figaro (~> 1.1)
fix-db-schema-conflicts!
fix-db-schema-conflicts
fog (~> 1.41)
front_matter_parser (~> 0.2)
gemoji (~> 3.0.0)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ docker run --privileged --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io

Теперь проверка бюджета на главной странице должна пройти успешно!


## Настройка CI

Теперь настроим `CI`: `Travis` или `Github Actions`.

Шаги:

- выставить текущую версию приложения в интернет с помощью `ngrok`
- запушить урл `ngrok` в конфиг `CI` в `github` и тем самым триггернуть билд
- билд должен проверять ваше приложение по урлу `ngrok` с помощью `sitespeed.io` на соблюдение бюджета
Expand All @@ -67,7 +67,6 @@ docker run --privileged --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io
- скриншоты `bundle-analyzer` до и после оптимизации
- настроенный `CI` на `Travis` или `Github Actions`


<div align="center">
<br>
<img
Expand Down
186 changes: 93 additions & 93 deletions app/javascript/packs/proCharts.js
Original file line number Diff line number Diff line change
@@ -1,93 +1,93 @@
import Chart from 'chart.js';

const reactionsCanvas = document.getElementById('reactionsChart');
const commentsCanvas = document.getElementById('commentsChart');

export const reactionsChart = new Chart(reactionsCanvas, {
type: 'line',
data: {
labels: JSON.parse(reactionsCanvas.dataset.labels),
datasets: [
{
label: 'Reaction Total',
data: JSON.parse(reactionsCanvas.dataset.totalCount),
// data: [5, 10, 15, 17, 25, 23],
fill: false,
borderColor: 'rgb(75, 192, 192)',
lineTension: 0.1,
},
{
label: 'Total Likes',
data: JSON.parse(reactionsCanvas.dataset.totalLikes),
// data: [2, 5, 10, 10, 15, 13],
fill: false,
borderColor: 'rgb(229, 100, 100)',
lineTension: 0.1,
},
{
label: 'Total Unicorns',
data: JSON.parse(reactionsCanvas.dataset.totalUnicorns),
// data: [1, 2, 2, 4, 5, 3],
fill: false,
borderColor: 'rgb(157, 57, 233)',
lineTension: 0.1,
},
{
label: 'Total Bookmarks',
data: JSON.parse(reactionsCanvas.dataset.totalReadinglist),
// data: [2, 3, 3, 3, 5, 7],
fill: false,
borderColor: 'rgb(10, 133, 255)',
lineTension: 0.1,
},
],
},
options: {
title: {
display: true,
text: 'Reactions over the Last Week',
},
scales: {
yAxes: [
{
ticks: {
suggestedMin: 0,
precision: 0,
},
},
],
},
},
});

export const commentsChart = new Chart(commentsCanvas, {
type: 'line',
data: {
labels: JSON.parse(commentsCanvas.dataset.labels),
datasets: [
{
label: 'Total Comments',
data: JSON.parse(commentsCanvas.dataset.totalCount),
fill: false,
borderColor: 'rgb(75, 192, 192)',
lineTension: 0.1,
},
],
},
options: {
title: {
display: true,
text: 'Comments over the Last Week',
},
scales: {
yAxes: [
{
ticks: {
suggestedMin: 0,
precision: 0,
},
},
],
},
},
});
// import Chart from 'chart.js';
//
// const reactionsCanvas = document.getElementById('reactionsChart');
// const commentsCanvas = document.getElementById('commentsChart');
//
// export const reactionsChart = new Chart(reactionsCanvas, {
// type: 'line',
// data: {
// labels: JSON.parse(reactionsCanvas.dataset.labels),
// datasets: [
// {
// label: 'Reaction Total',
// data: JSON.parse(reactionsCanvas.dataset.totalCount),
// // data: [5, 10, 15, 17, 25, 23],
// fill: false,
// borderColor: 'rgb(75, 192, 192)',
// lineTension: 0.1,
// },
// {
// label: 'Total Likes',
// data: JSON.parse(reactionsCanvas.dataset.totalLikes),
// // data: [2, 5, 10, 10, 15, 13],
// fill: false,
// borderColor: 'rgb(229, 100, 100)',
// lineTension: 0.1,
// },
// {
// label: 'Total Unicorns',
// data: JSON.parse(reactionsCanvas.dataset.totalUnicorns),
// // data: [1, 2, 2, 4, 5, 3],
// fill: false,
// borderColor: 'rgb(157, 57, 233)',
// lineTension: 0.1,
// },
// {
// label: 'Total Bookmarks',
// data: JSON.parse(reactionsCanvas.dataset.totalReadinglist),
// // data: [2, 3, 3, 3, 5, 7],
// fill: false,
// borderColor: 'rgb(10, 133, 255)',
// lineTension: 0.1,
// },
// ],
// },
// options: {
// title: {
// display: true,
// text: 'Reactions over the Last Week',
// },
// scales: {
// yAxes: [
// {
// ticks: {
// suggestedMin: 0,
// precision: 0,
// },
// },
// ],
// },
// },
// });
//
// export const commentsChart = new Chart(commentsCanvas, {
// type: 'line',
// data: {
// labels: JSON.parse(commentsCanvas.dataset.labels),
// datasets: [
// {
// label: 'Total Comments',
// data: JSON.parse(commentsCanvas.dataset.totalCount),
// fill: false,
// borderColor: 'rgb(75, 192, 192)',
// lineTension: 0.1,
// },
// ],
// },
// options: {
// title: {
// display: true,
// text: 'Comments over the Last Week',
// },
// scales: {
// yAxes: [
// {
// ticks: {
// suggestedMin: 0,
// precision: 0,
// },
// },
// ],
// },
// },
// });
38 changes: 38 additions & 0 deletions case-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Case Study

## Шаг 1. Бюджет

Задал бюджет на объём js на главной странице.

Прогнал sitespeed
`npm i -g sitespeed.io && sitespeed.io http://localhost:3000 --budget.configPath homeBudget.json`

Бюджет не соблюдается:
`INFO: Failing budget JavaScript Transfer Size for http://localhost:3000 with value 3.6 MB max limit 449.2 KB`

## Шаг 2. Оптимизация

Добавил плагин webpack-bundle-analyzer

Выполните анализ исходной версии приложения с помощью webpack-bundle-analyzer
![img.png](img.png)

moment.js входит в сборку vendor

Закомментировал всё содержимое файла proCharts.js
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В идеале конечно было бы ещё разобраться зачем он был нужен и как его включить только там где надо

Бандл похудел
![img_1.png](img_1.png)

Но бюджет всё ещё не соблюдается

`Failing budget JavaScript Transfer Size for http://localhost:3000 with value 521.4 KB max limit 449.2 KB`

Скорее всего со времен создания репозитория с заданием имеющиеся либы распухли сами по себе, увеличил бюджет до 540000
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, всё так, вот так и происходит ползучая деградация, если не защититься


## Шаг 3. Настройка CI

Настроил ngrok на прослушивание 3000 порта и запустил приложение
Настроил Github Actions на запуск проверки sitespeed на публичном урле запущенного приложения

Проверка пройдена успешно
`INFO: Budget: 1 working, 0 failing tests and 0 errors`
Loading