1- name : python
1+ name : Python CI
22
33on :
44 push :
55 branches : [ main ]
6+ paths :
7+ - ' python/**'
8+ - ' .github/workflows/python-arabic.yml'
69 pull_request :
10+ paths :
11+ - ' python/**'
12+ - ' .github/workflows/python-arabic.yml'
13+
14+ # Cancel in-progress runs for the same workflow and branch
15+ concurrency :
16+ group : ${{ github.workflow }}-${{ github.ref }}
17+ cancel-in-progress : true
18+
19+ permissions :
20+ contents : read
21+ security-events : write
722
823jobs :
24+ dependency-review :
25+ runs-on : ubuntu-latest
26+ if : github.event_name == 'pull_request'
27+ steps :
28+ - name : Checkout code
29+ uses : actions/checkout@v4
30+
31+ - name : Dependency Review
32+ uses : actions/dependency-review-action@v3
33+
34+ codeql :
35+ runs-on : ubuntu-latest
36+ timeout-minutes : 15
37+ steps :
38+ - name : Checkout code
39+ uses : actions/checkout@v4
40+
41+ - name : Initialize CodeQL
42+ uses : github/codeql-action/init@v2
43+ with :
44+ languages : python
45+
46+ - name : Perform CodeQL Analysis
47+ uses : github/codeql-action/analyze@v2
48+
949 infer :
1050 runs-on : ubuntu-latest
51+ timeout-minutes : 10
1152 strategy :
1253 fail-fast : false
1354 matrix :
14- python-version : ['3.6 ', '3.7 ', '3.8 ', '3.9 ']
55+ python-version : ['3.8 ', '3.9 ', '3.10 ', '3.11', '3.12 ']
1556
1657 steps :
17- - uses : actions/checkout@v2
18- - uses : actions/setup-python@v2
19- with :
20- python-version : ${{ matrix.python-version }}
58+ - name : Checkout code
59+ uses : actions/checkout@v4
2160
22- - uses : actions/cache@v2
61+ - name : Set up Python ${{ matrix.python-version }}
62+ uses : actions/setup-python@v5
2363 with :
24- path : ${{ env.pythonLocation }}
25- key : ${{ env.pythonLocation }}-${{ hashFiles('python/arabic/setup.py') }}-${{ hashFiles('python/arabic/requirements.txt') }}
64+ python-version : ${{ matrix.python-version }}
65+ cache : ' pip'
66+ cache-dependency-path : |
67+ python/arabic/requirements.txt
68+ python/arabic/setup.py
2669
2770 - name : Install requirements
2871 working-directory : ./python/arabic
2972 run : |
73+ python -m pip install --upgrade pip
3074 pip install --upgrade --upgrade-strategy eager -r requirements.txt -e .
3175
76+ - name : Create model directory
77+ working-directory : ./python/arabic
78+ run : |
79+ mkdir -p log_dir/CA_MSA.base.cbhg/models/
80+
3281 - name : Download PyTorch model
3382 working-directory : ./python/arabic
3483 run : |
@@ -42,25 +91,29 @@ jobs:
4291
4392 train :
4493 runs-on : ubuntu-latest
94+ timeout-minutes : 20
4595 strategy :
4696 fail-fast : false
4797 matrix :
48- python-version : ['3.6 ', '3.7 ', '3.8 ', '3.9 ']
98+ python-version : ['3.8 ', '3.9 ', '3.10 ', '3.11', '3.12 ']
4999
50100 steps :
51- - uses : actions/checkout@v2
52- - uses : actions/setup-python@v2
53- with :
54- python-version : ${{ matrix.python-version }}
101+ - name : Checkout code
102+ uses : actions/checkout@v4
55103
56- - uses : actions/cache@v2
104+ - name : Set up Python ${{ matrix.python-version }}
105+ uses : actions/setup-python@v5
57106 with :
58- path : ${{ env.pythonLocation }}
59- key : ${{ env.pythonLocation }}-${{ hashFiles('python/setup.py') }}-${{ hashFiles('python/requirements.txt') }}
107+ python-version : ${{ matrix.python-version }}
108+ cache : ' pip'
109+ cache-dependency-path : |
110+ python/arabic/requirements.txt
111+ python/arabic/setup.py
60112
61113 - name : Install requirements
62114 working-directory : ./python/arabic
63115 run : |
116+ python -m pip install --upgrade pip
64117 pip install --upgrade --upgrade-strategy eager -r requirements.txt -e .
65118
66119 - name : Prepare dataset
@@ -78,4 +131,35 @@ jobs:
78131 - name : Try training (WIP)
79132 working-directory : ./python/arabic
80133 run : |
134+ # Fix for Python 3.9+ multiprocessing issue
135+ if [[ "${{ matrix.python-version }}" == "3.9" || "${{ matrix.python-version }}" > "3.9" ]]; then
136+ sed -i '1s/^/import multiprocessing\nif __name__ == "__main__":\n multiprocessing.freeze_support()\n/' train.py
137+ fi
81138 python train.py --model "cbhg" --config config/test_cbhg.yml
139+
140+ security-scan :
141+ runs-on : ubuntu-latest
142+ timeout-minutes : 10
143+ steps :
144+ - name : Checkout code
145+ uses : actions/checkout@v4
146+
147+ - name : Set up Python
148+ uses : actions/setup-python@v5
149+ with :
150+ python-version : ' 3.11'
151+
152+ - name : Install safety
153+ run : |
154+ python -m pip install --upgrade pip
155+ pip install safety
156+
157+ - name : Check for vulnerabilities in Arabic requirements
158+ working-directory : ./python/arabic
159+ run : |
160+ safety check -r requirements.txt --full-report || true
161+
162+ - name : Check for vulnerabilities in Hebrew requirements
163+ working-directory : ./python/hebrew
164+ run : |
165+ safety check -r requirements.txt --full-report || true
0 commit comments