Skip to content

Commit

Permalink
Merge pull request #7 from huggingface/user/aliberts/2024_05_03_publi…
Browse files Browse the repository at this point in the history
…sh_v0.1.0

Publish v0.1.0
  • Loading branch information
aliberts authored May 3, 2024
2 parents 415811f + 3d724e1 commit 27b136b
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 149 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/publish.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Quality

on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main

env:
PYTHON_VERSION: "3.10"

jobs:
style:
name: Style
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Get Ruff Version from pre-commit-config.yaml
id: get-ruff-version
run: |
RUFF_VERSION=$(awk '/repo: https:\/\/github.com\/astral-sh\/ruff-pre-commit/{flag=1;next}/rev:/{if(flag){print $2;exit}}' .pre-commit-config.yaml)
echo "RUFF_VERSION=${RUFF_VERSION}" >> $GITHUB_ENV
- name: Install Ruff
run: python -m pip install "ruff==${{ env.RUFF_VERSION }}"

- name: Ruff check
run: ruff check

- name: Ruff format
run: ruff format --diff


poetry_check:
name: Poetry check
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install poetry
run: pipx install poetry

- name: Poetry check
run: poetry check
119 changes: 32 additions & 87 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,105 +4,50 @@ on:
pull_request:
branches:
- main
paths:
- "gym_xarm/**"
- "tests/**"
- "examples.py"
- ".github/**"
- "poetry.lock"
push:
branches:
- main
paths:
- "gym_xarm/**"
- "tests/**"
- "examples.py"
- ".github/**"
- "poetry.lock"

jobs:
tests:
pytest:
name: Pytest
runs-on: ubuntu-latest
env:
POETRY_VERSION: 1.8.2
DATA_DIR: tests/data
MUJOCO_GL: egl
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v4
with:
lfs: true

- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.10'

#----------------------------------------------
# install & configure poetry
#----------------------------------------------
- name: Load cached Poetry installation
id: restore-poetry-cache
uses: actions/cache/restore@v3
with:
path: ~/.local
key: poetry-${{ env.POETRY_VERSION }}

- name: Install Poetry
if: steps.restore-poetry-cache.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
installer-parallel: true

- name: Save cached Poetry installation
if: |
steps.restore-poetry-cache.outputs.cache-hit != 'true' &&
github.ref_name == 'main'
id: save-poetry-cache
uses: actions/cache/save@v3
with:
path: ~/.local
key: poetry-${{ env.POETRY_VERSION }}
- uses: actions/checkout@v4

- name: Configure Poetry
run: poetry config virtualenvs.in-project true

#----------------------------------------------
# install dependencies
#----------------------------------------------
- name: Load cached venv
id: restore-dependencies-cache
uses: actions/cache/restore@v3
with:
path: .venv
key: venv-${{ steps.setup-python.outputs.python-version }}-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
- name: Install EGL
run: sudo apt-get update && sudo apt-get install -y libegl1-mesa-dev

- name: Install dependencies
if: steps.restore-dependencies-cache.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --without dev
- name: Install poetry
run: |
pipx install poetry && poetry config virtualenvs.in-project true
echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH
- name: Save cached venv
if: |
steps.restore-dependencies-cache.outputs.cache-hit != 'true' &&
github.ref_name == 'main'
id: save-dependencies-cache
uses: actions/cache/save@v3
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
path: .venv
key: venv-${{ steps.setup-python.outputs.python-version }}-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
python-version: "3.10"
cache: "poetry"

- name: Install libegl1-mesa-dev
run: sudo apt-get update && sudo apt-get install -y libegl1-mesa-dev

#----------------------------------------------
# install project
#----------------------------------------------
- name: Install project
run: poetry install --no-interaction --without dev

#----------------------------------------------
# run tests & coverage
#----------------------------------------------
- name: Run tests
- name: Install poetry dependencies
run: |
source .venv/bin/activate
pytest --cov=./gym_xarm tests
poetry install --all-extras
# TODO(aliberts): Link with HF Codecov account
# - name: Upload coverage reports to Codecov with GitHub Action
# uses: codecov/codecov-action@v4
# with:
# files: ./coverage.xml
# verbose: true
- name: Test with pytest
run: |
pytest tests -v --cov=./gym_xarm --durations=0
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
args: ['--maxkb=5000']
Expand All @@ -19,7 +19,7 @@ repos:
hooks:
- id: pyupgrade
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
rev: v0.4.2
hooks:
- id: ruff
args: [--fix]
Expand Down
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,7 @@ If you don't have it already, follow the [instructions](https://python-poetry.or

Install the project with dev dependencies:
```bash
poetry install --with dev
```

### Add dependencies

The equivalent of `pip install some-package` would just be:
```bash
poetry add some-package
poetry install --all-extras
```

### Follow our style
Expand Down
Loading

0 comments on commit 27b136b

Please sign in to comment.