Skip to content

Commit 5d80c1a

Browse files
authored
Merge pull request #69 from tisnik/lcore-161-added-rest-of-ci-checkers
LCORE-161 - rest of CI checkers
2 parents 2e2f035 + eaf783c commit 5d80c1a

File tree

20 files changed

+174
-2
lines changed

20 files changed

+174
-2
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: List outdated dependencies
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
list_outdated_dependencies:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
pull-requests: read
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.11'
18+
- name: Check Python version
19+
run: python --version
20+
- name: PDM installation
21+
run: pip install --user pdm
22+
- name: List outdated dependencies
23+
run: pdm outdated

.github/workflows/pydocstyle.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Pydocstyle
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
pydocstyle:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
pull-requests: read
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.11'
18+
- name: Python version
19+
run: python --version
20+
- name: Pydocstyle install
21+
run: pip install --user pydocstyle
22+
- name: Python docstring checks
23+
run: pydocstyle -v .

.github/workflows/radon.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Radon
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
radon:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
pull-requests: read
13+
name: "radon"
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: davidslusser/actions_python_radon@v1.0.0
17+
with:
18+
src: "src"
19+
min: "A"
20+
grade: "B"

.github/workflows/shellcheck.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Shell check
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
shellcheck:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
pull-requests: read
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Shell check
16+
run: make shellcheck

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ docs/config.png: docs/config.puml ## Generate an image with configuration graph
3838
mv classes.png config.png && \
3939
popd
4040

41+
shellcheck: ## Run shellcheck
42+
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz" | tar -xJv \
43+
shellcheck --version
44+
shellcheck -- */*.sh
45+

scripts/codecov.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
3+
set -o nounset
4+
set -o pipefail
5+
set -x
6+
7+
CI_SERVER_URL=https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test
8+
COVER_PROFILE=${COVER_PROFILE:-"$1"}
9+
JOB_TYPE=${JOB_TYPE:-"local"}
10+
11+
# Configure the git refs and job link based on how the job was triggered via prow
12+
if [[ "${JOB_TYPE}" == "presubmit" ]]; then
13+
echo "detected PR code coverage job for #${PULL_NUMBER}"
14+
REF_FLAGS="-P ${PULL_NUMBER} -C ${PULL_PULL_SHA}"
15+
JOB_LINK="${CI_SERVER_URL}/pr-logs/pull/${REPO_OWNER}_${REPO_NAME}/${PULL_NUMBER}/${JOB_NAME}/${BUILD_ID}"
16+
elif [[ "${JOB_TYPE}" == "batch" ]] || [[ "${JOB_TYPE}" == "postsubmit" ]]; then
17+
echo "detected branch code coverage job for ${PULL_BASE_REF}"
18+
REF_FLAGS="-B ${PULL_BASE_REF} -C ${PULL_BASE_SHA}"
19+
JOB_LINK="${CI_SERVER_URL}/logs/${JOB_NAME}/${BUILD_ID}"
20+
elif [[ "${JOB_TYPE}" == "local" ]]; then
21+
echo "coverage report available at ${COVER_PROFILE}"
22+
exit 0
23+
else
24+
echo "${JOB_TYPE} jobs not supported" >&2
25+
exit 1
26+
fi
27+
28+
# Configure certain internal codecov variables with values from prow.
29+
export CI_BUILD_URL="${JOB_LINK}"
30+
export CI_BUILD_ID="${JOB_NAME}"
31+
export CI_JOB_ID="${BUILD_ID}"
32+
33+
if [[ "${JOB_TYPE}" != "local" ]]; then
34+
if [[ -z "${ARTIFACT_DIR:-}" ]] || [[ ! -d "${ARTIFACT_DIR}" ]] || [[ ! -w "${ARTIFACT_DIR}" ]]; then
35+
# shellcheck disable=SC2016
36+
echo '${ARTIFACT_DIR} must be set for non-local jobs, and must point to a writable directory' >&2
37+
exit 1
38+
fi
39+
curl -sS https://codecov.io/bash -o "${ARTIFACT_DIR}/codecov.sh"
40+
bash <(cat "${ARTIFACT_DIR}/codecov.sh") -Z -K -f "${COVER_PROFILE}" -r "${REPO_OWNER}/${REPO_NAME}" "${REF_FLAGS}"
41+
# shellcheck disable=SC2181
42+
if [ $? -ne 0 ]; then
43+
echo "Failed uploading coverage report from a non local environment. Exiting gracefully with status code 0."
44+
exit 0
45+
fi
46+
else
47+
bash <(curl -s https://codecov.io/bash) -Z -K -f "${COVER_PROFILE}" -r "${REPO_OWNER}/${REPO_NAME}" "${REF_FLAGS}"
48+
# shellcheck disable=SC2181
49+
if [ $? -ne 0 ]; then
50+
echo "Failed uploading coverage report from local environment. Exiting gracefully with status code 0."
51+
exit 0
52+
fi
53+
fi

src/app/endpoints/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222

2323
@router.get("/config", responses=get_config_responses)
2424
def config_endpoint_handler(request: Request) -> Configuration:
25+
"""Handle requests to the /config endpoint."""
2526
return configuration.configuration

src/app/endpoints/info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222

2323
@router.get("/info", responses=get_into_responses)
2424
def info_endpoint_handler(request: Request) -> InfoResponse:
25+
"""Handle request to the /info endpoint."""
2526
return InfoResponse(name="foo", version=__version__)

src/app/endpoints/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
@router.get("/models", responses=models_responses)
4343
def models_endpoint_handler(request: Request) -> ModelsResponse:
44+
"""Handle requests to the /models endpoint."""
4445
llama_stack_config = configuration.llama_stack_configuration
4546
logger.info("LLama stack config: %s", llama_stack_config)
4647

src/app/endpoints/query.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
def query_endpoint_handler(
3333
request: Request, query_request: QueryRequest
3434
) -> QueryResponse:
35+
"""Handle request to the /query endpoint."""
3536
llama_stack_config = configuration.llama_stack_configuration
3637
logger.info("LLama stack config: %s", llama_stack_config)
3738
client = get_llama_stack_client(llama_stack_config)
@@ -84,7 +85,7 @@ def select_model_id(client: LlamaStackClient, query_request: QueryRequest) -> st
8485
def retrieve_response(
8586
client: LlamaStackClient, model_id: str, query_request: QueryRequest
8687
) -> str:
87-
88+
"""Retrieve response from LLMs and agents."""
8889
available_shields = [shield.identifier for shield in client.shields.list()]
8990
if not available_shields:
9091
logger.info("No available shields. Disabling safety")
@@ -124,6 +125,7 @@ def retrieve_response(
124125

125126
def validate_attachments_metadata(attachments: list[Attachment]) -> None:
126127
"""Validate the attachments metadata provided in the request.
128+
127129
Raises HTTPException if any attachment has an improper type or content type.
128130
"""
129131
for attachment in attachments:

0 commit comments

Comments
 (0)