Skip to content

Bugfix: GitHub output #34

Bugfix: GitHub output

Bugfix: GitHub output #34

Workflow file for this run

# GitHub Actions Pipeline
name: 'YoYoCICD'
on:
pull_request:
branches:
- main
paths:
- yoyo/**
- tests/**
- .github/workflows/**
push:
branches:
- main
paths:
- yoyo/**
- tests/**
- .github/workflows/**
# Repo Permissions
permissions:
contents: write
issues: read
checks: write
pull-requests: write
jobs:
Test:
runs-on: 'ubuntu-latest'
steps:
- name: checkout repo content
uses: actions/checkout@v2
- name: setup python
uses: actions/setup-python@v2
with:
python-version: '3.12'
- name: Upgrade package manager
run: python -m pip install -U pip
# Install dependencies
- name: install testing libraries
run: pip install pytest mock codecov pydocstyle pytest-cov pylint pylint_junit
- name: install project dependencies
run: python -m packages.sync
# Run tests
- name: Run tests
run: pytest -v tests/ --doctest-modules --junitxml=unit-testresults.xml --cov=yoyo/ --cov-append --cov-report=xml:xmlcov --cov-report=html:htmlcov
- name: Publish test reuslts
uses: EnricoMi/[email protected]
Build:
needs: Test
runs-on: 'ubuntu-latest'
outputs:
isPR: ${{ steps.check_build.outputs.is_pr }}
VERSION: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout repo content
uses: actions/checkout@v2
- name: Install python
uses: actions/setup-python@v2
with:
python-version: '3.12'
# Install dependencies
- name: Upgrade pip
run: python -m pip install -U pip
- name: Install build dependencies
run: pip install build setuptools
- name: install project dependencies
run: python -m packages.sync
# Build
- name: Build distribution
run: python -m build --wheel
# Artifacts
- name: Check build reason
id: check_build
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "is_pr=true" >> "$GITHUB_OUTPUT"
else
echo "is_pr=false" >> "$GITHUB_OUTPUT"
fi
- name: Extract version
id: get_version
if: ${{ steps.check_build.outputs.isPR }} == 'true'
run: |
echo "Getting version from __init__.py..."
VERSION=$(python <<EOF
import re
with open('yoyo/__init__.py', 'r') as file:
data = file.read()
match = re.search(r"__version__ = '\"['\"]", data)
print(match.group(1) if match else '')
EOF
)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: test
run: |
echo ${{ needs.Build.outputs.isPR }}
echo "${{ needs.Build.outputs.isPR }}"
echo echo ${{ needs.Build.outputs.VERSION }}
echo ${{ steps.get_version.outputs.version }}
echo ${{ steps.check_build.outputs.is_pr}}
- name: Create release
uses: ncipollo/[email protected]
if: ${{ steps.check_build.outputs.is_pr }} == 'true'
with:
tag: "${{ steps.get_version.outputs.version }}"
allowUpdates: true
replacesArtifacts: true
# # PYPI API Key not yet configured
# Release:
# needs: Build
# runs-on: ubuntu-latest
# steps:
# - name: Check out code
# uses: actions/checkout@v2
# - name: Set up Python
# uses: actions/setup-python@v2
# with:
# python-version: 3.12
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install setuptools wheel twine
# - name: Build and publish
# env:
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
# run: |
# python setup.py sdist bdist_wheel
# twine upload dist/*