Add rhdh-templates skill #18
This file contains hidden or 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 | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| resolve-python: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| min-version: ${{ steps.resolve.outputs.min }} | |
| max-version: ${{ steps.resolve.outputs.max }} | |
| matrix: ${{ steps.resolve.outputs.matrix }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: resolve | |
| run: | | |
| python3 << 'PYEOF' >> "$GITHUB_OUTPUT" | |
| import re, json | |
| with open('pyproject.toml') as f: | |
| spec = re.search(r'requires-python\s*=\s*"([^"]+)"', f.read()) | |
| spec = spec.group(1) if spec else '>=3.9' | |
| min_m = re.search(r'>=\s*([\d.]+)', spec) | |
| max_m = re.search(r'<=?\s*([\d.]+)', spec) | |
| min_v = min_m.group(1) if min_m else '3.9' | |
| max_v = max_m.group(1) if max_m else '3.x' | |
| matrix = [min_v, max_v] if min_v != max_v else [min_v] | |
| print(f'min={min_v}') | |
| print(f'max={max_v}') | |
| print(f'matrix={json.dumps(matrix)}') | |
| PYEOF | |
| lint: | |
| needs: resolve-python | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ needs.resolve-python.outputs.max-version }} | |
| - run: uv sync --frozen --extra dev | |
| - run: uv run ruff check . | |
| - run: uv run ruff format --check . | |
| test: | |
| needs: resolve-python | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ${{ fromJson(needs.resolve-python.outputs.matrix) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - run: uv sync --frozen --extra dev | |
| - run: uv run pytest -v |