CI/CD for VEDA #45
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD for VEDA | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
# Testing job for both Linux and Windows | |
test: | |
name: Test on ${{ matrix.os }} with Python ${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
python-version: ['3.9', '3.10', '3.11'] | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache pip | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/pip | |
C:\Users\runneradmin\AppData\Local\pip\Cache | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
pip install flake8 pytest | |
pip install build | |
- name: Lint with flake8 | |
run: | | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
- name: Run tests | |
run: | | |
if [ "$RUNNER_OS" = "Windows" ]; then | |
PYTHONPATH="src" | |
else | |
export PYTHONPATH=src | |
fi | |
pytest tests | |
shell: bash | |
# Publishing job to PyPI | |
publish: | |
name: Build and publish Python distribution | |
runs-on: ubuntu-latest | |
needs: test | |
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build binary wheel and a source tarball | |
run: python -m build | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@master | |
with: | |
password: ${{ secrets.VEDA_SECRET }} |