From 427ae9c88f80e1ed4146db7628f9f680a2139399 Mon Sep 17 00:00:00 2001 From: Daniel Khorkhordin Date: Sat, 12 Jun 2021 11:52:49 +0300 Subject: [PATCH 01/17] Add react workflow --- .github/workflows/react.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/react.yaml diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml new file mode 100644 index 0000000..0fa837c --- /dev/null +++ b/.github/workflows/react.yaml @@ -0,0 +1,17 @@ +name: '' +on: [push] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + version: 14 + - run: yarn + - run: yarn build + - uses: actions/upload-artifact + with: + name: build + path: build/ + if-no-files-found: error From e179f5b0cf2702203fa09632512628e154754c36 Mon Sep 17 00:00:00 2001 From: Daniel Khorkhordin Date: Sat, 12 Jun 2021 11:55:22 +0300 Subject: [PATCH 02/17] Fix upload artifact action name --- .github/workflows/react.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml index 0fa837c..f29458a 100644 --- a/.github/workflows/react.yaml +++ b/.github/workflows/react.yaml @@ -10,7 +10,7 @@ jobs: version: 14 - run: yarn - run: yarn build - - uses: actions/upload-artifact + - uses: actions/upload-artifact@v2 with: name: build path: build/ From 44c2dda39633a7489013d09ea913018e0e74dcc2 Mon Sep 17 00:00:00 2001 From: Daniel Khorkhordin Date: Sat, 12 Jun 2021 12:15:39 +0300 Subject: [PATCH 03/17] Add cache for dependencies in yarn.lock --- .github/workflows/react.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml index f29458a..bb8eb52 100644 --- a/.github/workflows/react.yaml +++ b/.github/workflows/react.yaml @@ -8,6 +8,16 @@ jobs: - uses: actions/setup-node@v2 with: version: 14 + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v2 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- - run: yarn - run: yarn build - uses: actions/upload-artifact@v2 From 67608ae70f745775e424b05f84694c3c087b04e2 Mon Sep 17 00:00:00 2001 From: Daniel Khorkhordin Date: Sat, 12 Jun 2021 12:31:12 +0300 Subject: [PATCH 04/17] Add test job --- .github/workflows/react.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml index bb8eb52..eade8cc 100644 --- a/.github/workflows/react.yaml +++ b/.github/workflows/react.yaml @@ -20,6 +20,14 @@ jobs: ${{ runner.os }}-yarn- - run: yarn - run: yarn build + - run: yarn test --coverage + env: + CI: true + - uses: actions/upload-artifact@v2 + with: + name: coverage + path: coverage/ + if-no-files-found: error - uses: actions/upload-artifact@v2 with: name: build From d04d9bf8b2a11a94e6405de7387107d37bea69a5 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 19 Jun 2021 10:45:31 +0300 Subject: [PATCH 05/17] Add eslint command --- .github/workflows/react.yaml | 1 + package.json | 31 ++++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml index eade8cc..2d832e8 100644 --- a/.github/workflows/react.yaml +++ b/.github/workflows/react.yaml @@ -19,6 +19,7 @@ jobs: restore-keys: | ${{ runner.os }}-yarn- - run: yarn + - run: yarn lint - run: yarn build - run: yarn test --coverage env: diff --git a/package.json b/package.json index 4c15a13..bcc024d 100644 --- a/package.json +++ b/package.json @@ -11,17 +11,42 @@ "react-scripts": "4.0.3", "web-vitals": "^1.0.1" }, + "devDependencies": { + "eslint-config-airbnb": "^18.2.1", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-jsx-a11y": "^6.4.1", + "eslint-plugin-prettier": "^3.4.0", + "eslint-plugin-react-hooks": "^4.2.0", + "prettier": "^2.3.1" + }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "lint": "eslint ./src" }, "eslintConfig": { "extends": [ "react-app", - "react-app/jest" - ] + "react-app/jest", + "plugin:jsx-a11y/recommended", + "plugin:react-hooks/recommended", + "prettier" + ], + "plugins": [ + "jsx-a11y", + "prettier" + ], + "rules": { + "semi": 1, + "prettier/prettier": [ + "error", + { + "semi": true + } + ] + } }, "browserslist": { "production": [ From 67787efd9b8230070ff03b62f2baeb7ef8a1c5b7 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 19 Jun 2021 10:46:55 +0300 Subject: [PATCH 06/17] Fix code style --- src/App.js | 4 ++-- src/App.test.js | 6 +++--- src/index.js | 12 ++++++------ src/reportWebVitals.js | 4 ++-- src/setupTests.js | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/App.js b/src/App.js index 3784575..e9f34aa 100644 --- a/src/App.js +++ b/src/App.js @@ -1,5 +1,5 @@ -import logo from './logo.svg'; -import './App.css'; +import logo from "./logo.svg"; +import "./App.css"; function App() { return ( diff --git a/src/App.test.js b/src/App.test.js index 1f03afe..9382b9a 100644 --- a/src/App.test.js +++ b/src/App.test.js @@ -1,7 +1,7 @@ -import { render, screen } from '@testing-library/react'; -import App from './App'; +import { render, screen } from "@testing-library/react"; +import App from "./App"; -test('renders learn react link', () => { +test("renders learn react link", () => { render(); const linkElement = screen.getByText(/learn react/i); expect(linkElement).toBeInTheDocument(); diff --git a/src/index.js b/src/index.js index ef2edf8..ad9cbbb 100644 --- a/src/index.js +++ b/src/index.js @@ -1,14 +1,14 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import './index.css'; -import App from './App'; -import reportWebVitals from './reportWebVitals'; +import React from "react"; +import ReactDOM from "react-dom"; +import "./index.css"; +import App from "./App"; +import reportWebVitals from "./reportWebVitals"; ReactDOM.render( , - document.getElementById('root') + document.getElementById("root") ); // If you want to start measuring performance in your app, pass a function diff --git a/src/reportWebVitals.js b/src/reportWebVitals.js index 5253d3a..9ecd33f 100644 --- a/src/reportWebVitals.js +++ b/src/reportWebVitals.js @@ -1,6 +1,6 @@ -const reportWebVitals = onPerfEntry => { +const reportWebVitals = (onPerfEntry) => { if (onPerfEntry && onPerfEntry instanceof Function) { - import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { + import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { getCLS(onPerfEntry); getFID(onPerfEntry); getFCP(onPerfEntry); diff --git a/src/setupTests.js b/src/setupTests.js index 8f2609b..1dd407a 100644 --- a/src/setupTests.js +++ b/src/setupTests.js @@ -2,4 +2,4 @@ // allows you to do things like: // expect(element).toHaveTextContent(/react/i) // learn more: https://github.com/testing-library/jest-dom -import '@testing-library/jest-dom'; +import "@testing-library/jest-dom"; From bb8c8f11f2bf2243d943799b816f55ce08b58c94 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 19 Jun 2021 11:40:47 +0300 Subject: [PATCH 07/17] Add deploy-stage job --- .github/workflows/react.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml index 2d832e8..3e88581 100644 --- a/.github/workflows/react.yaml +++ b/.github/workflows/react.yaml @@ -34,3 +34,17 @@ jobs: name: build path: build/ if-no-files-found: error + deploy-stage: + runs-on: ubuntu-latest + needs: build + environment: stage + steps: + - uses: actions/download-artifact@v2 + name: build + - uses: shallwefootball/s3-upload-action@v1.1.3 + with: + aws_key_id: ${{ secrets.AWS_KEY_ID }} + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}} + aws_bucket: ${{ secrets.AWS_BUCKET }} + source_dir: build + From 2de9fbfcb23bff7b008aafd341a9c0b60cb88605 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 19 Jun 2021 12:19:25 +0300 Subject: [PATCH 08/17] Change deploy-stage s3 action to jakejarvis/s3-sync-action --- .github/workflows/react.yaml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml index 3e88581..84c1b79 100644 --- a/.github/workflows/react.yaml +++ b/.github/workflows/react.yaml @@ -40,11 +40,16 @@ jobs: environment: stage steps: - uses: actions/download-artifact@v2 - name: build - - uses: shallwefootball/s3-upload-action@v1.1.3 with: - aws_key_id: ${{ secrets.AWS_KEY_ID }} - aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}} - aws_bucket: ${{ secrets.AWS_BUCKET }} - source_dir: build - + name: build + - uses: jakejarvis/s3-sync-action@v0.5.1 + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ru-central1 + SOURCE_DIR: build + DEST_DIR: "/pr/${{github.event.number}}" + AWS_S3_ENDPOINT: https://storage.yandexcloud.net From 7a31d6dd7b3963d7628d340ec366fa66b4751bc6 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 19 Jun 2021 12:24:11 +0300 Subject: [PATCH 09/17] Fix download artifact path --- .github/workflows/react.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml index 84c1b79..052ff23 100644 --- a/.github/workflows/react.yaml +++ b/.github/workflows/react.yaml @@ -42,6 +42,7 @@ jobs: - uses: actions/download-artifact@v2 with: name: build + path: ~/build - uses: jakejarvis/s3-sync-action@v0.5.1 with: args: --acl public-read --follow-symlinks --delete From b67e5fcf98df724f3874275d93bf3ed1c0b5df17 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 19 Jun 2021 12:28:02 +0300 Subject: [PATCH 10/17] Fix build path --- .github/workflows/react.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml index 052ff23..d03f569 100644 --- a/.github/workflows/react.yaml +++ b/.github/workflows/react.yaml @@ -42,7 +42,7 @@ jobs: - uses: actions/download-artifact@v2 with: name: build - path: ~/build + path: ./build - uses: jakejarvis/s3-sync-action@v0.5.1 with: args: --acl public-read --follow-symlinks --delete @@ -51,6 +51,6 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_REGION: ru-central1 - SOURCE_DIR: build + SOURCE_DIR: ./build DEST_DIR: "/pr/${{github.event.number}}" AWS_S3_ENDPOINT: https://storage.yandexcloud.net From 5cacedc27d856f8c5d1556703f797f91c14154bd Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 19 Jun 2021 12:43:00 +0300 Subject: [PATCH 11/17] Fix dest path --- .github/workflows/react.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml index d03f569..14d6959 100644 --- a/.github/workflows/react.yaml +++ b/.github/workflows/react.yaml @@ -52,5 +52,5 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_REGION: ru-central1 SOURCE_DIR: ./build - DEST_DIR: "/pr/${{github.event.number}}" + DEST_DIR: ./pr/${{github.base_ref}} AWS_S3_ENDPOINT: https://storage.yandexcloud.net From 97dd6f478ad2e1f8f5e7a1e09e2252263040d6a0 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 22 Jun 2021 15:43:20 +0300 Subject: [PATCH 12/17] Update DEST_DIR to ./pr/${{github.run_id}} --- .github/workflows/react.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml index 14d6959..367bce8 100644 --- a/.github/workflows/react.yaml +++ b/.github/workflows/react.yaml @@ -52,5 +52,5 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_REGION: ru-central1 SOURCE_DIR: ./build - DEST_DIR: ./pr/${{github.base_ref}} + DEST_DIR: ./pr/${{github.run_id}} AWS_S3_ENDPOINT: https://storage.yandexcloud.net From 8e9c5e4c30853107488317567e6ebddff5169dc1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 22 Jun 2021 15:46:14 +0300 Subject: [PATCH 13/17] Fix dest path --- .github/workflows/react.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml index 367bce8..bfdda52 100644 --- a/.github/workflows/react.yaml +++ b/.github/workflows/react.yaml @@ -52,5 +52,5 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_REGION: ru-central1 SOURCE_DIR: ./build - DEST_DIR: ./pr/${{github.run_id}} + DEST_DIR: pr/${{github.run_id}} AWS_S3_ENDPOINT: https://storage.yandexcloud.net From 989fa7cf801724d0822d1038bd7c70a95db24b46 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 22 Jun 2021 15:55:11 +0300 Subject: [PATCH 14/17] Set relative homepage --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index bcc024d..67cb53a 100644 --- a/package.json +++ b/package.json @@ -59,5 +59,6 @@ "last 1 firefox version", "last 1 safari version" ] - } + }, + "homepage": "./" } From 3ac832cc4ed0c085bc8c875c7a2c05f27840ddaf Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 22 Jun 2021 16:38:42 +0300 Subject: [PATCH 15/17] Add notifications --- .github/workflows/react.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml index bfdda52..0c66a20 100644 --- a/.github/workflows/react.yaml +++ b/.github/workflows/react.yaml @@ -54,3 +54,7 @@ jobs: SOURCE_DIR: ./build DEST_DIR: pr/${{github.run_id}} AWS_S3_ENDPOINT: https://storage.yandexcloud.net + - uses: appleboy/telegram-action@v0.0.3 + with: + to: ${{ secrets.TELEGRAM_TO }} + token: ${{ secrets.TELEGRAM_TOKEN }} From 9fd439a6e85f0c689cac9563b43801ae64ddec4c Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 22 Jun 2021 16:44:21 +0300 Subject: [PATCH 16/17] Fix version appleboy/telegram-action --- .github/workflows/react.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml index 0c66a20..3f1da30 100644 --- a/.github/workflows/react.yaml +++ b/.github/workflows/react.yaml @@ -54,7 +54,7 @@ jobs: SOURCE_DIR: ./build DEST_DIR: pr/${{github.run_id}} AWS_S3_ENDPOINT: https://storage.yandexcloud.net - - uses: appleboy/telegram-action@v0.0.3 + - uses: appleboy/telegram-action@0.0.3 with: to: ${{ secrets.TELEGRAM_TO }} token: ${{ secrets.TELEGRAM_TOKEN }} From 12db62934857153dba4baa2b476ea026fb0675c6 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 22 Jun 2021 16:57:49 +0300 Subject: [PATCH 17/17] Fix version appleboy/telegram-action --- .github/workflows/react.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml index 3f1da30..544f13e 100644 --- a/.github/workflows/react.yaml +++ b/.github/workflows/react.yaml @@ -54,7 +54,7 @@ jobs: SOURCE_DIR: ./build DEST_DIR: pr/${{github.run_id}} AWS_S3_ENDPOINT: https://storage.yandexcloud.net - - uses: appleboy/telegram-action@0.0.3 + - uses: appleboy/telegram-action@v0.1.1 with: to: ${{ secrets.TELEGRAM_TO }} token: ${{ secrets.TELEGRAM_TOKEN }}