From 3ebd96752c94f92c3eccad3316f87ebba2a77a7a Mon Sep 17 00:00:00 2001 From: Jasper Alexander <84851956+JasperAlexander@users.noreply.github.com> Date: Sat, 27 May 2023 17:38:58 +0200 Subject: [PATCH] Initial commit --- .env | 5 +++++ .github/workflows/test.yml | 32 ++++++++++++++++++++++++++++++++ .gitignore | 19 +++++++++++++++++++ CHANGELOG.md | 6 ++++++ Dockerfile | 4 ++++ LICENSE.md | 21 +++++++++++++++++++++ README.md | 21 +++++++++++++++++++++ action.yml | 17 +++++++++++++++++ entrypoint.sh | 18 ++++++++++++++++++ package.json | 33 +++++++++++++++++++++++++++++++++ test/connection/connection.js | 15 +++++++++++++++ 11 files changed, 191 insertions(+) create mode 100644 .env create mode 100644 .github/workflows/test.yml create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 Dockerfile create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 action.yml create mode 100644 entrypoint.sh create mode 100644 package.json create mode 100644 test/connection/connection.js diff --git a/.env b/.env new file mode 100644 index 0000000..a7a0aa7 --- /dev/null +++ b/.env @@ -0,0 +1,5 @@ +QUERY_DEFAULTS_LIMIT=25 +AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED=true +PERSISTENCE_DATA_PATH=/var/lib/weaviate +DEFAULT_VECTORIZER_MODULE=none +CLUSTER_HOSTNAME=node1 \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..226d68f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,32 @@ +name: Test Weaviate Server + +on: [push, pull_request] + +jobs: + weaviate-action: + name: Start Weaviate Server + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: pnpm/action-setup@v2.0.1 + with: + version: 6.32.2 + + - name: Setup Weaviate + uses: ./ + with: + weaviate-version: 'latest' + weaviate-port: 8080 + + - name: Setup Node.js 16.x + uses: actions/setup-node@v3 + with: + node-version: 16.x + + - name: Install dependencies + run: pnpm install + + - name: Run tests + run: pnpm test ./test/connection diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7fd3912 --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +# dependencies +node_modules +.pnp +.pnp.js +*-lock.* +*.lock + +# testing +coverage + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3cc0658 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +# Changelog + +## 1.0.0 + +### Minor Changes +- Initial release. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..44a65c6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM docker:stable +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..a536a9b --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Jasper Alexander + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..909f886 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Weaviate GitHub Action + +This GitHub Action starts a Weaviate server. You can configure the version an port that are being used. The default version is `latest` and the default port is `8080`. + +## Usage + +```yml +name: Test Weaviate + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Setup Weaviate + uses: JasperAlexander@weaviate-github-action@1.0.0 + with: + - weaviate-version: 'latest' + - weaviate-port: 8080 +``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..37df06d --- /dev/null +++ b/action.yml @@ -0,0 +1,17 @@ +name: 'Weaviate GitHub Action' +description: 'Start a Weaviate server' +inputs: + weaviate-version: + description: 'Weaviate version to use (defaults to latest)' + required: false + default: 'latest' + weaviate-port: + description: 'Weaviate port to use (defaults to 8080)' + required: false + default: 8080 +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.weaviate-version }} + - ${{ inputs.weaviate-port }} diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..98051be --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/sh -l + +WEAVIATE_VERSION=$1 +WEAVIATE_PORT=$2 + +echo "::group::Starting Weaviate" +echo " - version [$WEAVIATE_VERSION]" +echo " - port [$WEAVIATE_PORT]" +echo "" + +docker run --name weaviate --publish $WEAVIATE_PORT:$WEAVIATE_PORT --env-file ./.env --detach semitechnologies/weaviate:$WEAVIATE_VERSION + +if [ $? -ne 0 ]; then + echo "Error starting Weaviate in Docker container" + exit 2 +fi + +echo "::endgroup::" \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..d877fe8 --- /dev/null +++ b/package.json @@ -0,0 +1,33 @@ +{ + "name": "@JasperAlexander/weaviate-github-action", + "version": "1.0.0", + "description": "Weaviate GitHub Action", + "author": "Jasper Alexander", + "license": "MIT", + "homepage": "https://github.com/JasperAlexander/weaviate-github-action", + "keywords": [ + "github", + "github-action", + "weaviate" + ], + "bugs": { + "url": "https://github.com/JasperAlexander/weaviate-github-action/issues" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/JasperAlexander/weaviate-github-action.git" + }, + "scripts": { + "test": "c8 --include=dist uvu --ignore fixtures", + "posttest": "c8 report --reporter=html" + }, + "devDependencies": { + "c8": "^7.13.0", + "graphql": "^16.6.0", + "uvu": "^0.5.6", + "weaviate-ts-client": "^1.3.2" + }, + "engines": { + "node": ">=14.0.0" + } + } \ No newline at end of file diff --git a/test/connection/connection.js b/test/connection/connection.js new file mode 100644 index 0000000..97d2133 --- /dev/null +++ b/test/connection/connection.js @@ -0,0 +1,15 @@ +'use strict' + +const { test } = require('uvu') +const { default: weaviate } = require('weaviate-ts-client') + +test('connects to Weaviate on port 8080', () => { + const weaviateClient = weaviate.client({ + scheme: 'http', + host: 'localhost:8080', + }) + + weaviateClient.misc.metaGetter().do() +}) + +test.run()