add CI/CD and initial tests #1
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: Test python package | ||
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" }} | ||
Check failure on line 29 in .github/workflows/test.yaml GitHub Actions / Test python packageInvalid workflow file
|
||
run: | | ||
venv/bin/pip-compile --quiet --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: | | ||
pytest tests/ | ||
- name: License Check | ||
run: | | ||
venv/bin/pip install -e . | ||
venv/bin/license-check | ||
- name: Auto-tag a release | ||
if: ${{ matrix.python-version == "3.11" && github.ref == "refs/heads/main" }} | ||
run: | | ||
TAG="$(venv/bin/python -c 'import obs_common.release; print(obs_common.release.generate_tag())')" | ||
git tag -s "$TAG" -m "Tag $TAG" | ||
git push --tags |