Skip to content

Build and Test Workflow Run #73

Build and Test Workflow Run

Build and Test Workflow Run #73

name: Build and Test Workflow Run
on:
workflow_run:
workflows:
- "Build and Test"
types:
- completed
permissions:
checks: write
statuses: write
# Only run the latest job
concurrency:
group: '${{ github.workflow }} - ${{ github.event.workflow_run.event }}: ${{ github.event.workflow_run.head_repository.full_name }}@${{ github.event.workflow_run.head_branch }}'
cancel-in-progress: true
env:
TEST_NAME: Build and Test Workflow Run
# Common for the tests
POD_CONTAINER: docker
EXTRA_CONTAINER_OPTION: "--detach"
# Env vars to configure Stomp
STOMP_USER: artemis
STOMP_PASSWORD: artemis
# Env vars to configure the Neo4j db. Currently, these values are hardcoded in the tests
NEO4J_USERNAME: neo4j
NEO4J_PASSWORD: neo4jpassword
NEO4J_DATABASE: neo4j
# Env vars to configure the PgVector db. Currently, these values are hardcoded in the tests
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
# Keys/tokens for external models
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(job) }}
run: echo "$JOB_CONTEXT"
- uses: actions/download-artifact@v4
with:
name: .job-env
github-token: ${{ github.token }}
run-id: ${{ github.event.workflow_run.id }}
- name: Read environment variables from the previous job
run: |
text="$(cat .job-env)"
echo "${text}"
echo "${text}" >> "$GITHUB_ENV"
- name: Report check is starting
if: env.PR_NUMBER != 'push'
env:
GH_TOKEN: ${{ github.token }}
run: |
JSON_STRING=$(jq -c -n \
--arg state "pending" \
--arg tgt "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
--arg desc "Running tests" \
'{state: $state, target_url: $tgt, description: $desc, context: "Build and Test Workflow Run/build (workflow_run)"}' )
curl -L -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GH_TOKEN}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA }} \
-d "${JSON_STRING}"
- uses: actions/checkout@v4
with:
ref: ${{ env.GITHUB_SHA }}
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Update pip
run: |
python -m pip install --upgrade pip
- name: Start Neo4j graph db
working-directory: graphdb
run: |
./run_graphdb.sh &
- name: Start PGVector vector db
working-directory: vectordb
run: |
./run_vectordb.sh &
- name: Start Artemis
working-directory: artemis
run: |
./artemis.sh &
- name: Start Redis
working-directory: redis
run: |
./run_redis.sh &
- name: Install wise-agents dependencies
run: |
pip install .
pip install -e '.[test]'
- name: Test with pytest
run: |
pytest --log-cli-level=DEBUG -m "not needsllm and not needsllama"
- name: Save success
if: ${{ always() }} && env.PR_NUMBER != 'push'
env:
GH_TOKEN: ${{ github.token }}
run: |
STATUS=${{ job.status }}
if [ "${STATUS}" == "cancelled" ]; then
STATUS="failure"
TEXT="The job was cancelled"
elif [ "${STATUS}" == "success" ]; then
TEXT="The job passed!"
elif [ "${STATUS}" == "failure" ]; then
TEXT="The job failed"
else
STATUS = "failure"
TEXT="The job was not successful"
fi
JSON_STRING=$(jq -c -n \
--arg state "${STATUS}" \
--arg tgt "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
--arg desc "${TEXT}" \
'{state: $state, target_url: $tgt, description: $desc, context: "Build and Test Workflow Run/build (workflow_run)"}' )
curl -L -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GH_TOKEN}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA }} \
-d "${JSON_STRING}"