Skip to content

add CI/CD and initial tests #1

add CI/CD and initial tests

add CI/CD and initial tests #1

Workflow file for this run

name: Test, build, and release
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m venv venv
venv/bin/pip install -r requirements.txt
- name: Verify requirements.txt
if: ${{ matrix.python-version == '3.11' }}
run: |
venv/bin/pip-compile --quiet --allow-unsafe --generate-hashes --strip-extras
git diff --exit-code -- requirements.txt
- name: Run lint check
if: ${{ matrix.python-version == '3.11' }}
run: |
venv/bin/ruff format --check obs_common tests
venv/bin/ruff check obs_common tests
- name: Run tests
run: |
venv/bin/pytest tests/
- name: License Check
run: |
venv/bin/pip install -e .
venv/bin/license-check
build-and-release:
if: ${{ github.ref == 'refs/heads/main' }}
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Generate release tag
run: echo RELEASE_TAG="$(python -c 'import obs_common.release; print(obs_common.release.generate_tag())')" >> "$GITHUB_ENV"
- name: Overrride dynamic version
run: sed 's/dynamic = \["version"]/# dynamic = ["version"]\nversion = "'"$RELEASE_TAG"'"/' -i pyproject.toml
- name: Build wheel
run: python -m build
- name: Publish release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create "$RELEASE_TAG" --repo="$GITHUB_REPOSITORY" --generate-notes dist/*.whl