.3.0: updating actions #10
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: PR Validation | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
validation: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
pip install -r requirements.txt | |
- name: Get version from main branch | |
id: get_version | |
run: | | |
# Extract version from the Python file and store it as a variable | |
VERSION=$(python -c "import importlib; print(importlib.import_module('src.libcrawler.version').__version__)") | |
echo "Extracted Version: $VERSION" | |
# Prefix the version with 'v' to match the branch naming convention | |
BRANCH_VERSION="v$VERSION" | |
echo "Formatted Branch Version: $BRANCH_VERSION" | |
# Set the formatted version as an environment variable for later steps | |
echo "branch_version=$BRANCH_VERSION" >> $GITHUB_ENV | |
- name: Check if branch exists for the current version | |
run: | | |
# Use the formatted branch version to check if it exists in the repo | |
git ls-remote --heads origin refs/heads/$branch_version && exit 0 || (echo "Branch $branch_version does not exist" && exit 1) | |
- name: Run tests | |
run: python -m unittest discover -s src/tests | |
- name: Build and check distribution | |
run: python3 -m build sdist | |
- name: Install package and test entry point | |
run: | | |
pip install dist/*.tar.gz | |
crawl-docs --help |