Skip to content

Commit

Permalink
github actions
Browse files Browse the repository at this point in the history
ghstack-source-id: a60ee82712fdb171ebca3a27f4c29aa71cf37eee
Pull Request resolved: #1654
  • Loading branch information
bottler committed Nov 27, 2024
1 parent fbfa539 commit 48cd2c4
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/actions/ubuntu_restore_all/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: ubuntu_restore_all
runs:
using: composite
steps:
- uses: actions/[email protected]
- name: restore_cache
uses: actions/[email protected]
with:
key: v4-dependencies-{{ checksum "requirements/dev.txt" }}-{{ checksum "requirements/main.txt"}}-{{ checksum "requirements/bench.txt"}}
path: ./venv
restore-keys: |
v4-dependencies-{{ checksum "requirements/dev.txt" }}-{{ checksum "requirements/main.txt"}}-{{ checksum "requirements/bench.txt"}}
v4-dependencies-main-{{ checksum "requirements/main.txt"}}
- name: "[all] Install dependencies"
run: |
#python3 -m venv venv
rm -rf venv && python3 -m venv venv
. venv/bin/activate
pip install --progress-bar off -U pip setuptools
pip install --progress-bar off -e .[all]
#pip install --progress-bar off --use-deprecated=legacy-resolver -e .[all]
pip install --progress-bar off -U numpy==1.24.0 matplotlib==2.2.3 pyomo==5.7.1
pip install keras==2.6.0 # issue on Nov 4th 2021
shell: bash
7 changes: 7 additions & 0 deletions .github/check-yaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pathlib
import yaml

for path in pathlib.Path(".").glob("**/*.yml"):
print(path)
with open(path) as f:
yaml.load(f, Loader=yaml.FullLoader)
125 changes: 125 additions & 0 deletions .github/workflows/every_commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: facebookresearch/nevergrad/every_commit
on:
push:
branches:
- main
pull-request:
jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- uses: actions/[email protected]
- name: restore_cache
uses: actions/[email protected]
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/[email protected]
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 repo/nevergrad-build/dist/nevergrad-*any.whl
#pip install --progress-bar off --use-deprecated=legacy-resolver repo/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
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/[email protected]
- 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
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- uses: actions/[email protected]
- uses: "./.github/actions/ubuntu_restore_all"
- name: "[all] Run pytest"
run: |
. venv/bin/activate
pip install pytest
pytest --circleci-parallelize nevergrad -v --durations=20 --cov=nevergrad
#pytest nevergrad -v --exitfirst --durations=20 --cov=nevergrad
19 changes: 19 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: facebookresearch/nevergrad/main
on:
push:
branches:
- main
jobs:
docs-links:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- uses: actions/[email protected]
- uses: "./.github/actions/ubuntu_restore_all"
- name: Check links
run: |
. venv/bin/activate
cd docs/
make linkcheck
44 changes: 44 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: facebookresearch/nevergrad/release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+.post[0-9]+'
env:
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
CIRCLE_TAG: ${{ github.ref_name }}
jobs:
pypi-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- uses: actions/[email protected]
- uses: "./.github/actions/ubuntu_restore_all"
- 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/
- name: Create .pypirc
run: |
echo -e "[pypi]" >> ~/.pypirc
echo -e "username = __token__" >> ~/.pypirc
echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
- name: Verify tag
run: python setup.py verify_circleci_version
- name: upload to pypi
run: |
echo "Deploying"
. venv/bin/activate
du -h nevergrad-build/dist/*
twine check nevergrad-build/dist/nevergrad-*
twine upload nevergrad-build/dist/nevergrad-* --verbose

0 comments on commit 48cd2c4

Please sign in to comment.