Skip to content
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

INTYGFV-15269: Upgrade build system, react and dependencies #715

Merged
merged 58 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
994616c
WIP
SamuelTilly Feb 8, 2023
9fd1412
WIP
SamuelTilly Feb 8, 2023
c6c69fe
WIP
SamuelTilly Feb 8, 2023
b279b62
WIP
SamuelTilly Feb 8, 2023
6b7e04b
WIP
SamuelTilly Feb 8, 2023
d172f38
Merge remote-tracking branch 'origin/master' into feature/monorepo_fixes
SamuelTilly Feb 8, 2023
045e483
WIP
SamuelTilly Feb 8, 2023
77dc750
WIP
SamuelTilly Feb 9, 2023
124ad3e
merge with origin/master
SamuelTilly Feb 15, 2023
fa625c8
WIP
SamuelTilly Feb 15, 2023
3702a9c
Working build
SamuelTilly Feb 16, 2023
c251669
WIP
SamuelTilly Feb 16, 2023
a99eee3
Merge remote-tracking branch 'origin/master' into feature/monorepo_fixes
SamuelTilly Feb 16, 2023
1258ee8
WIP
SamuelTilly Feb 17, 2023
1ffe108
Merge remote-tracking branch 'origin/master' into feature/monorepo_fixes
SamuelTilly Feb 17, 2023
5d15fbb
vitest in common
SamuelTilly Feb 17, 2023
9b4a623
vitest
SamuelTilly Feb 17, 2023
3d2ac9f
vitest
SamuelTilly Feb 17, 2023
96695b3
every tests pass
SamuelTilly Feb 20, 2023
2ac9827
Merge remote-tracking branch 'origin/master' into feature/monorepo_fixes
SamuelTilly Feb 20, 2023
a5f2294
Fix typescript issues
SamuelTilly Feb 21, 2023
d769568
typo in dockerfile
SamuelTilly Feb 21, 2023
e033f2c
update github actions
SamuelTilly Feb 21, 2023
3ed6312
cleanup
SamuelTilly Feb 21, 2023
afff077
missing functions
SamuelTilly Feb 21, 2023
35c0296
rename eslint file
SamuelTilly Feb 21, 2023
bd057c3
use env variables
SamuelTilly Feb 21, 2023
e93a65d
make vite functions global for webcert
SamuelTilly Feb 21, 2023
9a99aa1
make vite functions global for common
SamuelTilly Feb 21, 2023
1b86064
eslint wip
SamuelTilly Feb 21, 2023
b95f604
Working E2E
SamuelTilly Feb 23, 2023
2bed505
Use older version of inera css with correct colors
SamuelTilly Feb 23, 2023
4f9c27a
More progress on E2E
SamuelTilly Feb 23, 2023
4eb5440
Merge remote-tracking branch 'origin/master' into feature/monorepo_fixes
SamuelTilly Feb 23, 2023
77e9b57
update yarn.lock
SamuelTilly Feb 23, 2023
f3465c0
fix broken test
SamuelTilly Feb 23, 2023
022e28f
configure eslint
SamuelTilly Feb 24, 2023
a27f7fa
eslint github action
SamuelTilly Feb 24, 2023
5f8a17e
sort linting legacy overrides
SamuelTilly Feb 24, 2023
e3f68c6
update readme
SamuelTilly Feb 28, 2023
249d44f
Merge remote-tracking branch 'origin/master' into feature/monorepo_fixes
SamuelTilly Feb 28, 2023
f97f8a5
Merge remote-tracking branch 'origin/master' into feature/monorepo_fixes
SamuelTilly Feb 28, 2023
f527959
cleanup
SamuelTilly Feb 28, 2023
ec24222
use precompiled css, remove sass dependency
SamuelTilly Feb 28, 2023
1b2b47b
apply accept headers for fake login
SamuelTilly Feb 28, 2023
7cc9f49
Merge remote-tracking branch 'origin/master' into feature/monorepo_fixes
SamuelTilly Feb 28, 2023
0e344ef
Revert changes to UeMedicalInvestigation
SamuelTilly Mar 1, 2023
8938090
remove alias
SamuelTilly Mar 2, 2023
72615e0
make port strict
SamuelTilly Mar 2, 2023
4c73584
make hmr work when developing
SamuelTilly Mar 3, 2023
559fe1a
update assemble script
SamuelTilly Mar 3, 2023
aca92c3
fix typo
SamuelTilly Mar 3, 2023
1e0d1ec
Merge remote-tracking branch 'origin/master' into feature/monorepo_fixes
SamuelTilly Mar 3, 2023
f3bd31f
fix junit report and build for assemble script
SamuelTilly Mar 3, 2023
e63fa7b
re-add junit merger
SamuelTilly Mar 3, 2023
dd6d287
fix broken tests after merge
SamuelTilly Mar 3, 2023
9e90397
simplified junit report and revert change to build order
SamuelTilly Mar 3, 2023
e8289ef
Merge branch 'master' into feature/monorepo_fixes
SamuelTilly Mar 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ['custom'],
}
54 changes: 54 additions & 0 deletions .eslintrc.json.back
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier/@typescript-eslint",
"prettier/react",
"plugin:jsdoc/recommended",
"plugin:prettier/recommended",
"plugin:storybook/recommended"
],
"plugins": ["unused-imports"],
"settings": {
"jsdoc": {
"mode": "typescript"
}
},
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": ["warn"],
"import/no-relative-packages": "error",
"jsdoc/require-jsdoc": "off",
"jsdoc/require-param": "off",
"jsdoc/require-returns": "off"
},
"overrides": [
{
"files": ["packages/webcert-e2e/**/*.js"],
"extends": ["plugin:cypress/recommended"],
"rules": {
"no-undef": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"no-unused-expressions": "off"
}
},
{
"files": ["*.stories.@(ts|tsx|js|jsx|mjs|cjs)"],
"rules": {
"import/no-anonymous-default-export": "off"
}
},
{
"files": ["**/*.stories.*"],
"rules": {
"import/no-anonymous-default-export": "off"
}
}
]
}
10 changes: 5 additions & 5 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
- uses: cypress-io/github-action@v4
env:
NODE_TLS_REJECT_UNAUTHORIZED: 0
HTTP_PROXY_LOGS: 'false'
with:
install-command: yarn --frozen-lockfile --silent
working-directory: 'packages/webcert-e2e'
start: yarn workspace @frontend/webcert start:test
wait-on: 'https://localhost:3000'
install-command: yarn --frozen-lockfile --silent
build: yarn workspace @frontend/common build
start: yarn workspace @frontend/webcert dev -m test
wait-on: 'https://127.0.0.1:3000'
command: yarn workspace @frontend/webcert-e2e cypress run
--config baseUrl=https://localhost:3000,screenshotOnRunFailure=false
--config baseUrl=https://127.0.0.1:3000,screenshotOnRunFailure=false
--env grepTags=@react,grepFilterSpecs=true
64 changes: 30 additions & 34 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,38 @@ on:
branches: [master, 'project/**']

jobs:
eslint:
name: runner / eslint
build:
name: Build and Test
timeout-minutes: 15
runs-on: ubuntu-latest
# To use Remote Caching, uncomment the next lines and follow the steps below.
# env:
# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
# TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14.x'
cache: 'yarn'
- run: yarn install --frozen-lockfile
- uses: reviewdog/action-eslint@v1.17.0
tsc:
name: runner / tsc
runs-on: ubuntu-latest
strategy:
matrix:
package: [common, webcert]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: Check out code
uses: actions/checkout@v3
with:
node-version: '14.x'
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn workspace @frontend/${{ matrix.package }} tsc --noEmit
jest:
name: runner / jest
runs-on: ubuntu-latest
strategy:
matrix:
package: [common, webcert]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
fetch-depth: 2

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: '14.x'
node-version: 14
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn workspace @frontend/${{ matrix.package }} test:ci

- name: Install dependencies
run: yarn

- name: Build
run: yarn build

- name: 'Lint'
uses: reviewdog/action-eslint@v1.17.0

- name: Typescript
run: yarn typescript

- name: Test
run: yarn test
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ junit.xml
# production
build

# development
dist
.turbo

# misc
.DS_Store
.env.local
Expand All @@ -27,4 +31,6 @@ yarn-error.log*
/packages/webcert-e2e/results/
/packages/webcert-e2e/videos/

/.vscode/settings.json
/.vscode/settings.json

lint-result.xml
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

5 changes: 0 additions & 5 deletions .s2iignore

This file was deleted.

8 changes: 2 additions & 6 deletions Dockerfile.webcert
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:12-alpine3.12 AS build-stage
FROM node:14-alpine3.16 AS build-stage

# RUN npm install -g yarn
RUN apk update
Expand All @@ -18,7 +18,6 @@ WORKDIR /app
COPY ./package.json .
COPY ./yarn.lock .
COPY ./packages/common/package.json ./packages/common/package.json
COPY ./packages/mockserver/package.json ./packages/mockserver/package.json
COPY ./packages/webcert/package.json ./packages/webcert/package.json

# Install all dependencies
Expand All @@ -27,9 +26,6 @@ RUN yarn install
# Copy the source
COPY . .

# Change to webcert
WORKDIR /app/packages/webcert

RUN yarn build

# Make nginx image
Expand All @@ -41,7 +37,7 @@ WORKDIR /usr/share/nginx/html
# Remove default nginx static assets
RUN rm -rf ./*

COPY --from=build-stage /app/packages/webcert/build/ .
COPY --from=build-stage /app/packages/webcert/dist/ .

COPY --from=build-stage /app/packages/webcert/nginx/templates /etc/nginx/templates/
COPY --from=build-stage /app/packages/webcert/nginx/conf/nginx.conf /etc/nginx/nginx.conf
Expand Down
74 changes: 37 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,35 @@

## Setup

- Clone the repo. `git clone https://github.com/sklintyg/frontend.git`
- Open terminal in `sklintyg/frontend/` and install packages with `yarn install`
- Configure preferred IDE
- IntelliJ
- Install [Prettier](https://plugins.jetbrains.com/plugin/10456-prettier/) plugin.
- Configure to use prettier when formatting in IntelliJ (requires IntelliJ 2020.2). See Settings -> Language & Frameworks -> Javascript -> Prettier
- VS Code
- Install plugin `ESLint`
- Install plugin `vscode-styled-components`
- Install plugin `Prettier - Code formatter`
- Enable auto format on save
- Press `ctrl` + `shift` + `p`, type `settings` and open `Preferences: Open Settings (JSON)`
- Add the following properties
```json
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
```
- Add the following properties (_optional_)
```json
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll": true
}
```
1. Install dependencies with `yarn install`
2. Execute a build with `yarn build`
3. Start development environment and watchers with `yarn start`

## Configure Editor

- IntelliJ
- Install [Prettier](https://plugins.jetbrains.com/plugin/10456-prettier/) plugin.
- Configure to use prettier when formatting in IntelliJ (requires IntelliJ 2020.2). See Settings -> Language & Frameworks -> Javascript -> Prettier
- VS Code
- Install plugin `ESLint`
- Install plugin `vscode-styled-components`
- Install plugin `Prettier - Code formatter`
- Enable auto format on save
- Press `ctrl` + `shift` + `p`, type `settings` and open `Preferences: Open Settings (JSON)`
- Add the following properties
```json
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
```
- Add the following properties (_optional_)
```json
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll": true
}
```

## Run Webcert backend and frontend client

Expand All @@ -63,7 +66,7 @@ Detailed instructions for building and running the backend apps can be found in
- Open terminal in `sklintyg/webcert/`
- Run command `gradlew appRun` (or `./gradlew appRun` in Git Bash)
5. Run the app in the development mode. React will hot-reload changes made in the app as well as in common.
- Start webcert in development: `yarn workspace @frontend/webcert start`
- Start webcert in development: `yarn start`
6. Navigate to Webcert-frontend in a chromium-browser: https://wc2.wc.localtest.me/welcome

## OpenShift Build Pipeline
Expand Down Expand Up @@ -97,13 +100,11 @@ Storybook can be used to develop and test components within the common package.

## Running tests

Jest is used for executing tests.
vitest is used for executing tests.

To run tests in Webcert: `yarn workspace @frontend/webcert test`
To run tests in all packages `yarn test`

To run tests in Common: `yarn workspace @frontend/common test` (add `--watchAll` if you want the test runner to run the tests for any change you make.)

See [Jest CLI Options](https://jestjs.io/docs/en/cli) for more info what you can do when executing tests.
To run tests in a perticular workspace `yarn workspace <name of workspace> test`

## Writing tests

Expand All @@ -113,18 +114,17 @@ Smoke test that checks if the component can be rendered without crashing. Ex:

```javascript
it('renders without crashing', () => {
const question = createQuestionWithTextValue()
const div = document.createElement('div')
ReactDOM.render(<UvText question={question} />, div)
const question = fakeTextElement({ id: 'id' })
expect(render(<UvText question={question['id']} />)).not.toThrow()
})
```

Tests that verifies the components behavior from a user perspective. Use React Testing Library.

```javascript
it('displaying empty value', () => {
const question = createQuestion({ type: CertificateDataValueType.TEXT })
const { getByText } = render(<UvText question={question} />)
const question = fakeTextElement({ id: 'id' })
const { getByText } = render(<UvText question={question['id']} />)
getByText(/Ej angivet/i)
})
```
6 changes: 0 additions & 6 deletions lerna.json

This file was deleted.

Loading