Skip to content

Commit d3c58b5

Browse files
committed
update ci to use super-linter and push to both quay-repos
1 parent 6f62ccc commit d3c58b5

26 files changed

+418
-270
lines changed

.env

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@ TEMP_DIR=/tmp
55
LOG_LEVEL=info
66

77
# === Git Repo Document Sources ===
8-
REPO_SOURCES=[{"repo": "https://github.com/RHEcosystemAppEng/llm-on-openshift.git", "globs": ["examples/notebooks/langchain/rhods-doc/*.pdf"]}]
8+
REPO_SOURCES='[{"repo": "https://github.com/RHEcosystemAppEng/llm-on-openshift.git", "globs": ["examples/notebooks/langchain/rhods-doc/*.pdf"]}]'
99

1010
# === Web Document Sources ===
11-
WEB_SOURCES=["https://ai-on-openshift.io/getting-started/openshift/", "https://ai-on-openshift.io/getting-started/opendatahub/", "https://ai-on-openshift.io/getting-started/openshift-ai/", "https://ai-on-openshift.io/odh-rhoai/configuration/", "https://ai-on-openshift.io/odh-rhoai/custom-notebooks/", "https://ai-on-openshift.io/odh-rhoai/nvidia-gpus/", "https://ai-on-openshift.io/odh-rhoai/custom-runtime-triton/", "https://ai-on-openshift.io/odh-rhoai/openshift-group-management/", "https://ai-on-openshift.io/tools-and-applications/minio/minio/"]
11+
WEB_SOURCES='["https://ai-on-openshift.io/getting-started/openshift/", "https://ai-on-openshift.io/getting-started/opendatahub/", "https://ai-on-openshift.io/getting-started/openshift-ai/", "https://ai-on-openshift.io/odh-rhoai/configuration/", "https://ai-on-openshift.io/odh-rhoai/custom-notebooks/", "https://ai-on-openshift.io/odh-rhoai/nvidia-gpus/", "https://ai-on-openshift.io/odh-rhoai/custom-runtime-triton/", "https://ai-on-openshift.io/odh-rhoai/openshift-group-management/", "https://ai-on-openshift.io/tools-and-applications/minio/minio/"]'
1212

1313
# === General Embedding Config ===
14-
CHUNK_SIZE=1024
1514
CHUNK_OVERLAP=40
15+
CHUNK_SIZE=1024
1616
DB_TYPE=DRYRUN
1717
EMBEDDING_MODEL=sentence-transformers/all-mpnet-base-v2
1818

1919
# === Redis ===
20-
REDIS_URL=redis://localhost:6379
2120
REDIS_INDEX=docs
21+
REDIS_URL=redis://localhost:6379
2222

2323
# === Elasticsearch ===
24-
ELASTIC_URL=http://localhost:9200
2524
ELASTIC_INDEX=docs
26-
ELASTIC_USER=elastic
2725
ELASTIC_PASSWORD=changeme
26+
ELASTIC_URL=http://localhost:9200
27+
ELASTIC_USER=elastic
2828

2929
# === PGVector ===
30-
PGVECTOR_URL=postgresql+psycopg://user:pass@localhost:5432/mydb
3130
PGVECTOR_COLLECTION_NAME=documents
31+
PGVECTOR_URL=postgresql+psycopg://user:pass@localhost:5432/mydb
3232

3333
# === SQL Server ===
3434
MSSQL_CONNECTION_STRING="Driver={ODBC Driver 18 for SQL Server}; Server=localhost,1433; Database=embeddings; UID=sa; PWD=StrongPassword!; TrustServerCertificate=yes; Encrypt=no;"
3535
MSSQL_TABLE=docs
3636

3737
# === Qdrant ===
38-
QDRANT_URL=http://localhost:6333
3938
QDRANT_COLLECTION=embedded_docs
39+
QDRANT_URL=http://localhost:6333

.github/linters/.hadolint.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ignored:
2+
# Always tag the version of an image explicitly
3+
- DL3006
4+
# Using latest is prone to errors if the image will ever update. Pin the version explicitly to a release tag
5+
- DL3007
6+
# Specify version with `dnf install -y <package>-<version>`.
7+
- DL3041
8+
# Pin versions in pip. Instead of `pip install <package>` use `pip install <package>==<version>` or `pip install --requirement <requirements file>`
9+
- DL3013

.github/linters/.isort.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[settings]
2+
profile = "black"

.github/linters/.jscpd.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ignore": ["**/.github/**"]
3+
}

.github/linters/.python-lint

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[MESSAGES CONTROL]
2+
disable=
3+
too-few-public-methods,
4+
broad-exception-caught,
5+
import-error

.github/workflows/ci-pipeline.yaml

Lines changed: 112 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,81 @@
1-
name: CI Pipeline
1+
name: Build and push to quay
22

33
on:
44
pull_request:
5+
branches: [main]
56
push:
67
branches: [main]
78
tags:
8-
- "v*"
9+
- "v*.*.*"
910

10-
jobs:
11-
lint:
12-
runs-on: ubuntu-latest
13-
steps:
14-
- uses: actions/checkout@v4
15-
- uses: actions/setup-python@v5
16-
with:
17-
python-version: "3.12"
18-
- run: pip install black isort ruff
19-
- run: black --check .
20-
- run: isort --check-only .
21-
- run: ruff check .
11+
permissions:
12+
contents: read
13+
14+
env:
15+
REGISTRY: localhost
16+
NAME: vector-embedder
17+
TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || (github.ref_name == 'main' && 'latest' || github.ref_name) }}
2218

23-
build:
19+
jobs:
20+
build-container:
2421
runs-on: ubuntu-latest
25-
needs: lint
26-
outputs:
27-
image_tag: ${{ steps.meta.outputs.sha_tag }}
28-
steps:
29-
- uses: actions/checkout@v4
3022

31-
- name: Generate tag
32-
id: meta
33-
run: echo "sha_tag=sha-${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
23+
permissions:
24+
contents: read
3425

35-
- name: Build Docker image
36-
uses: docker/build-push-action@v5
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v5
3729
with:
38-
context: .
39-
file: ./Containerfile
40-
load: true
41-
tags: test-image:${{ steps.meta.outputs.sha_tag }}
30+
fetch-depth: 0
31+
persist-credentials: false
4232

43-
- name: Save image as artifact
44-
run: docker save test-image:${{ steps.meta.outputs.sha_tag }} -o image.tar
33+
- name: Build container and push to local registry
34+
env:
35+
CONTAINER: ${{ env.NAME }}:${{ env.TAG }}
36+
run: |
37+
make build
38+
podman push "${CONTAINER}" "docker-archive:/tmp/image.tar:${CONTAINER}"
4539
4640
- name: Upload image artifact
4741
uses: actions/upload-artifact@v4
4842
with:
49-
name: test-image
50-
path: image.tar
43+
name: image-${{ github.run_id }}
44+
path: /tmp/image.tar
45+
retention-days: 1
5146

5247
test:
53-
needs: [lint, build]
54-
runs-on: ubuntu-latest
48+
needs: [build-container]
49+
if: github.event_name == 'pull_request'
5550
strategy:
5651
fail-fast: false
5752
matrix:
5853
db: [pgvector, redis, elastic, qdrant, mssql]
5954

55+
runs-on: ubuntu-latest
56+
permissions:
57+
contents: read
58+
6059
steps:
61-
- uses: actions/checkout@v4
60+
- name: Checkout code
61+
uses: actions/checkout@v5
62+
with:
63+
fetch-depth: 0
64+
persist-credentials: false
6265

63-
- name: Download image artifact
64-
uses: actions/download-artifact@v4
66+
- name: Download image
67+
uses: actions/download-artifact@v5
6568
with:
66-
name: test-image
67-
path: .
69+
name: image-${{ github.run_id }}
70+
path: /tmp
6871

69-
- name: Load Docker image
70-
run: docker load -i image.tar
72+
- name: Load image into local containers-storage
73+
run: podman pull docker-archive:/tmp/image.tar
7174

7275
- name: Start MSSQL
7376
if: matrix.db == 'mssql'
7477
run: |
75-
docker run -d --name mssql-vector-test \
78+
podman run -d --name mssql-vector-test \
7679
-e "ACCEPT_EULA=Y" \
7780
-e "SA_PASSWORD=StrongPassword!" \
7881
-p 1433:1433 \
@@ -81,7 +84,7 @@ jobs:
8184
- name: Start PGVector
8285
if: matrix.db == 'pgvector'
8386
run: |
84-
docker run -d --name pgvector-test \
87+
podman run -d --name pgvector-test \
8588
-e POSTGRES_USER=user \
8689
-e POSTGRES_PASSWORD=pass \
8790
-e POSTGRES_DB=mydb \
@@ -91,14 +94,14 @@ jobs:
9194
- name: Start Redis
9295
if: matrix.db == 'redis'
9396
run: |
94-
docker run -d --name redis-test \
97+
podman run -d --name redis-test \
9598
-p 6379:6379 \
9699
redis/redis-stack-server:6.2.6-v19
97100
98101
- name: Start Elasticsearch
99102
if: matrix.db == 'elastic'
100103
run: |
101-
docker run -d --name es-test \
104+
podman run -d --name es-test \
102105
-e "discovery.type=single-node" \
103106
-e "xpack.security.enabled=true" \
104107
-e "ELASTIC_PASSWORD=changeme" \
@@ -109,53 +112,86 @@ jobs:
109112
- name: Start Qdrant
110113
if: matrix.db == 'qdrant'
111114
run: |
112-
docker run -d --name qdrant-test \
115+
podman run -d --name qdrant-test \
113116
-p 6333:6333 \
114117
qdrant/qdrant
115118
116119
- name: Wait for DB to start
117120
run: sleep 30
118121

119122
- name: Run embed job
123+
env:
124+
CONTAINER: ${{ env.NAME }}:${{ env.TAG }}
125+
DB_TYPE: ${{ matrix.db }}
120126
run: |
121-
docker run --rm --network host \
127+
podman run --rm --network host \
122128
-e LOG_LEVEL=debug \
123-
-e DB_TYPE=${{ matrix.db }} \
124-
test-image:${{ needs.build.outputs.image_tag }}
129+
-e DB_TYPE="${DB_TYPE}" \
130+
"${REGISTRY}/${CONTAINER}"
131+
132+
push-container:
133+
needs: [build-container]
134+
if: github.event_name != 'pull_request'
135+
strategy:
136+
matrix:
137+
include:
138+
- upload_registry: quay.io/validatedpatterns
139+
legacy: false
140+
- upload_registry: quay.io/hybridcloudpatterns
141+
legacy: true
125142

126-
release:
127-
if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && github.event.repository.fork == false
128143
runs-on: ubuntu-latest
129-
needs: [lint, build, test]
130-
steps:
131-
- uses: actions/checkout@v4
144+
permissions:
145+
contents: read
146+
# This is used to complete the identity challenge
147+
# with sigstore/fulcio when running outside of PRs.
148+
id-token: write
132149

133-
- name: Log in to Quay.io
134-
uses: docker/login-action@v3
150+
steps:
151+
- name: Checkout code
152+
uses: actions/checkout@v5
135153
with:
136-
registry: quay.io
137-
username: ${{ secrets.QUAY_USERNAME }}
138-
password: ${{ secrets.QUAY_PASSWORD }}
154+
fetch-depth: 0
155+
persist-credentials: false
139156

140-
- name: Download image artifact
141-
uses: actions/download-artifact@v4
157+
- name: Download image
158+
uses: actions/download-artifact@v5
142159
with:
143-
name: test-image
144-
path: .
160+
name: image-${{ github.run_id }}
161+
path: /tmp
145162

146-
- name: Load Docker image
147-
run: docker load -i image.tar
163+
- name: Load image into local containers-storage
164+
run: podman pull docker-archive:/tmp/image.tar
148165

149-
- name: Tag and push image
166+
- name: Log into Quay
167+
env:
168+
USERNAME: ${{ matrix.legacy && secrets.LEGACY_QUAY_USERNAME || secrets.QUAY_USERNAME }}
169+
PASSWORD: ${{ matrix.legacy && secrets.LEGACY_QUAY_PASSWORD || secrets.QUAY_PASSWORD }}
150170
run: |
151-
docker tag test-image:${{ needs.build.outputs.image_tag }} quay.io/hybridcloudpatterns/vector-embedder:${{ needs.build.outputs.image_tag }}
171+
podman login -u "${USERNAME}" -p "${PASSWORD}" quay.io
152172
153-
if [[ $GITHUB_REF == refs/tags/* ]]; then
154-
docker tag test-image:${{ needs.build.outputs.image_tag }} quay.io/hybridcloudpatterns/vector-embedder:${GITHUB_REF#refs/tags/}
155-
docker push quay.io/hybridcloudpatterns/vector-embedder:${GITHUB_REF#refs/tags/}
156-
elif [[ $GITHUB_REF == refs/heads/main ]]; then
157-
docker tag test-image:${{ needs.build.outputs.image_tag }} quay.io/hybridcloudpatterns/vector-embedder:latest
158-
docker push quay.io/hybridcloudpatterns/vector-embedder:latest
159-
fi
173+
- name: Push image to Quay
174+
id: image-push
175+
env:
176+
UPLOADREGISTRY: ${{ matrix.upload_registry }}
177+
CONTAINER: ${{ env.NAME }}:${{ env.TAG }}
178+
run: |
179+
make upload
180+
DIGEST=$(skopeo inspect --format "{{.Digest}}" "docker://${UPLOADREGISTRY}/${CONTAINER}")
181+
echo "digest=$DIGEST" >> "$GITHUB_OUTPUT"
160182
161-
docker push quay.io/hybridcloudpatterns/vector-embedder:${{ needs.build.outputs.image_tag }}
183+
- name: Install cosign
184+
uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
185+
with:
186+
cosign-release: "v2.2.4"
187+
188+
# Cosign expects the docker config.json for registry authentication so we must
189+
# copy it from buildah
190+
- name: Sign the published Docker image
191+
env:
192+
CONTAINER: ${{ env.NAME }}:${{ env.TAG }}
193+
DIGEST: ${{ steps.image-push.outputs.digest }}
194+
UPLOADREGISTRY: ${{ matrix.upload_registry }}
195+
run: |
196+
cat "${XDG_RUNTIME_DIR}/containers/auth.json" > ~/.docker/config.json
197+
cosign sign --yes "${UPLOADREGISTRY}/${CONTAINER}@${DIGEST}"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Super linter
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
lint:
12+
uses: validatedpatterns/github-actions-library/.github/workflows/superlinter.yml@v1
13+
with:
14+
sl_env: |
15+
VALIDATE_TRIVY=false
16+
VALIDATE_PYTHON_ISORT=false

Containerfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
FROM registry.access.redhat.com/ubi9/python-312:9.5
1+
FROM registry.access.redhat.com/ubi10/python-312-minimal:10.0
22

33
USER root
4+
45
WORKDIR /app
56

6-
RUN dnf install -y \
7+
RUN microdnf install -y git \
78
unixODBC \
89
unixODBC-devel && \
910
curl -sSL https://packages.microsoft.com/config/rhel/9/prod.repo -o /etc/yum.repos.d/mssql-release.repo && \
10-
ACCEPT_EULA=Y dnf install -y msodbcsql18 && \
11-
dnf clean all
11+
ACCEPT_EULA=Y microdnf install -y msodbcsql18 && \
12+
microdnf clean all
1213

1314
COPY requirements.txt .
14-
RUN pip install --upgrade pip && \
15-
pip install -r requirements.txt
15+
RUN pip install --no-cache-dir --upgrade pip && \
16+
pip install \
17+
--no-cache-dir \
18+
--compile \
19+
-r requirements.txt
1620

1721
COPY vector_db ./vector_db
1822
COPY loaders ./loaders
@@ -24,4 +28,4 @@ RUN chown -R 1001:0 .
2428

2529
USER 1001
2630

27-
CMD ./embed_documents.py
31+
CMD ["python", "./embed_documents.py"]

0 commit comments

Comments
 (0)