forked from wise-agents/wise-agents
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (137 loc) · 4.79 KB
/
build-and-test-workflow-run.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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}"