diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 8b4997d2c..15f5cc64d 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,6 +1,10 @@ name: "Coverage" on: [push] + +env: + UV_SYSTEM_PYTHON: 1 + jobs: coverage: runs-on: ${{ matrix.os }} @@ -16,8 +20,14 @@ jobs: uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + # Install a specific version of uv. + version: "0.11.28" + enable-cache: true - name: Install dependencies - run: pip install tox tox-uv + run: uv pip install tox tox-uv - name: Run Tests and Record Coverage run: | - tox -e coverage + uv run tox -e coverage diff --git a/.github/workflows/docs_latest.yml b/.github/workflows/docs_latest.yml index 521378fd8..1ffcb1b91 100644 --- a/.github/workflows/docs_latest.yml +++ b/.github/workflows/docs_latest.yml @@ -11,6 +11,9 @@ on: # You should remember to delete the generated test-XXXXXX folder on the gh-pages branch after you are done with them. workflow_dispatch: +env: + UV_SYSTEM_PYTHON: 1 + jobs: build: name: 🚀📄 Build and deploy documentation to GitHub Pages @@ -34,24 +37,31 @@ jobs: - name: Set routing name to test-XXXXXX if: github.ref != 'refs/heads/main' run: echo "REF_NAME=test-$(shuf -i 100000-999999 -n 1)" >> "$GITHUB_ENV" - - uses: actions/setup-python@v6 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + # Install a specific version of uv. + version: "0.11.28" + enable-cache: true - name: Checkout uses: actions/checkout@v7 with: fetch-depth: 0 # otherwise, you will fail to push refs to dest repo - name: Install dependencies run: | - pip install tox tox-uv - pip install -r requirements.txt + uv pip install tox tox-uv + uv pip install -r requirements.txt # Note: The sphinx action below can only install a single requirements file. - name: Build JSON Schemas - run: tox -e generate_json_schemas + run: uv run tox -e generate_json_schemas - name: Build BO4E package # Note: This step necessary to correctly set the version in the JSON-Schema-links run: | - pip install -e . + uv pip install -e . python -c "import bo4e; print(bo4e.__gh_version__)" - name: Run kroki with docker run: | diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 2e7138459..17026f7dd 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -1,5 +1,9 @@ name: "Linting" on: [push] + +env: + UV_SYSTEM_PYTHON: 1 + jobs: linting: name: Python Code Quality and Lint @@ -15,8 +19,14 @@ jobs: uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + # Install a specific version of uv. + version: "0.11.28" + enable-cache: true - name: Install dependencies - run: pip install tox tox-uv + run: uv pip install tox tox-uv - name: Run ${{ matrix.linter-env }} run: | - tox -e ${{ matrix.linter-env }} + uv run tox -e ${{ matrix.linter-env }} diff --git a/.github/workflows/packaging_test.yml b/.github/workflows/packaging_test.yml index 9e6ca1e02..ca9111845 100644 --- a/.github/workflows/packaging_test.yml +++ b/.github/workflows/packaging_test.yml @@ -1,6 +1,10 @@ name: "Packaging Test" on: [push] + +env: + UV_SYSTEM_PYTHON: 1 + jobs: check_packaging: runs-on: ${{ matrix.os }} @@ -14,8 +18,14 @@ jobs: uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + # Install a specific version of uv. + version: "0.11.28" + enable-cache: true - name: Install dependencies - run: pip install tox tox-uv + run: uv pip install tox tox-uv - name: Run Packaging Test run: | - tox -e test_packaging + uv run tox -e test_packaging diff --git a/.github/workflows/python-publish-scheduled.yml b/.github/workflows/python-publish-scheduled.yml deleted file mode 100644 index 750e025c5..000000000 --- a/.github/workflows/python-publish-scheduled.yml +++ /dev/null @@ -1,110 +0,0 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -name: Upload Python Package Scheduled - -on: - schedule: - # Runs at 01:23, on day 1 of the month, only in January and July. - - cron: '23 1 1 1,7 *' - -jobs: - tests: - runs-on: ${{ matrix.os }} - strategy: - matrix: - python-version: ["3.10", "3.11", "3.12"] - os: [ubuntu-latest] - steps: - - uses: actions/checkout@v7 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v6 - with: - python-version: ${{ matrix.python-version }} - - name: Install tox - run: pip install tox tox-uv - - name: Run the Tests - run: | - tox -e tests - tag_and_release: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v7 - - name: Calculate Tag Name - id: calc_tag - run: | - CURRENT_YEAR=$(date +%Y) - CURRENT_MONTH=$(date +%m) - TAG="${CURRENT_YEAR}${TAG_MONTH}.0.0" - echo "Calculated tag $TAG" - echo "::set-output name=tag::$TAG" - - name: Create and Push Tag - run: | - TAG=${{ steps.calc_tag.outputs.tag }} - git tag $TAG - git push origin $TAG - generate: - name: Generate JSON-Schemas - runs-on: ubuntu-latest - needs: tests - steps: - - name: Check out Git repository - uses: actions/checkout@v7 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v6 - with: - python-version: ${{ matrix.python-version }} - - name: Install tox - run: pip install tox tox-uv - - name: Build JSON Schemas - run: tox -e generate_json_schemas - env: - TARGET_VERSION: ${{ github.ref_name }} - - name: Push schemas to BO4E-Schemas repo - uses: cpina/github-action-push-to-another-repository@v1.7.3 - env: - API_TOKEN_GITHUB: ${{ secrets.BO4E_PYTHON_GENERATE_SCHEMAS }} # this token expires on 2024-10-09 - # token with repo scope - # https://github.com/Hochfrequenz/BO4E-python/settings/secrets/actions/BO4E_PYTHON_GENERATE_SCHEMAS - with: - source-directory: "json_schemas" - target-directory: "src/bo4e_schemas" - destination-github-username: "Hochfrequenz" - destination-repository-name: "BO4E-Schemas" - user-email: bo4e-schemas@hochfrequenz.de - target-branch: main - commit-message: "Update JSON-Schemas - BO4E ${{ github.ref_name }}" - # This step uses the github API to automatically create a release with the same version tag - # in the BO4E-Schemas repo. For this we have to retrieve the commits SHA via the API first. - # For this, we use the lightweight tool jq (https://stedolan.github.io/jq/) to parse the JSON - # response from the API. - - name: Tag and release the new version in BO4E-Schemas - run: python bo4e_schemas_create_release.py - env: - GITHUB_TOKEN: ${{ secrets.BO4E_PYTHON_GENERATE_SCHEMAS }} # this token expires on 2024-10-09 - VERSION: ${{ github.ref_name }} - build-n-publish: - name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI - runs-on: ubuntu-latest - # Specifying a GitHub environment, which is strongly recommended by PyPI: https://docs.pypi.org/trusted-publishers/adding-a-publisher/ - environment: release - permissions: - # IMPORTANT: this permission is mandatory for trusted publishing - id-token: write - needs: [tests, generate] - steps: - - uses: actions/checkout@v7 - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: "3.10.x" - - name: Install dependencies - run: | - pip install uv - uv pip install --system --group packaging - - name: Build wheel and source distributions - run: python -m build - - name: Publish distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags/v') - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index f919a76cc..a5f50639c 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -7,6 +7,9 @@ on: release: types: [created, edited] +env: + UV_SYSTEM_PYTHON: 1 + jobs: tests: if: startsWith(github.ref, 'refs/tags/v') @@ -21,11 +24,50 @@ jobs: uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + # Install a specific version of uv. + version: "0.11.28" + enable-cache: true - name: Install tox - run: pip install tox tox-uv + run: uv pip install tox tox-uv - name: Run the Tests run: | - tox -e tests + uv run tox -e tests + json_schemas_artifact: + name: Generate JSON-Schemas + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.12"] + steps: + - name: Check out Git repository + uses: actions/checkout@v7 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + # Install a specific version of uv. + version: "0.11.28" + enable-cache: true + - name: Install tox + run: uv pip install tox tox-uv + - name: Build JSON Schemas + run: | + uv run tox -e generate_json_schemas + env: + TARGET_VERSION: ${{ github.ref_name }} + - name: Upload JSON Schemas as artifact + uses: actions/upload-artifact@v7 + with: + name: json-schemas + path: json_schemas/ + if-no-files-found: "error" + retention-days: 1 check_version_tag: name: Check if the version tag is correct runs-on: ubuntu-latest @@ -34,23 +76,17 @@ jobs: # this, anonymous API calls hit GitHub's 60 req/hr rate limit and # `bo4e repo versions` / `bo4e pull` fail mid-job. GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + needs: [json_schemas_artifact] steps: - name: Check out Git repository uses: actions/checkout@v7 with: fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v6 + - name: Download JSON Schemas artifact + uses: actions/download-artifact@v8 with: - python-version: "3.12" - - name: Install dependencies for schema generation - run: | - pip install uv - uv pip install --system -e . --group json_schemas - - name: Build JSON Schemas - run: python generate_or_validate_json_schemas.py --mode generate - env: - TARGET_VERSION: ${{ github.ref_name }} + name: json-schemas + path: json_schemas/ - name: Install bo4e CLI uses: ./.github/actions/setup-bo4e - name: Verify version bump @@ -59,27 +95,34 @@ jobs: bo4e pull -t "$LAST_VERSION" -o tmp/last_schemas bo4e diff schemas tmp/last_schemas json_schemas -o tmp/diff.json bo4e diff version-bump tmp/diff.json -q - json_schemas: - name: Generate JSON-Schemas + json_schemas_publish: + name: Publish JSON-Schemas runs-on: ubuntu-latest needs: [tests, check_version_tag] concurrency: build-n-publish-json-schemas + strategy: + matrix: + python-version: ["3.12"] steps: - - name: Check out Git repository - uses: actions/checkout@v7 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v6 with: - python-version: "3.12" - - name: Install tox - run: pip install tox tox-uv - - name: Build JSON Schemas + python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + # Install a specific version of uv. + version: "0.11.28" + enable-cache: true + - name: Download JSON Schemas artifact + uses: actions/download-artifact@v8 + with: + name: json-schemas + path: json_schemas/ + - name: Remove .version file run: | - tox -e generate_json_schemas # Remove .version file as we don't want to commit it to BO4E-Schemas rm json_schemas/.version - env: - TARGET_VERSION: ${{ github.ref_name }} - name: Push schemas to BO4E-Schemas repo uses: cpina/github-action-push-to-another-repository@v1.7.3 env: @@ -100,7 +143,7 @@ jobs: # response from the API. - name: Install dependencies for creating release run: | - pip install requests click + uv pip install requests click - name: Tag and release the new version in BO4E-Schemas run: python bo4e_schemas_create_release.py env: @@ -118,27 +161,37 @@ jobs: # the documentation asset script (bo4e repo versions, bo4e pull) doesn't # hit GitHub's 60 req/hr anonymous rate limit. GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + strategy: + matrix: + python-version: ["3.12"] steps: - uses: actions/checkout@v7 with: fetch-depth: 0 # otherwise, you will fail to push refs to dest repo - - name: Set up Python + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v6 with: - python-version: "3.12" + python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + # Install a specific version of uv. + version: "0.11.28" + enable-cache: true - name: Install dependencies run: | - pip install tox tox-uv - pip install -r requirements.txt + uv pip install tox tox-uv + uv pip install -r requirements.txt # Note: The sphinx action below can only install a single requirements file. - - name: Build JSON Schemas - run: tox -e generate_json_schemas - env: - TARGET_VERSION: ${{ github.ref_name }} + - name: Download JSON Schemas artifact + uses: actions/download-artifact@v8 + with: + name: json-schemas + path: json_schemas/ - name: Build BO4E package # Note: This step necessary to correctly set the version in the JSON-Schema-links run: | - pip install -e . + uv pip install -e . python -c "import bo4e; print(bo4e.__gh_version__)" - name: Run kroki with docker run: | @@ -192,20 +245,24 @@ jobs: permissions: # IMPORTANT: this permission is mandatory for trusted publishing id-token: write - needs: [tests, json_schemas, docs] + needs: [tests, json_schemas_publish, docs] + strategy: + matrix: + python-version: ["3.12"] concurrency: build-n-publish-distributions steps: - uses: actions/checkout@v7 - - name: Set up Python + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v6 with: - python-version: "3.10.x" - - name: Install dependencies - run: | - pip install uv - uv pip install --system --group packaging + python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + # Install a specific version of uv. + version: "0.11.28" + enable-cache: true - name: Build wheel and source distributions - run: python -m build + run: uv build - name: Publish distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags/v') - uses: pypa/gh-action-pypi-publish@release/v1 + run: uv publish diff --git a/.github/workflows/test_docs.yml b/.github/workflows/test_docs.yml index 23f245e77..e546065eb 100644 --- a/.github/workflows/test_docs.yml +++ b/.github/workflows/test_docs.yml @@ -1,5 +1,9 @@ name: "Test Doc Creation (Sphinx)" on: [push] + +env: + UV_SYSTEM_PYTHON: 1 + jobs: docbuild: name: Check Docs @@ -21,13 +25,19 @@ jobs: uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + # Install a specific version of uv. + version: "0.11.28" + enable-cache: true - name: Run kroki with docker run: | docker compose up -d - name: Install bo4e CLI uses: ./.github/actions/setup-bo4e - name: Install dependencies - run: pip install tox tox-uv + run: uv pip install tox tox-uv - name: Check Docs run: | - tox -e docs + uv run tox -e docs diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 272ec6a59..3f9c63674 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,10 @@ name: Tests on: [push] + +env: + UV_SYSTEM_PYTHON: 1 + jobs: tests: runs-on: ${{ matrix.os }} @@ -16,8 +20,14 @@ jobs: uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + # Install a specific version of uv. + version: "0.11.28" + enable-cache: true - name: Install tox - run: pip install tox tox-uv + run: uv pip install tox tox-uv - name: Test with tox run: | - tox -e tests + uv run tox -e tests