From adbb2c3d3f8de34abff6e9068223846963a1f411 Mon Sep 17 00:00:00 2001 From: Donald Labaj Date: Tue, 1 Sep 2020 10:51:59 -0400 Subject: [PATCH] Added github actions to automate build, test, and linting (#41) Fixes issue #15. Builds, test, lints, and checks format when a PR is created using github actions. --- .github/workflows/node.js.yml | 33 +++++++++++++++ package.json | 1 + src/PageHeader.tsx | 30 +++++++------- src/PageNav.tsx | 8 ++-- src/__mocks__/fileMock.js | 2 +- src/auth/KeycloakContext.tsx | 4 +- src/auth/keycloak.service.ts | 18 ++++----- src/auth/keycloak.ts | 6 +-- src/clients/ClientList.test.tsx | 10 ++--- src/clients/ClientList.tsx | 40 +++++++++---------- src/components/alert/Alerts.test.tsx | 22 +++++----- src/components/alert/Alerts.tsx | 6 +-- .../alert/__snapshots__/Alerts.test.tsx.snap | 4 +- src/components/data-loader/DataLoader.tsx | 6 +-- src/components/external-link/ExternalLink.tsx | 8 ++-- .../realm-selector/RealmSelector.tsx | 10 ++--- src/components/scroll-form/FormPanel.tsx | 6 +-- src/components/scroll-form/ScrollForm.tsx | 14 +++---- src/components/table-toolbar/TableToolbar.tsx | 14 +++---- src/forms/realm/NewRealmForm.tsx | 2 +- src/http-service/HttpClientContext.tsx | 4 +- src/http-service/http-client.ts | 20 +++++----- src/i18n.ts | 10 ++--- src/index.tsx | 24 +++++------ src/util.ts | 9 +++-- 25 files changed, 172 insertions(+), 139 deletions(-) create mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000000..72ea87a893 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,33 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - run: npm install -g yarn + - run: yarn install + - run: yarn format:check + - run: yarn build + - run: yarn lint + - run: yarn test \ No newline at end of file diff --git a/package.json b/package.json index 01ebf86eed..cad6ef7bbb 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "build": "snowpack build", "test": "jest", "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"", + "format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx}\"", "lint": "eslint ./src/**/*.ts*", "storybook": "start-storybook -p 6006", "build-storybook": "build-storybook" diff --git a/src/PageHeader.tsx b/src/PageHeader.tsx index 028eedd339..fa1f2cc054 100644 --- a/src/PageHeader.tsx +++ b/src/PageHeader.tsx @@ -1,5 +1,5 @@ -import React, { useContext, useState } from 'react'; -import { useTranslation } from 'react-i18next'; +import React, { useContext, useState } from "react"; +import { useTranslation } from "react-i18next"; import { Avatar, Button, @@ -14,10 +14,10 @@ import { PageHeaderTools, PageHeaderToolsItem, PageHeaderToolsGroup, -} from '@patternfly/react-core'; -import { HelpIcon } from '@patternfly/react-icons'; -import { KeycloakContext } from './auth/KeycloakContext'; -import { Link } from 'react-router-dom'; +} from "@patternfly/react-core"; +import { HelpIcon } from "@patternfly/react-icons"; +import { KeycloakContext } from "./auth/KeycloakContext"; +import { Link } from "react-router-dom"; export const Header = () => { return ( @@ -39,7 +39,7 @@ const ManageAccountDropdownItem = () => { const { t } = useTranslation(); return ( keycloak?.account()}> - {t('Manage account')} + {t("Manage account")} ); }; @@ -49,19 +49,19 @@ const SignOutDropdownItem = () => { const { t } = useTranslation(); return ( keycloak?.logout()}> - {t('Sign out')} + {t("Sign out")} ); }; const ServerInfoDropdownItem = () => { const { t } = useTranslation(); - return {t('Server info')}; + return {t("Server info")}; }; const HelpDropdownItem = () => { const { t } = useTranslation(); - const help = t('Help'); + const help = t("Help"); return ( @@ -90,8 +90,8 @@ const headerTools = () => { @@ -104,15 +104,15 @@ const headerTools = () => {