diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 67ebe45..47a974f 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -1,24 +1,54 @@ name: python_lib description: Installs the given GardenLinux Python library + inputs: - version: - description: GardenLinux Python library version - default: "0.8.9" + version: + description: GardenLinux Python library version + default: "0.8.9" + python_version: + description: Python version to setup + default: "3.13" + +outputs: + version: + description: GardenLinux Python library version + value: ${{ inputs.version }} + python_version: + description: Python version to setup + value: ${{ inputs.python_version }} + package_tool: + description: "Detected Python cache strategy." + value: ${{ steps.env-check.outputs.package_tool }} + runs: - using: composite - steps: - - name: Verify requirements.txt for "actions/setup-python" with enabled "pip" cache - shell: bash - run: | - if [ ! -f "requirements.txt" ]; then - echo "python-gardenlinux-lib @ git+https://github.com/gardenlinux/python-gardenlinux-lib.git@${{ inputs.version }}" | tee -a requirements.txt - fi - - name: Set up Python 3.13 - uses: actions/setup-python@v5 - with: - python-version: "3.13" - cache: 'pip' - - name: Install GardenLinux Python library - shell: bash - run: | - pip install git+https://github.com/gardenlinux/python-gardenlinux-lib.git@${{ inputs.version }} + using: composite + steps: + - name: Evaluate Python environment + id: env-check + shell: bash + run: | + # Determine cache type based on available lockfile + if [ -f poetry.lock ]; then + echo "package_tool=poetry" >> $GITHUB_OUTPUT + elif [ -f requirements.txt ]; then + echo "package_tool=pip" >> $GITHUB_OUTPUT + else + # no lockfile present: create one and use pip caching + echo "gardenlinux @ git+https://github.com/gardenlinux/python-gardenlinux-lib.git@${{ inputs.version }}" | tee -a requirements.txt + echo "package_tool=pip" >> $GITHUB_OUTPUT + fi + + - name: Install Poetry + if: steps.env-check.outputs.package_tool == 'poetry' + uses: snok/install-poetry@v1 + + - name: Set up Python ${{ inputs.python_version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python_version }} + cache: ${{ steps.env-check.outputs.package_tool }} + + - name: Install GardenLinux Python library + shell: bash + run: | + pip install git+https://github.com/gardenlinux/python-gardenlinux-lib.git@${{ inputs.version }} diff --git a/.github/workflows/pytests.yml b/.github/workflows/pytests.yml index 24498bc..1109206 100644 --- a/.github/workflows/pytests.yml +++ b/.github/workflows/pytests.yml @@ -11,6 +11,9 @@ jobs: test: name: Run tests and collect coverage runs-on: ubuntu-latest + strategy: + matrix: + python_version: [ "3.13" ] steps: - name: Checkout uses: actions/checkout@v4 @@ -19,9 +22,8 @@ jobs: - name: Setup Gardenlinux uses: ./.github/actions/setup - - - name: Install Poetry - uses: snok/install-poetry@v1 + with: + python_version: ${{ matrix.python_version }} - name: Install dependencies run: poetry install --with dev @@ -30,7 +32,7 @@ jobs: run: make install-test - name: Run tests - run: | + run: | export GLOCI_REGISTRY_TOKEN="invalid" make test-coverage-ci