Build/uv #126
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: Python package | |
on: | |
push: | |
branches: | |
- "main" | |
pull_request: | |
branches: | |
- "**" | |
types: [opened, synchronize, reopened] | |
create: | |
branches: | |
- "**" | |
jobs: | |
python-lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- uses: actions/cache@v4 | |
id: cache | |
with: | |
path: ${{ env.pythonLocation }} | |
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
- name: Install Dependencies | |
run: uv sync --only-dev --frozen | |
- name: Lint | |
run: uv run ./scripts/lint.sh | |
- name: Archive lint reports | |
uses: actions/upload-artifact@v4 | |
with: | |
name: lint-reports | |
path: reports | |
python-test: | |
strategy: | |
matrix: | |
python-version: ["3.10", "3.11", "3.12"] | |
platform: [ubuntu-latest, windows-latest] | |
fail-fast: false | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: actions/cache@v4 | |
id: cache | |
with: | |
path: ${{ env.pythonLocation }} | |
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
- name: Install Dependencies | |
run: uv sync --only-dev --frozen | |
- name: Test | |
shell: bash | |
run: ./scripts/test.sh | |
- name: Coveralls Parallel | |
uses: coverallsapp/github-action@v2 | |
with: | |
flag-name: run-${{ join(matrix.*, '-') }} | |
parallel: true | |
- name: Archive code coverage results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-${{ matrix.platform }}-${{ matrix.python-version }} | |
path: reports/.coverage | |
include-hidden-files: true | |
coveralls-finish: | |
needs: [python-test] | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Coveralls Finished | |
uses: coverallsapp/[email protected] | |
with: | |
parallel-finished: true | |
carryforward: "run-ubuntu-latest-3.10,run-ubuntu-latest-3.11,run-ubuntu-latest-3.12,run-windows-latest-3.10,run-windows-latest-3.11,run-windows-latest-3.12" | |
sonarcloud: | |
needs: [python-test] | |
name: SonarCloud | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage-ubuntu-latest-3.12 | |
path: reports | |
- name: Create coverage XML | |
run: uv run coverage xml | |
- name: Generate sonar properties | |
run: | | |
cat << EOF > sonar-project.properties | |
sonar.projectKey=ljnsn_coinapi-rest | |
sonar.organization=ljnsn | |
sonar.python.version=3.10 | |
sonar.python.coverage.reportPaths=reports/coverage.xml | |
sonar.sources=src/ | |
sonar.tests=tests/ | |
sonar.projectVersion="$(git describe --tags HEAD)" | |
EOF | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
bump-version: | |
runs-on: ubuntu-latest | |
needs: [python-lint, python-test] | |
if: | | |
github.event_name == 'push' && | |
github.ref_name == 'main' && | |
github.ref_type == 'branch' && | |
!startsWith(github.event.head_commit.message, 'π bump(release):') && | |
!startsWith(github.event.head_commit.message, 'bump(release):') && | |
!startsWith(github.event.head_commit.message, 'π bump:') && | |
!startsWith(github.event.head_commit.message, 'bump:') | |
name: "Bump version and create changelog with commitizen" | |
steps: | |
- name: Check out | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" | |
- name: Create bump and changelog | |
uses: commitizen-tools/commitizen-action@master | |
with: | |
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
extra_requirements: "cz-conventional-gitmoji" |