-
Notifications
You must be signed in to change notification settings - Fork 356
136 lines (133 loc) · 4.74 KB
/
every_commit.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
name: facebookresearch/nevergrad/every_commit
on:
push:
branches:
- main
pull_request:
jobs:
install:
runs-on: ubuntu-latest
permissions:
id-token: write
pages: write
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- uses: actions/checkout@v4.1.0
- name: restore_cache
uses: actions/cache@v3.3.2
with:
key: v4-dependencies-main-{{ checksum "requirements/main.txt"}}
path: "./venv"
restore-keys: v4-dependencies-main-{{ checksum "requirements/main.txt"}}
- name: "[no-extra] Install dependencies"
run: |
rm -rf venv && python3 -m venv venv
. venv/bin/activate
pip install --progress-bar off pip==23.2
pip install --progress-bar off -e .
- name: "[no-extra] Print installation"
run: |
. venv/bin/activate
pip freeze
- name: "[no-extra] Run basic tests (checking dependencies)"
run: |
. venv/bin/activate
python -m nevergrad.optimization.requirements_check # calls a bit of everything
- uses: "./.github/actions/ubuntu_restore_all"
- name: save_cache
uses: actions/cache@v3.3.2
with:
path: "./venv"
key: v4-dependencies-{{ checksum "requirements/dev.txt" }}-{{ checksum "requirements/main.txt"}}-{{ checksum "requirements/bench.txt"}}
- name: "[all] Print installation"
run: |
. venv/bin/activate
pip freeze
- name: Run wheel and check package
run: |
. venv/bin/activate
pip install wheel
rm -rf dist # make sure it's clean
echo "Creating sdist"
python setup.py sdist
echo "Created sdist, now creating wheel"
python setup.py bdist_wheel
echo "Created wheel"
mkdir nevergrad-build
mv dist nevergrad-build/
python -c "from pathlib import Path;files = Path('nevergrad.egg-info/SOURCES.txt').read_text().split(); assert 'LICENSE' in files"
python3 -m venv test_wheel
. test_wheel/bin/activate
pip install -U pip
cd .. # don't use nevergrad locally
echo "Installing wheel"
pip install --progress-bar off nevergrad/nevergrad-build/dist/nevergrad-*any.whl
#pip install --progress-bar off --use-deprecated=legacy-resolver nevergrad/nevergrad-build/dist/nevergrad-*any.whl
echo "Installed wheel"
python -c "from nevergrad import functions;f = functions.ArtificialFunction(name='sphere', block_dimension=2);f([2, 3])"
- name: Build docs
run: |
. venv/bin/activate
cd docs/
make html
- name: Upload static files as artifact
id: deployment
uses: actions/upload-pages-artifact@v3
with:
path: docs/_build/html/
if: github.event_name != 'pull_request'
deploy-docs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: install
if: github.event_name != 'pull_request'
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
static:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- uses: actions/checkout@v4.1.0
- uses: "./.github/actions/ubuntu_restore_all"
- name: Run mypy
run: |
. venv/bin/activate
mypy --version
mypy nevergrad
- name: Run basic pylint
run: |
. venv/bin/activate
pylint --version
pylint nevergrad --disable=all --enable=unused-import,unused-argument,unused-variable,undefined-loop-variable,redefined-builtin,used-before-assignment,super-init-not-called,useless-super-delegation,dangerous-default-value,unnecessary-pass,attribute-defined-outside-init
- name: Run black
run: |
. venv/bin/activate
pip install black
black --version
black nevergrad --check --diff
pytests:
# runs-on: ubuntu-latest-16-cores
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- uses: actions/checkout@v4.1.0
- uses: "./.github/actions/ubuntu_restore_all"
- name: "[all] Run pytest"
run: |
. venv/bin/activate
pip install pytest
# run tests with no parallelism
pytest nevergrad -v --durations=20 --cov=nevergrad
# run in parallel using pytest-xdist
# pytest nevergrad -n auto -v --durations=20 --cov=nevergrad
#pytest nevergrad -v --exitfirst --durations=20 --cov=nevergrad