-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from weaviate/weaviate-version-in-image
Add weaviate-version-in-image composite action.
- Loading branch information
Showing
3 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: weaviate-version-in-image | ||
description: 'Retrieves the Weaviate version from a given Weaviate Docker image.' | ||
inputs: | ||
image_tag: | ||
description: 'The Weaviate Docker image to retrieve the version from.' | ||
required: true | ||
default: 'latest' | ||
registry: | ||
description: 'The Docker registry and namespace to pull the image from.' | ||
required: false | ||
default: 'docker.io/semitechnologies/weaviate' | ||
outputs: | ||
weaviate_version: | ||
description: 'The Weaviate version retrieved from the image.' | ||
value: ${{ steps.set-weaviate-version.outputs.weaviate_version }} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Set globals | ||
id: globals | ||
shell: bash | ||
run: | | ||
echo "action_timeout=300" >> "${GITHUB_OUTPUT}" | ||
echo "action_port=8080" >> "${GITHUB_OUTPUT}" | ||
- name: Start Weaviate service | ||
shell: bash | ||
id: start-docker-container | ||
run: | | ||
CONTAINER_ID=$(docker run -d --rm \ | ||
--name weaviate_service \ | ||
-p ${{ steps.globals.outputs.action_port}}:8080 \ | ||
${{ inputs.registry }}:${{ inputs.image_tag }} \ | ||
--host 0.0.0.0 \ | ||
--port 8080 \ | ||
--scheme http \ | ||
--write-timeout 600s) | ||
echo "Container ID: $CONTAINER_ID" | ||
echo "container_id=$CONTAINER_ID" >> "${GITHUB_OUTPUT}" | ||
- name: Wait for .well-known/ready API to be ready | ||
shell: bash | ||
id: wait-for-ready | ||
run: | | ||
start_time=$(date +%s) | ||
timeout=${{ steps.globals.outputs.action_timeout }} | ||
until [ "$(curl -w '%{http_code}' -s -o /dev/null http://localhost:${{ steps.globals.outputs.action_port}}/v1/.well-known/ready)" -eq 200 ]; do | ||
current_time=$(date +%s) | ||
elapsed_time=$((current_time - start_time)) | ||
if [ "$elapsed_time" -ge "$timeout" ]; then | ||
echo "Timeout of $timeout seconds reached. Exiting..." | ||
exit 1 | ||
fi | ||
echo "Waiting for Weaviate service to be ready..." | ||
sleep 5 | ||
done | ||
- name: Set the Weaviate version as an output | ||
id: set-weaviate-version | ||
shell: bash | ||
run: | | ||
WEAVIATE_VERSION=$(curl http://localhost:${{ steps.globals.outputs.action_port}}/v1/meta | jq -r '.version') | ||
echo "Found weaviate version: $WEAVIATE_VERSION" | ||
echo "weaviate_version=$WEAVIATE_VERSION" >> "${GITHUB_OUTPUT}" | ||
- name: Clean up Docker container | ||
if: always() | ||
shell: bash | ||
run: | | ||
docker rm -f ${{ steps.start-docker-container.outputs.container_id }} || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: Test Weaviate Version in Image Action | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
basic-image: | ||
runs-on: ubuntu-latest | ||
env: | ||
IMAGE_TAG: "1.27.0" | ||
EXPECTED: "1.27.0" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Test weaviate-version-in-image action | ||
id: weaviate-version-in-image | ||
uses: ./.github/actions/weaviate-version-in-image | ||
with: | ||
image_tag: ${{ env.IMAGE_TAG }} | ||
- name: Verify that the retrieved version matches the expected one | ||
run: | | ||
echo "Expected: ${{ env.EXPECTED }}" | ||
echo "Actual: ${{ steps.weaviate-version-in-image.outputs.weaviate_version }}" | ||
if [ "${{ env.EXPECTED }}" != "${{ steps.weaviate-version-in-image.outputs.weaviate_version }}" ]; then | ||
echo "The retrieved version does not match the expected one." | ||
exit 1 | ||
fi | ||
stable-image: | ||
runs-on: ubuntu-latest | ||
env: | ||
IMAGE_TAG: "stable-v1.25-b3bc753" | ||
EXPECTED: "1.25.21" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Test weaviate-version-in-image action | ||
id: weaviate-version-in-image | ||
uses: ./.github/actions/weaviate-version-in-image | ||
with: | ||
image_tag: ${{ env.IMAGE_TAG }} | ||
- name: Verify that the retrieved version matches the expected one | ||
run: | | ||
echo "Expected: ${{ env.EXPECTED }}" | ||
echo "Actual: ${{ steps.weaviate-version-in-image.outputs.weaviate_version }}" | ||
if [ "${{ env.EXPECTED }}" != "${{ steps.weaviate-version-in-image.outputs.weaviate_version }}" ]; then | ||
echo "The retrieved version does not match the expected one." | ||
exit 1 | ||
fi | ||
main-image: | ||
runs-on: ubuntu-latest | ||
env: | ||
IMAGE_TAG: "main-f759849" | ||
EXPECTED: "1.27.0-rc.0" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Test weaviate-version-in-image action | ||
id: weaviate-version-in-image | ||
uses: ./.github/actions/weaviate-version-in-image | ||
with: | ||
image_tag: ${{ env.IMAGE_TAG }} | ||
- name: Verify that the retrieved version matches the expected one | ||
run: | | ||
echo "Expected: ${{ env.EXPECTED }}" | ||
echo "Actual: ${{ steps.weaviate-version-in-image.outputs.weaviate_version }}" | ||
if [ "${{ env.EXPECTED }}" != "${{ steps.weaviate-version-in-image.outputs.weaviate_version }}" ]; then | ||
echo "The retrieved version does not match the expected one." | ||
exit 1 | ||
fi | ||
preview-image: | ||
runs-on: ubuntu-latest | ||
env: | ||
IMAGE_TAG: "preview--hnsw-pq-bq-prefill-compressed-vector-cache-in-parallel-d351d51" | ||
EXPECTED: "1.25.21" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Test weaviate-version-in-image action | ||
id: weaviate-version-in-image | ||
uses: ./.github/actions/weaviate-version-in-image | ||
with: | ||
image_tag: ${{ env.IMAGE_TAG }} | ||
- name: Verify that the retrieved version matches the expected one | ||
run: | | ||
echo "Expected: ${{ env.EXPECTED }}" | ||
echo "Actual: ${{ steps.weaviate-version-in-image.outputs.weaviate_version }}" | ||
if [ "${{ env.EXPECTED }}" != "${{ steps.weaviate-version-in-image.outputs.weaviate_version }}" ]; then | ||
echo "The retrieved version does not match the expected one." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,44 @@ | ||
# github-common-actions | ||
Reusable composite actions used from other Weaviate workflows to avoid code duplication | ||
|
||
## weaviate-version-in-image | ||
|
||
### Description | ||
Retrieves the Weaviate version from a given Weaviate Docker image. | ||
|
||
### Inputs | ||
- `image_tag` (required): The Weaviate Docker image to retrieve the version from. Default: `latest`. | ||
- `registry` (optional): The Docker registry and namespace to pull the image from. Default: `docker.io/semitechnologies/weaviate`. | ||
|
||
### Outputs | ||
- `weaviate_version`: The Weaviate version from the image tag. | ||
|
||
### Usage | ||
```yaml | ||
name: Retrieve Weaviate Version | ||
on: [push] | ||
|
||
jobs: | ||
retrieve-version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Retrieve Weaviate Version | ||
uses: ./.github/actions/weaviate-version-in-image | ||
id: weaviate-version | ||
with: | ||
image_tag: 'latest' | ||
registry: 'docker.io/semitechnologies/weaviate' | ||
|
||
- name: Output Weaviate Version | ||
run: echo "Weaviate Version: ${{ steps.weaviate-version.outputs.weaviate_version }}" | ||
``` | ||
### Runs | ||
This action runs using `composite` with the following steps: | ||
1. **Set globals**: Sets global variables for action timeout and port. | ||
2. **Start Weaviate service**: Starts the Weaviate Docker container. | ||
3. **Wait for .well-known/ready API to be ready**: Waits until the Weaviate service is ready. | ||
4. **Set the Weaviate version as an output**: Retrieves and sets the Weaviate version as an output. |