From 22ec6338e67bf0f7714b62158ba5c3873fc21449 Mon Sep 17 00:00:00 2001 From: Jordan Pellizzari Date: Mon, 13 Sep 2021 16:39:44 -0700 Subject: [PATCH] Add dockerized library integration tests (#732) * Add dockerized library integration test * Fix test.yaml after bad merge --- .github/workflows/test.yml | 13 +++++++++++++ .gitignore | 1 + Makefile | 12 +++++++++++- test/library/libtest.dockerfile | 9 +++++++++ test/library/test.sh | 10 ++++++++++ ui/index.ts | 4 ++-- 6 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 test/library/libtest.dockerfile create mode 100755 test/library/test.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 47b1f083af..e3ad8b79a8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -259,3 +259,16 @@ jobs: name: acceptance-test-artifacts path: ${{ env.ARTIFACTS_BASE_DIR }} retention-days: 1 + library-integration-test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25 + - name: Run Library Integration Test + env: + GITHUB_TOKEN: "${{ secrets.github_token }}" + run: make lib-test + + diff --git a/.gitignore b/.gitignore index 9c3305fbcb..e825412923 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ coverage *.lcov ginkgo.report .deps +test/library/wego-library-test diff --git a/Makefile b/Makefile index e3b691ba34..d2cc30c4c2 100644 --- a/Makefile +++ b/Makefile @@ -63,6 +63,7 @@ clean: ## Clean up images and binaries rm -rf coverage rm -rf node_modules rm -f .deps + rm -rf dist fmt: ## Run go fmt against code go fmt ./... @@ -127,7 +128,16 @@ cmd/wego/ui/run/dist/index.html: cmd/wego/ui/run/dist cmd/wego/ui/run/dist/main.js: npm run build -dist/index.js: +# Runs a test to raise errors if the integration between WeGO Core and EE is +# in danger of breaking due to package API changes. +# See the test/library dockerfile and test.sh script for more info. +lib-test: dependencies + docker build -t wego-library-test -f test/library/libtest.dockerfile $(CURRENT_DIR)/test/library + docker run -e GITHUB_TOKEN=$$GITHUB_TOKEN -i --rm \ + -v $(CURRENT_DIR):/go/src/github.com/weaveworks/weave-gitops \ + wego-library-test + +dist/index.js: ui/index.ts npm run build:lib && cp package.json dist dist/index.d.ts: diff --git a/test/library/libtest.dockerfile b/test/library/libtest.dockerfile new file mode 100644 index 0000000000..17c737d02f --- /dev/null +++ b/test/library/libtest.dockerfile @@ -0,0 +1,9 @@ +FROM golang:1.16 +RUN apt-get update +RUN apt-get -y install curl gnupg +RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - +RUN apt-get -y install nodejs +COPY test.sh /test/test.sh +WORKDIR /test +CMD ./test.sh + diff --git a/test/library/test.sh b/test/library/test.sh new file mode 100755 index 0000000000..18f736328d --- /dev/null +++ b/test/library/test.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e +set -x + +git clone https://github.com/weaveworks-gitops-test/wego-library-test.git test/library/wego-library-test +cd test/library/wego-library-test +npm ci +npm run build +go mod tidy +go build main.go diff --git a/ui/index.ts b/ui/index.ts index 9602d209cc..1150482883 100644 --- a/ui/index.ts +++ b/ui/index.ts @@ -1,10 +1,10 @@ +import _LoadingPage from "./components/LoadingPage"; import _AppContextProvider from "./contexts/AppContext"; +import _useApplications from "./hooks/applications"; import { Applications as appsClient } from "./lib/api/applications/applications.pb"; import _Theme from "./lib/theme"; import _ApplicationDetail from "./pages/ApplicationDetail"; import _Applications from "./pages/Applications"; -import _useApplications from "./hooks/applications"; -import _LoadingPage from "./components/LoadingPage"; export const theme = _Theme; export const AppContextProvider = _AppContextProvider;