diff --git a/.github/workflows/react.yaml b/.github/workflows/react.yaml new file mode 100644 index 0000000..544f13e --- /dev/null +++ b/.github/workflows/react.yaml @@ -0,0 +1,60 @@ +name: '' +on: [push] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - 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 lint + - 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 + path: build/ + if-no-files-found: error + deploy-stage: + runs-on: ubuntu-latest + needs: build + environment: stage + steps: + - 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 + 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.run_id}} + AWS_S3_ENDPOINT: https://storage.yandexcloud.net + - uses: appleboy/telegram-action@v0.1.1 + with: + to: ${{ secrets.TELEGRAM_TO }} + token: ${{ secrets.TELEGRAM_TOKEN }} diff --git a/package.json b/package.json index 4c15a13..67cb53a 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": [ @@ -34,5 +59,6 @@ "last 1 firefox version", "last 1 safari version" ] - } + }, + "homepage": "./" } 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";