Repository navigation
109 lines (92 loc) · 4.32 KB
/
Copy pathpytest.yml
File metadata and controls
109 lines (92 loc) · 4.32 KB
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
name: "Test Build"
on:
workflow_dispatch:
push:
branches: [ master, production, itrb-test, dev ]
paths:
- 'code/**'
- 'DockerBuild/**'
- 'requirements.txt'
- '.github/workflows/pytest.yml'
pull_request:
branches: [ master, production, itrb-test, dev ]
paths:
- 'code/**'
- 'DockerBuild/**'
- 'requirements.txt'
- '.github/workflows/pytest.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }} # this is the workflow name and the branch name
cancel-in-progress: true # this is to cancel the in-progress workflow if a new one is started
jobs:
analyze:
name: Analyze
runs-on: [self-hosted, ARAX, docker]
env:
PYTHONPATH: ${{ github.workspace }}/code
permissions:
actions: read
contents: read
security-events: read
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
steps:
- name: Checkout code to RTX directory
uses: actions/checkout@v2
with:
#path: /home/ubuntu/RTX
ref: ${{ github.head_ref || github.ref_name }}
- name: Set up Python environment
uses: RTXteam/setup-python@v4
with:
python-version: '3.12'
- name: Set up config files
run: |
scp araxconfig@araxconfig.rtx.ai:config_secrets.json /mnt/config/config_secrets.json
- name: Download databases into CICD instance
working-directory: ${{ github.workspace }}
# continue-on-error: true
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python code/ARAX/ARAXQuery/ARAX_database_manager.py --mnt --skip-if-exists --remove_unused
# Scoped to this workflow's own container/image only. Other containers on the
# host (such as per-PR preview containers rtx_pr_<N>, see deploy/preview/README.md)
# must survive a CI run. Issue #2846.
- name: Clean up previous rtx_test container and image
continue-on-error: true
run: |
sudo docker rm -f rtx_test 2>/dev/null || echo "No previous rtx_test container"
sudo docker rmi -f rtx:test 2>/dev/null || echo "No previous rtx:test image"
- name: Build docker image
run: sudo docker build --no-cache=true --rm --build-arg "BUILD_BRANCH=${{ github.head_ref || github.ref_name }}" -t rtx:test DockerBuild/ -f DockerBuild/CICD-Dockerfile
- name: Run docker container
run: sudo docker run -d -it --name rtx_test -v /mnt/data/orangeboard/databases:/mnt/data/orangeboard/databases -v /mnt/config/config_secrets.json:/mnt/data/orangeboard/production/RTX/code/config_secrets.json rtx:test
# Without an override the container auto-detects maturity=development and
# queries the dev tier KPs, whose in-progress changes can break every PR (in
# 2026-09 dev Retriever switched to a non TRAPI 1.6 binding format). Staging
# makes CI query the same ci tier KPs as arax.ci, where master deploys.
# Must run before the KP info cache is built, the cache is keyed by maturity.
- name: Pin maturity to staging
run: sudo docker exec rtx_test bash -c "sudo -u rt bash -c 'echo staging > /mnt/data/orangeboard/production/RTX/code/maturity_override.txt'"
- name: Create symlinks
run: sudo docker exec rtx_test bash -c "sudo -u rt bash -c 'cd /mnt/data/orangeboard/production/RTX && python3 code/ARAX/ARAXQuery/ARAX_database_manager.py'"
- name: Build KP info cache
run: sudo docker exec rtx_test bash -c "cd /mnt/data/orangeboard/production/RTX/code/ARAX/ARAXQuery/Expand && python3 kp_info_cacher.py"
- name: Start services
run: |
sudo docker exec rtx_test service apache2 start
sudo docker exec rtx_test service RTX_OpenAPI_production start
sudo docker exec rtx_test service RTX_Complete start
- name: Run tests with pytest
run: sudo docker exec rtx_test bash -c "cd /mnt/data/orangeboard/production/RTX/code/ARAX/test && pytest -v --disable-pytest-warnings"
- name: Remove rtx_test container and image
if: always()
continue-on-error: true
run: |
sudo docker rm -f rtx_test 2>/dev/null || echo "No rtx_test container"
sudo docker rmi -f rtx:test 2>/dev/null || echo "No rtx:test image"
# dangling layers only, never touches tagged images of other containers
sudo docker image prune -f