diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index de6d98d1400..677d0ef98ab 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -7,8 +7,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ "3.8", "3.9", "3.10" ] - os: [ ubuntu-latest, macOS-latest ] + python-version: ["3.8", "3.9", "3.10"] + os: [ubuntu-latest, macOS-latest] exclude: - os: macOS-latest python-version: "3.9" @@ -31,7 +31,7 @@ jobs: with: go-version: 1.18.0 - name: Install mysql on macOS - if: startsWith(matrix.os, 'macOS') + if: startsWith(matrix.os, 'macOS') run: | brew install mysql PATH=$PATH:/usr/local/mysql/bin @@ -57,12 +57,12 @@ jobs: - name: Install apache-arrow on ubuntu if: matrix.os == 'ubuntu-latest' run: | - sudo apt update - sudo apt install -y -V ca-certificates lsb-release wget - wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb - sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb - sudo apt update - sudo apt install -y -V libarrow-dev + sudo apt update + sudo apt install -y -V ca-certificates lsb-release wget + wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb + sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb + sudo apt update + sudo apt install -y -V libarrow-dev - name: Install apache-arrow on macos if: matrix.os == 'macOS-latest' run: brew install apache-arrow @@ -100,11 +100,31 @@ jobs: go-version: 1.18.0 - name: Install apache-arrow on ubuntu run: | - sudo apt update - sudo apt install -y -V ca-certificates lsb-release wget - wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb - sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb - sudo apt update - sudo apt install -y -V libarrow-dev + sudo apt update + sudo apt install -y -V ca-certificates lsb-release wget + wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb + sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb + sudo apt update + sudo apt install -y -V libarrow-dev - name: Test run: make test-go + + unit-test-ui: + runs-on: ubuntu-latest + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: "17.x" + registry-url: "https://registry.npmjs.org" + - name: Install yarn dependencies + working-directory: ./ui + run: yarn install + - name: Build yarn rollup + working-directory: ./ui + run: yarn build:lib + - name: Run yarn tests + working-directory: ./ui + run: yarn test --watchAll=false diff --git a/ui/package.json b/ui/package.json index 7d50b3e086b..b607c426635 100644 --- a/ui/package.json +++ b/ui/package.json @@ -48,11 +48,11 @@ "use-query-params": "^1.2.3" }, "scripts": { - "start": "npm run generate-protos && react-scripts start", - "build": "npm run generate-protos && react-scripts build", - "build:lib": "npm run generate-protos && rimraf ./dist && tsc && rollup -c", - "build:lib-dev": "npm run generate-protos && rimraf ./dist && tsc && rollup -c && yalc publish -f", - "test": "npm run generate-protos && react-scripts test", + "start": "yarn run generate-protos && react-scripts start", + "build": "yarn run generate-protos && react-scripts build", + "build:lib": "yarn run generate-protos && rimraf ./dist && tsc && rollup -c", + "build:lib-dev": "yarn run generate-protos && rimraf ./dist && tsc && rollup -c && yalc publish -f", + "test": "yarn run generate-protos && react-scripts test", "eject": "react-scripts eject", "generate-protos": "pbjs --no-encode -o src/protos.js -w commonjs -t static-module `find ../protos/feast/ -iname *.proto` && pbts -n protos -o src/protos.d.ts src/protos.js" }, diff --git a/ui/src/FeastUISansProviders.test.tsx b/ui/src/FeastUISansProviders.test.tsx index 09985bc1338..cd0e4fe5465 100644 --- a/ui/src/FeastUISansProviders.test.tsx +++ b/ui/src/FeastUISansProviders.test.tsx @@ -15,7 +15,11 @@ import { creditHistoryRegistry, } from "./mocks/handlers"; -import registry from "../public/registry.json"; +import { feast } from "./protos"; + +import fs from 'fs'; + +const registry = feast.core.Registry.decode(fs.readFileSync("./public/registry.db")); // declare which API requests to mock const server = setupServer( @@ -50,7 +54,7 @@ test("full app rendering", async () => { // Explore Panel Should Appear expect(screen.getByText(/Explore this Project/i)).toBeInTheDocument(); - const projectNameRegExp = new RegExp(registry.project, "i"); + const projectNameRegExp = new RegExp(registry.projectMetadata[0].project!, "i"); // It should load the default project, which is credit_scoring_aws await waitFor(() => { @@ -95,9 +99,10 @@ test("routes are reachable", async () => { } }); - -const featureViewName = registry.featureViews[0].spec.name; -const featureName = registry.featureViews[0].spec.features[0].name; +const featureView: feast.core.IFeatureView = registry.featureViews[0]; +const featureViewName = featureView.spec?.name!; +const feature: feast.core.IFeatureSpecV2 = featureView.spec?.features![0]!; +const featureName = feature.name!; test("features are reachable", async () => { render(); diff --git a/ui/src/mocks/handlers.ts b/ui/src/mocks/handlers.ts index e7b0040f0dc..865cd50a3fd 100644 --- a/ui/src/mocks/handlers.ts +++ b/ui/src/mocks/handlers.ts @@ -1,5 +1,8 @@ import { rest } from "msw"; -import registry from "../../public/registry.json"; + +import fs from 'fs'; + +const registry = fs.readFileSync("./public/registry.db"); const projectsListWithDefaultProject = rest.get( "/projects-list.json", @@ -14,7 +17,7 @@ const projectsListWithDefaultProject = rest.get( description: "Project for credit scoring team and associated models.", id: "credit_score_project", - registryPath: "/registry.json", + registryPath: "/registry.db", }, ], }) @@ -22,8 +25,8 @@ const projectsListWithDefaultProject = rest.get( } ); -const creditHistoryRegistry = rest.get("/registry.json", (req, res, ctx) => { - return res(ctx.status(200), ctx.json(registry)); +const creditHistoryRegistry = rest.get("/registry.db", (req, res, ctx) => { + return res(ctx.status(200), ctx.body(registry)); }); export { projectsListWithDefaultProject, creditHistoryRegistry };