.github/workflows/ci.yml
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: CI
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]
schedule:
- cron: '0 8 * * *'
jobs:
test:
# Skip CI if [ci skip] in the commit message
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
strategy:
fail-fast: true
matrix:
os: [ "ubuntu-20.04" ]
# python-version: [ "3.6.2", "3.7", "3.8", "3.9" ]
python-version: [ "3.8" ]
runs-on: ${{ matrix.os }}
timeout-minutes: 40
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v2
- name: Set up python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.2
virtualenvs-create: true
virtualenvs-in-project: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction
#----------------------------------------------
# check codestyle & lint
#----------------------------------------------
- name: Check codestyle
run: |
make check-codestyle
- name: Lint with flake8
run: |
make lint
#----------------------------------------------
# ----- install & configure ROS -----
#----------------------------------------------
- name: install ROS
run: |
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt install curl # if you haven't already installed curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt update
sudo apt install ros-noetic-ros-base
echo "source /opt/ros/noetic/setup.bash" >> .venv/bin/activate
sudo apt-get install ros-noetic-cv-bridge
sudo apt-get install freeglut3-dev
#----------------------------------------------
# Build docs
#----------------------------------------------
- name: Build the doc
run: |
sudo apt-get install python3-sphinx
source .venv/bin/activate
make doc
#----------------------------------------------
# add matrix specifics and run test suite
#----------------------------------------------
- name: Run tests
run: |
source .venv/bin/activate
make pytest
#----------------------------------------------
# Save code coverage
#----------------------------------------------
- uses: actions/upload-artifact@v3
with:
name: 'coverage'
path: coverage.xml
release:
needs: test
# https://github.community/t/how-do-i-specify-job-dependency-running-in-another-workflow/16482
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && !contains(github.event.head_commit.message, 'chore(release):')
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
#-----------------------------------------------
# Publish to PYPI in case of a new version
#-----------------------------------------------
- name: Semantic Release
run: |
pip install python-semantic-release==7.34.6
git config --global user.name "github-actions"
git config --global user.email "action@github.com"
semantic-release publish -D commit_author="github-actions <action@github.com>"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_USERNAME: ${{ secrets.PYPI_USERNAME }}
REPOSITORY_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
#----------------------------------------------
# Download coverage and publish to CodeClimate
#----------------------------------------------
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: 'coverage'
path: .
- name: Publish code coverage to CodeClimate
uses: paambaati/codeclimate-action@v2.7.5
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
debug: true