Unverified Commit 7c9a29a7 authored by Marcos Iglesias's avatar Marcos Iglesias Committed by GitHub

build: Adding betterer to workflow (#598)

Signed-off-by: 's avatarMarcos Iglesias Valle <golodhros@gmail.com>
parent 24509612
...@@ -15,8 +15,8 @@ jobs: ...@@ -15,8 +15,8 @@ jobs:
test-unit-python: test-unit-python:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
strategy: strategy:
matrix: matrix:
python-version: ['3.6.x', '3.7.x'] python-version: ["3.6.x", "3.7.x"]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
...@@ -34,20 +34,24 @@ jobs: ...@@ -34,20 +34,24 @@ jobs:
matrix: matrix:
node-version: [12.x] node-version: [12.x]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- name: Install and Lint - name: Install and Lint
working-directory: ./amundsen_application/static working-directory: ./amundsen_application/static
run: | run: |
npm install npm install
npm install codecov -g npm install codecov -g
npm run lint npm run lint
npm run build --if-present - name: Check and build
- name: Test working-directory: ./amundsen_application/static
working-directory: ./amundsen_application/static run: |
run: npm run test npm run betterer
env: npm run build --if-present
CI: true - name: Test
working-directory: ./amundsen_application/static
run: npm run test
env:
CI: true
This diff is collapsed.
import { typescript } from '@betterer/typescript';
export default {
'strict null compilation': typescript('./tsconfig.json', {
strictNullChecks: true,
}),
};
...@@ -52,6 +52,12 @@ interface DashboardPageState { ...@@ -52,6 +52,12 @@ interface DashboardPageState {
uri: string; uri: string;
} }
type TabInfo = {
content: JSX.Element;
key: string;
title: string;
};
export interface StateFromProps { export interface StateFromProps {
isLoading: boolean; isLoading: boolean;
statusCode: number; statusCode: number;
...@@ -111,7 +117,8 @@ export class DashboardPage extends React.Component< ...@@ -111,7 +117,8 @@ export class DashboardPage extends React.Component<
}; };
renderTabs() { renderTabs() {
const tabInfo = []; const tabInfo: TabInfo[] = [];
tabInfo.push({ tabInfo.push({
content: ( content: (
<ResourceList <ResourceList
......
...@@ -60,8 +60,8 @@ describe('Flag', () => { ...@@ -60,8 +60,8 @@ describe('Flag', () => {
expect(convertText(text, 'not a valid options')).toEqual(text); expect(convertText(text, 'not a valid options')).toEqual(text);
}); });
it('returns empty strings for null values', () => { it('returns empty strings for undefined values', () => {
expect(convertText(null, CaseType.SENTENCE_CASE)).toEqual(''); expect(convertText(undefined, CaseType.SENTENCE_CASE)).toEqual('');
}); });
}); });
}); });
...@@ -19,8 +19,7 @@ export interface FlagProps { ...@@ -19,8 +19,7 @@ export interface FlagProps {
labelStyle?: BadgeStyle; labelStyle?: BadgeStyle;
} }
export function convertText(str: string, caseType: string): string { export function convertText(str = '', caseType: string): string {
str = str || '';
switch (caseType) { switch (caseType) {
case CaseType.LOWER_CASE: case CaseType.LOWER_CASE:
return str.toLowerCase(); return str.toLowerCase();
...@@ -34,9 +33,9 @@ export function convertText(str: string, caseType: string): string { ...@@ -34,9 +33,9 @@ export function convertText(str: string, caseType: string): string {
} }
const Flag: React.FC<FlagProps> = ({ const Flag: React.FC<FlagProps> = ({
caseType, caseType = null,
text, text = '',
labelStyle, labelStyle = BadgeStyle.DEFAULT,
}: FlagProps) => { }: FlagProps) => {
// TODO: After upgrading to Bootstrap 4, this component should leverage badges // TODO: After upgrading to Bootstrap 4, this component should leverage badges
// https://getbootstrap.com/docs/4.1/components/badge/ // https://getbootstrap.com/docs/4.1/components/badge/
...@@ -49,10 +48,4 @@ const Flag: React.FC<FlagProps> = ({ ...@@ -49,10 +48,4 @@ const Flag: React.FC<FlagProps> = ({
); );
}; };
Flag.defaultProps = {
caseType: null,
text: '',
labelStyle: BadgeStyle.DEFAULT,
};
export default Flag; export default Flag;
...@@ -10,7 +10,7 @@ TODO: Coupling the shape of the search state and search response requires the us ...@@ -10,7 +10,7 @@ TODO: Coupling the shape of the search state and search response requires the us
Partial to resolve errors, removing type safty of these methods. We should Partial to resolve errors, removing type safty of these methods. We should
restructure any logic that takes of advantage of the case where the shape of the response restructure any logic that takes of advantage of the case where the shape of the response
and the shape of the state happend to be the same because a piece of application state and the shape of the state happend to be the same because a piece of application state
can be the combination of multiple responses. can be the combination of multiple responses.
*/ */
export const getPageIndex = ( export const getPageIndex = (
......
...@@ -154,7 +154,7 @@ const globalState: GlobalState = { ...@@ -154,7 +154,7 @@ const globalState: GlobalState = {
data: {}, data: {},
status: null, status: null,
}, },
statusCode: null, statusCode: 200,
tableData: { tableData: {
badges: [], badges: [],
cluster: '', cluster: '',
......
...@@ -26,7 +26,9 @@ ...@@ -26,7 +26,9 @@
"stylelint:fix": "stylelint --fix '**/*.scss'", "stylelint:fix": "stylelint --fix '**/*.scss'",
"format": "prettier --loglevel warn --write \"**/*.{ts,tsx,css,scss}\"", "format": "prettier --loglevel warn --write \"**/*.{ts,tsx,css,scss}\"",
"storybook": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' start-storybook -p 6006", "storybook": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' start-storybook -p 6006",
"build-storybook": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' build-storybook" "build-storybook": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' build-storybook",
"betterer": "betterer",
"betterer:update": "betterer --update"
}, },
"author": "", "author": "",
"license": "Apache-2.0", "license": "Apache-2.0",
...@@ -57,6 +59,8 @@ ...@@ -57,6 +59,8 @@
"@storybook/addons": "^5.3.19", "@storybook/addons": "^5.3.19",
"@storybook/react": "^5.3.19", "@storybook/react": "^5.3.19",
"@storybook/theming": "^6.0.6", "@storybook/theming": "^6.0.6",
"@betterer/cli": "^3.0.0",
"@betterer/typescript": "^3.0.1",
"@types/enzyme": "^3.10.5", "@types/enzyme": "^3.10.5",
"@types/jasmine-matchers": "^0.2.32", "@types/jasmine-matchers": "^0.2.32",
"@types/jest": "^24.9.1", "@types/jest": "^24.9.1",
......
...@@ -60,6 +60,10 @@ Using Storybook makes it much easier to quickly iterate on components when getti ...@@ -60,6 +60,10 @@ Using Storybook makes it much easier to quickly iterate on components when getti
We use TypeScript in our codebase, so `npm run tsc` conducts type checking. The build commands `npm run build` and `npm run dev-build` also conduct type checking, but are slower because they also build the source code. Run any of these commands and fix all failed checks before submitting a PR. We use TypeScript in our codebase, so `npm run tsc` conducts type checking. The build commands `npm run build` and `npm run dev-build` also conduct type checking, but are slower because they also build the source code. Run any of these commands and fix all failed checks before submitting a PR.
Currently, we are trying to gradually make our TypeScript code more strict. For that, we are leveraging a project called [betterer][betterer], which keeps track of our errors when a given test is passed. Right now, we are running it with "strictNullChecks" set to true, so if any code change makes the results worse, it will break the build.
[betterer]: https://github.com/phenomnomnominal/betterer
### Frontend Linting and Formatting ### Frontend Linting and Formatting
We have in place two linters – [ESLint][eslint] for our JavaScript and TypeScript files, [Stylelint][stylelint] for our Sass files. If you have both ESLint and Stylelint extensions installed on your IDE, you should get warnings on your editor by default. We have in place two linters – [ESLint][eslint] for our JavaScript and TypeScript files, [Stylelint][stylelint] for our Sass files. If you have both ESLint and Stylelint extensions installed on your IDE, you should get warnings on your editor by default.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment