Skip to content

Commit

Permalink
github actions
Browse files Browse the repository at this point in the history
ghstack-source-id: 761a0e4b72463a19c94db61b2d0119cff0b069b3
Pull Request resolved: #1654
  • Loading branch information
bottler committed Dec 2, 2024
1 parent 62b7777 commit a40a1e4
Show file tree
Hide file tree
Showing 8 changed files with 301 additions and 46 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:
- 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
( unset GITHUB_REF ; pip install --progress-bar off IOHexperimenter>=0.2.9.2 )
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
136 changes: 136 additions & 0 deletions .github/workflows/every_commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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/[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 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/[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-16-cores
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
# 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
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
40 changes: 22 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
# - repo: https://github.com/pre-commit/mirrors-autopep8
# rev: v1.4.4 # Use the sha / tag you want to point at
# hooks:
# - id: autopep8
# exclude: ^scripts/
# args: ['-i', '--max-line-length=140']
- repo: https://github.com/python/black
rev: 20.8b1
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
# - repo: https://github.com/pre-commit/mirrors-autopep8
# rev: v1.4.4 # Use the sha / tag you want to point at
# hooks:
# - id: autopep8
# exclude: ^scripts/
# args: ['-i', '--max-line-length=140']
- repo: https://github.com/python/black
rev: 22.3.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/pre-commit/mirrors-pylint
- id: black
language_version: python3
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.4.4
hooks:
- id: pylint
exclude: ^scripts/
args: ['--disable=bad-continuation'] # coz incompatible with black
- id: pylint
exclude: ^scripts/
args: ['--disable=bad-continuation'] # coz incompatible with black
- repo: https://github.com/google/yamlfmt
rev: v0.14.0
hooks:
- id: yamlfmt
Loading

0 comments on commit a40a1e4

Please sign in to comment.