-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (151 loc) · 5.5 KB
/
workflow.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Run Pytest on Branches
concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true
on:
pull_request:
branches:
- main
push:
branches:
- main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AZURE_STORAGE_ACCOUNT_URL: ${{ secrets.AZURE_STORAGE_ACCOUNT_URL }}
AZURE_STORAGE_ACCOUNT_KEY: ${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }}
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
SLACK_ACCESS_KEY: ${{ secrets.SLACK_ACCESS_KEY }}
DROPBOX_APP_KEY: ${{ secrets.DROPBOX_APP_KEY }}
DROPBOX_APP_SECRET: ${{secrets.DROPBOX_APP_SECRET}}
DROPBOX_REFRESH_TOKEN: ${{secrets.DROPBOX_REFRESH_TOKEN}}
USERNAME_GITHUB: ${{secrets.USERNAME_GITHUB}}
ACCESS_TOKEN_GITHUB: ${{secrets.ACCESS_TOKEN_GITHUB}}
REPOSITORY_NAME_GITHUB: ${{secrets.REPOSITORY_NAME_GITHUB}}
DRIVE_SCOPES: ${{secrets.DRIVE_SCOPES}}
DRIVE_REFRESH_TOKEN: ${{secrets.DRIVE_REFRESH_TOKEN}}
DRIVE_TOKEN: ${{secrets.DRIVE_TOKEN}}
DRIVE_CLIENT_ID: ${{secrets.DRIVE_CLIENT_ID}}
DRIVE_CLIENT_SECRET: ${{secrets.DRIVE_CLIENT_SECRET}}
IMAP_PASSWORD: ${{secrets.IMAP_PASSWORD}}
JIRA_API_TOKEN: ${{secrets.JIRA_API_TOKEN}}
OPENAI_API_KEY: ${{secrets.OPENAI_API_KEY}}
NEWS_API_KEY: ${{secrets.NEWS_API_KEY}}
GOOGLE_BUCKET_PRIVATE_KEY_ID: ${{secrets.GOOGLE_BUCKET_PRIVATE_KEY_ID}}
GOOGLE_BUCKET_PRIVATE_KEY: ${{secrets.GOOGLE_BUCKET_PRIVATE_KEY}}
GOOGLE_BUCKET_CLIENT_ID: ${{secrets.GOOGLE_BUCKET_CLIENT_ID}}
jobs:
pytest:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Check if requirements.txt has changed
id: check-requirements
run: |
git fetch origin main
git diff --quiet origin/main -- requirements.txt || echo "Requirements changed"
continue-on-error: true
- name: Cache Python dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
if: steps.check-requirements.outputs['check-requirements'] == 'Requirements changed'
- name: Apt install dependencies
run: |
sudo apt-get update
sudo apt install tesseract-ocr
sudo apt install libtesseract-dev
sudo apt-get install ffmpeg
sudo apt install antiword
sudo apt install libreoffice
- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}"
- name: "Copy to tmp"
run: |
mkdir -p /tmp/.config/gcloud
cp $GOOGLE_APPLICATION_CREDENTIALS /tmp/.config/gcloud/application_default_credentials.json
- name: "Set up Google Cloud SDK"
uses: "google-github-actions/setup-gcloud@v0.2.0"
with:
project_id: "protocolstreams-ai"
service_account_key: "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}"
export_default_credentials: true
- name: Install curl
run: |
sudo apt-get update
sudo apt-get install curl -y
sudo apt-get install -y jq
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Cache NLTK punkt
id: cache-nltk
uses: actions/cache@v2
with:
path: ~/nltk_data/tokenizers/punkt
key: nltk-punkt-${{ runner.os }}
restore-keys: |
nltk-punkt-${{ runner.os }}
- name: Download NLTK punkt
run: |
python -m nltk.downloader punkt
python -m nltk.downloader wordnet
python -m nltk.downloader stopwords
- name: Cache spaCy large model
id: cache-spacy
uses: actions/cache@v2
with:
path: ~/.cache/spacy
key: spacy-large-${{ runner.os }}
restore-keys: |
spacy-large-${{ runner.os }}
- name: Download spaCy large model
run: |
python -m spacy download en_core_web_lg
# - name: Run Pytest
# run: python -B -m pytest -v --disable-warnings .
# env:
# PYTHONDONTWRITEBYTECODE: 1
- name: Test Code Coverage
run: pytest -s --cov=querent -vv --durations=0
env:
PYTHONDONTWRITEBYTECODE: 1
package:
runs-on: ubuntu-latest
needs: pytest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Package
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install --upgrade wheel setuptools
python setup.py sdist bdist_wheel
- name: Publish to PyPI
run: |
python -m pip install --upgrade pip
pip install --upgrade twine
python -m twine upload dist/* --skip-existing
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}