Skip to content

Commit

Permalink
Update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
aliberts committed May 3, 2024
1 parent 5ab62d1 commit 4c95262
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 105 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

0 comments on commit 4c95262

Please sign in to comment.