-
Notifications
You must be signed in to change notification settings - Fork 2
154 lines (137 loc) · 4.43 KB
/
test_release.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
name: Python pytest
# do not change name
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
release:
types: [edited, created]
permissions: write-all
jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ['3.8','3.9','3.10','3.11']
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.x
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
pip install poetry==1.8.3
poetry config virtualenvs.create false
poetry check --lock
poetry install --extras sentence_transformers --with test
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: test create shinx docs
# create shpinx api autodocs of hf_hub_ctranslate2 and move them to docs
# makefile: make html build the the docs/_build/html/
run: |
sphinx-apidoc -o ./docs ./hf_hub_ctranslate2
cp README.md ./docs
cd docs
make html
- name: Generate Report
run: |
coverage run -m --source=hf_hub_ctranslate2 pytest tests
coverage xml
- name: Upload coverage to Codecov for python 3.8
if: ${{ matrix.python == '3.10' }}
uses: codecov/codecov-action@v2
deploy_docs:
if: ${{ success() && github.event_name == 'release' }}
needs: build-linux
runs-on: ubuntu-latest
# only run if pytest successfull
steps:
- name: Checkout current branch
uses: actions/checkout@v4
with:
path: 'branch-dir'
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: 'gh-pages'
path: 'gh-pages-dir'
- name: Install dependencies from current branch
run: |
cd branch-dir
pip install poetry==1.8.3
poetry install --extras sentence_transformers --with test
- name: create shinx docs from current branch
# create shpinx api autodocs of opensentiment and move them to docs
# makefile: make html build the the docs/_build/html/
run: |
cd branch-dir
poetry run sphinx-apidoc -o ./docs ./hf_hub_ctranslate2
cp README.md ./docs
cd docs
poetry run make html
- name: merge /docs/_build/ files into gh-pages branch
run: |
# move all files to gh-pages branch
cp -r branch-dir/docs/_build/html/* gh-pages-dir/
cp -r branch-dir/.gitignore gh-pages-dir/
# configure gh-pages-dir / gh-pages branch
ls -a
cd gh-pages-dir
ls -a
# create nojekyll file
touch .nojekyll
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# add local files and untrack
git add .
git commit -m "Update documentation" -a || true
# The above command will fail if no changes were present, so we ignore
# that.
- name: Push changes to github repo/gh-pages
uses: ad-m/github-push-action@master
with:
branch: refs/heads/gh-pages
directory: gh-pages-dir/
deploy_pypi:
needs: deploy_docs
runs-on: ubuntu-latest
name: Build and publish Python 🐍 distributions 📦 to PyPI
permissions:
id-token: write
environment:
name: publish
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install pypa/build
run: |
pip install build --user
- name: Build a binary wheel and a source tarball
run: |
python -m build --sdist --wheel --outdir dist/
# - name: Publish distribution 📦 to Test PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository_url: https://test.pypi.org/legacy/
- name: Publish package distributions to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
verbose: true
print-hash: true