Skip to content

Commit

Permalink
Merge branch 'main' into perf/dashboard-test
Browse files Browse the repository at this point in the history
  • Loading branch information
NoamGaash committed Nov 14, 2023
1 parent 31b6e62 commit e5f8635
Show file tree
Hide file tree
Showing 19 changed files with 16,595 additions and 10,710 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/clean_tree.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,31 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install yarn
run: npm install -g yarn
node-version: 18
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install
- name: make sure package.lock does not exist
run: rm -f package-lock.json
- name: Git Check Clean Tree
uses: ArkadiK94/[email protected]
with:
error-reason: "removing package-lock.json file"
error-reason: 'removing package-lock.json file'
- name: Install dependencies
run: yarn
- name: Git Check Clean Tree
uses: ArkadiK94/[email protected]
with:
error-reason: "yarn"
error-reason: 'yarn'
- name: Build
run: yarn build
- name: Build Storybook
run: yarn build-storybook -o dist/storybook
- name: Git Check Clean Tree
uses: ArkadiK94/[email protected]
with:
error-reason: "yarn build"
error-reason: 'yarn build and yarn build-storybook'
- name: Clean up
if: always()
run: npm uninstall -g yarn
run: npm uninstall -g yarn
23 changes: 12 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: yarn
- name: Run lint
run: yarn lint
- name: find circular dependencies
run: yarn madge --extensions js,ts --circular .

- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install
- name: Run lint
run: yarn lint
- name: find circular dependencies
run: yarn madge --extensions js,ts --circular .
78 changes: 40 additions & 38 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,47 @@ jobs:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: yarn
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30\
- uses: shallwefootball/s3-upload-action@master
name: Upload report to S3
if: always()
id: s3-report
continue-on-error: true
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: noam-gaash.co.il
source_dir: playwright-report
destination_dir: ${{ github.run_id }}/open-bus/playwright-report
- name: output link to report to the summary
if: always() && steps.s3-report.outcome == 'success'
run: echo "link to report - https://s3.amazonaws.com/noam-gaash.co.il/$GITHUB_RUN_ID/open-bus/playwright-report/index.html" >> $GITHUB_STEP_SUMMARY
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30\
- uses: shallwefootball/s3-upload-action@master
name: Upload report to S3
if: always()
id: s3-report
continue-on-error: true
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: noam-gaash.co.il
source_dir: playwright-report
destination_dir: ${{ github.run_id }}/open-bus/playwright-report
- name: output link to report to the summary
if: always() && steps.s3-report.outcome == 'success'
run: echo "link to report - https://s3.amazonaws.com/noam-gaash.co.il/$GITHUB_RUN_ID/open-bus/playwright-report/index.html" >> $GITHUB_STEP_SUMMARY

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: yarn
- name: Build
run: yarn build
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: yarn
- name: Build
run: yarn build
18 changes: 10 additions & 8 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ jobs:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Install dependencies
run: yarn
- name: run the tests
run: yarn test:unit
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install
- name: run the tests
run: yarn test:unit
893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.1.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.0.1.cjs
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Pulled March 21, 2023
FROM node:18@sha256:8d9a875ee427897ef245302e31e2319385b092f1c3368b497e89790f240368f5
FROM node:18@sha256:8d9a875ee427897ef245302e31e2319385b092f1c3368b497e89790f240368f5 as build
WORKDIR /app
COPY package.json ./
COPY yarn.lock ./
RUN yarn install --pure-lockfile
COPY . .
RUN yarn set version stable
RUN yarn install --frozen-lockfile
RUN yarn run build
RUN yarn build-storybook -o dist/storybook

# Pulled March 21, 2023
FROM nginx@sha256:aa0afebbb3cfa473099a62c4b32e9b3fb73ed23f2a75a65ce1d4b4f55a5c2ef2
COPY nginx-default.conf /etc/nginx/conf.d/default.conf
COPY --from=0 /app/dist /usr/share/nginx/html
COPY --from=build /app/dist /usr/share/nginx/html
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"stylis-plugin-rtl": "^2.1.1",
"typescript": "^5.2.2",
"underscore.string": "^3.3.6",
"use-konami": "^1.0.1",
"usehooks-ts": "^2.9.1",
"vite": "^4.4.9",
"vite-plugin-svgr": "^4.1.0",
Expand Down Expand Up @@ -104,5 +105,6 @@
"prettier": "^2.7.1",
"storybook": "^7.5.3",
"vitest": "^0.34.6"
}
},
"packageManager": "[email protected]"
}
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { LocalizationProvider } from '@mui/x-date-pickers'
import RoutesList, { PAGES } from './routes'
import MainHeader from './pages/components/header/Header'
import LayoutContext from './layout/LayoutContext'
import { EasterEgg } from './pages/EasterEgg/EasterEgg'
const { Content } = Layout

const StyledLayout = styled(Layout)`
Expand Down Expand Up @@ -132,6 +133,7 @@ const App = () => {
const RoutedApp = () => (
<Router>
<App />
<EasterEgg />
</Router>
)
export default RoutedApp
2 changes: 0 additions & 2 deletions src/api/gapsService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import moment, { Moment } from 'moment-timezone'
import { GapsList } from '../model/gaps'
import { log } from '../log'
import axios from 'axios'
import { BASE_PATH } from './apiConfig'

Expand Down Expand Up @@ -30,7 +29,6 @@ export const getGapsAsync = async (
operatorId: string,
lineRef: number,
): Promise<GapsList> => {
log('Searching for gaps', { operatorId, lineRef })
const fromDay = moment(fromTimestamp).startOf('day')
const toDay = moment(toTimestamp).startOf('day')
// const startOfDay = moment(fromTimestamp).startOf('day')
Expand Down
2 changes: 0 additions & 2 deletions src/api/geoService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { computeDestinationPoint, findNearest } from 'geolib'
import { Coordinates, CoordinatesBoundary } from 'src/model/location'
import { log } from 'src/log'

export function geoLocationBoundary(location: Coordinates, byMeters: number): CoordinatesBoundary {
const moveUp = computeDestinationPoint(location, byMeters, 0)
Expand All @@ -11,7 +10,6 @@ export function geoLocationBoundary(location: Coordinates, byMeters: number): Co
lowerBound: { longitude: moveLeft.longitude, latitude: moveDown.latitude },
upperBound: { longitude: moveRight.longitude, latitude: moveUp.latitude },
}
log('getting boundary', { location, byMeters, boundary })
return boundary
}

Expand Down
10 changes: 0 additions & 10 deletions src/api/gtfsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import moment, { Moment } from 'moment'
import { BusRoute, fromGtfsRoute } from 'src/model/busRoute'
import { BusStop, fromGtfsStop } from 'src/model/busStop'
import { API_CONFIG, MAX_HITS_COUNT } from 'src/api/apiConfig'
import { log } from 'src/log'

const GTFS_API = new GtfsApi(API_CONFIG)
//const USER_CASES_API = new UserCasesApi(API_CONFIG)
Expand All @@ -16,7 +15,6 @@ export async function getRoutesAsync(
operatorId: string,
lineNumber: string,
): Promise<BusRoute[]> {
log('looking up routes', { operatorId, lineNumber })
const gtfsRoutes = await GTFS_API.gtfsRoutesListGet({
routeShortName: lineNumber,
operatorRefs: operatorId,
Expand All @@ -38,15 +36,13 @@ export async function getRoutesAsync(
return agg
}, {} as Record<string, BusRoute>),
)
log('fetched routes', routes.length)
return routes
}

export async function getStopsForRouteAsync(
routeIds: number[],
timestamp: Moment,
): Promise<BusStop[]> {
log('looking up stops', routeIds)
const stops: BusStop[] = []

for (const routeId of routeIds) {
Expand All @@ -71,7 +67,6 @@ export async function getStopsForRouteAsync(
}),
)
}
log('fetched stops', stops.length)
return stops.sort((a, b) =>
a.stopSequence === b.stopSequence
? a.name.localeCompare(b.name)
Expand All @@ -81,11 +76,6 @@ export async function getStopsForRouteAsync(

export async function getGtfsStopHitTimesAsync(stop: BusStop, timestamp: Moment) {
const targetStartTime = moment(timestamp).subtract(stop.minutesFromRouteStartTime, 'minutes')
log('looking for rides starting around time', {
stopId: stop.stopId,
min: stop.minutesFromRouteStartTime,
targetStartTime: targetStartTime.toDate(),
})

const rides = await GTFS_API.gtfsRidesListGet({
gtfsRouteId: stop.routeId,
Expand Down
7 changes: 0 additions & 7 deletions src/api/siriService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { BusStop } from 'src/model/busStop'
import moment, { Moment } from 'moment'
import { geoLocationBoundary, nearestLocation } from 'src/api/geoService'
import { Coordinates } from 'src/model/location'
import { log } from 'src/log'
import { BusRoute } from 'src/model/busRoute'
import { SiriRideWithRelatedPydanticModel } from 'open-bus-stride-client/openapi/models/SiriRideWithRelatedPydanticModel'

Expand Down Expand Up @@ -43,12 +42,6 @@ export async function getSiriRideWithRelated(
}

export async function getSiriStopHitTimesAsync(route: BusRoute, stop: BusStop, timestamp: Moment) {
log('looking for rides arriving at stop around time', {
route,
stopId: stop.stopId,
timestamp: timestamp.seconds(0).milliseconds(0).toDate(),
})

const rides = await getRidesAsync(route, stop, timestamp)
if (rides.length === 0) {
return []
Expand Down
10 changes: 0 additions & 10 deletions src/complaint/complaint.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,12 @@ try {
for (let attempt = 0; attempt < 3; attempt++) {
try {
await page.goto(url)
console.log('page loaded')
await page.click('text=כניסה לטופס')
await page.getByLabel('שם פרטי').fill(complaint.firstName)
await page.getByLabel('שם משפחה').fill(complaint.lastName)
await page.getByLabel('מספר זהות').fill(complaint.id)
await page.getByLabel('טלפון נייד', { exact: true }).fill(complaint.phone)
await page.getByRole('textbox', { name: 'דואר אלקטרוני' }).fill(complaint.email)

console.log('filled first page')

await page.getByRole('button', { name: 'לשלב הבא' }).click()
// await page.getByLabel('נושא הפנייה').getByLabel('בחירה מהרשימה').first().click()
// await new Promise((r) => setTimeout(r, 100))
Expand All @@ -59,9 +55,6 @@ try {
await new Promise((r) => setTimeout(r, 100))
await page.getByText(complaintTypes[0]).click()
await new Promise((r) => setTimeout(r, 100))

console.log('filled second page')

await page.getByRole('button', { name: 'לשלב הבא' }).click()
await page.getByLabel('חברת האוטובוסים (מפעיל)').fill(complaint.operator)
await page.getByRole('textbox', { name: 'מספר רישוי' }).fill(complaint.licensePlate)
Expand All @@ -72,12 +65,9 @@ try {
await page
.getByRole('textbox', { name: 'תוכן הפנייה' })
.fill('האוטובוס עצר בתחנה ולא נסע עד שעה מאוחרת')

await page.getByRole('textbox', { name: 'מספר קו' }).fill(complaint.lineNumber)
await page.getByLabel('מוצא/ יעד (כיוון )').fill(complaint.routeName)

console.log('filled third page')

for (let i = 0; i < 10 && (await page.getByText('הנחיות לצירוף מסמכים').isHidden()); i++) {
// retry until it works
await page.getByRole('button', { name: 'לשלב הבא' }).click()
Expand Down
Loading

0 comments on commit e5f8635

Please sign in to comment.