diff --git a/.github/actions/reusable-python-setup_conda/action.yml b/.github/actions/reusable-python-setup_conda/action.yml index 65c93b59..d474c139 100644 --- a/.github/actions/reusable-python-setup_conda/action.yml +++ b/.github/actions/reusable-python-setup_conda/action.yml @@ -1,6 +1,10 @@ name: Setup conda env description: Setup conda environment for Python inputs: + cache-number: + description: 'Cache number to reset cache if conda lock file has not changed' + required: true + type: number python-version: description: 'Python version to use' required: true @@ -32,6 +36,7 @@ runs: micromamba-version: ${{ env.micromamba_version }} init-shell: bash cache-downloads: true + cache-downloads-key: micromamba-dl${{ inputs.cache-number }} environment-name: "" post-cleanup: none - name: Authenticate to Artifactory @@ -47,6 +52,7 @@ runs: environment-name: test_env init-shell: bash cache-downloads: true + cache-downloads-key: micromamba-dl${{ inputs.cache-number }} post-cleanup: none env: PYTHONUTF8: 1 diff --git a/.github/actions/reusable-python-setup_pixi/action.yml b/.github/actions/reusable-python-setup_pixi/action.yml new file mode 100644 index 00000000..aacbfbf2 --- /dev/null +++ b/.github/actions/reusable-python-setup_pixi/action.yml @@ -0,0 +1,44 @@ +name: Setup pixi env +description: Setup pixi environment for Python +inputs: + cache-number: + description: 'Cache number to reset cache if pixi.lock has not changed' + required: true + type: number + python-version: + description: 'Python version to decide on the pixi environment to install' + required: false + type: string + JFROG_ARTIFACTORY_URL: + description: 'JFrog Artifactory URL' + required: true + type: string + JFROG_ARTIFACTORY_TOKEN: + description: 'JFrog Artifactory Token' + required: false + type: string + +runs: + using: "composite" + steps: + - id: get-env-name + name: Get pixi environment name + shell: bash + env: + PYTHON_VERSION: ${{ inputs.python-version }} + run: | + pixi_env="py${PYTHON_VERSION//./}" + echo "pixi-env=$pixi_env" >> "$GITHUB_OUTPUT" + - uses: prefix-dev/setup-pixi@v0.9.0 + with: + pixi-version: v0.54.1 + environments: ${{ steps.get-env-name.outputs.pixi-env }} + activate-environment: true + cache-key: pixi-env${{ inputs.cache-number }} + cache: true + locked: true + auth-host: ${{ inputs.JFROG_ARTIFACTORY_URL }} + auth-username: ${{ inputs.JFROG_ARTIFACTORY_TOKEN && 'github' || '' }} + auth-password: ${{ inputs.JFROG_ARTIFACTORY_TOKEN }} + env: + GIT_LFS_SKIP_SMUDGE: 1 diff --git a/.github/workflows/reusable-python-pytest.yml b/.github/workflows/reusable-python-pytest.yml index a2330e3f..1b471004 100644 --- a/.github/workflows/reusable-python-pytest.yml +++ b/.github/workflows/reusable-python-pytest.yml @@ -4,7 +4,7 @@ on: workflow_call: inputs: package-manager: - description: 'Package manager to use (e.g. "conda", "poetry")' + description: 'Package manager to use (e.g. "conda", "poetry", "pixi")' required: true type: string default: 'poetry' @@ -37,7 +37,7 @@ on: required: false type: string virtual-repo-names: - description: 'List of repository names to publish on (e.g. ["public-dev-pypi"])' + description: 'List of repository names to resolve on (e.g. ["public-dev-pypi"])' required: false type: string lfs: @@ -84,13 +84,15 @@ jobs: - name: Set up Python version uses: actions/setup-python@v5 + if: ${{ inputs.package-manager == 'poetry' || inputs.package-manager == 'hatch' }} with: python-version: ${{ matrix.python-version }} - - uses: MiraGeoscience/CI-tools/.github/actions/reusable-python-setup_conda@main + - uses: MiraGeoscience/CI-tools/.github/actions/reusable-python-setup_conda@DEVOPS-584 name: Setup conda env if: ${{ inputs.package-manager == 'conda' }} with: + cache-number: ${{ inputs.cache-number }} python-version: ${{ matrix.python-version }} JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }} JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }} @@ -112,12 +114,23 @@ jobs: cache-number: ${{ inputs.cache-number }} runner-os: ${{ runner.os }} + - uses: MiraGeoscience/CI-tools/.github/actions/reusable-python-setup_pixi@DEVOPS-584 + name: Setup pixi env + if: ${{ inputs.package-manager == 'pixi' }} + with: + cache-number: ${{ inputs.cache-number }} + python-version: ${{ matrix.python-version }} + JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }} + JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }} + - name: Run Pytest run: | if ${{ inputs.package-manager == 'conda' }}; then pytest --cov --cov-report=xml elif ${{ inputs.package-manager == 'poetry' }}; then poetry run pytest --cov --cov-report=xml + elif ${{ inputs.package-manager == 'pixi' }}; then + pixi run pytest --cov --cov-report=xml else hatch run pytest --cov --cov-report=xml fi diff --git a/.github/workflows/reusable-python-static_analysis.yml b/.github/workflows/reusable-python-static_analysis.yml index 09a300bc..957e5e7a 100644 --- a/.github/workflows/reusable-python-static_analysis.yml +++ b/.github/workflows/reusable-python-static_analysis.yml @@ -4,7 +4,7 @@ on: workflow_call: inputs: package-manager: - description: 'Package manager to use (e.g. "conda", "poetry")' + description: 'Package manager to use (e.g. "conda", "poetry", "pixi")' required: true type: string default: 'poetry' @@ -68,15 +68,18 @@ jobs: with: lfs: ${{ inputs.lfs }} fetch-depth: 0 + - name: Set up Python version uses: actions/setup-python@v5 + if: ${{ inputs.package-manager == 'poetry' || inputs.package-manager == 'hatch' }} with: python-version: ${{inputs.python-version}} - - uses: MiraGeoscience/CI-tools/.github/actions/reusable-python-setup_conda@main + - uses: MiraGeoscience/CI-tools/.github/actions/reusable-python-setup_conda@DEVOPS-584 name: Setup conda env if: ${{ inputs.package-manager == 'conda' }} with: + cache-number: ${{ inputs.cache-number }} python-version: ${{ inputs.python-version }} JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }} JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }} @@ -85,7 +88,7 @@ jobs: name: Setup poetry env if: ${{ inputs.package-manager == 'poetry' }} with: - cache-number: 1 + cache-number: ${{ inputs.cache-number }} runner-os: ${{ runner.os }} install-extras: ${{ inputs.install-extras }} virtual-repo-names: ${{ inputs.virtual-repo-names }} @@ -95,9 +98,18 @@ jobs: name: Setup hatch env if: ${{ inputs.package-manager == 'hatch' }} with: - cache-number: 1 + cache-number: ${{ inputs.cache-number }} runner-os: ${{ runner.os }} + - uses: MiraGeoscience/CI-tools/.github/actions/reusable-python-setup_pixi@DEVOPS-584 + name: Setup pixi env + if: ${{ inputs.package-manager == 'pixi' }} + with: + cache-number: ${{ inputs.cache-number }} + python-version: ${{ inputs.python-version }} + JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }} + JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }} + - name: Capture modified files if: github.event_name == 'pull_request' run: >- @@ -113,6 +125,8 @@ jobs: pylint $FILES_PARAM elif ${{ inputs.package-manager == 'poetry' }}; then poetry run pylint $FILES_PARAM + elif ${{ inputs.package-manager == 'pixi' }}; then + pixi run pylint $FILES_PARAM else hatch run pylint $FILES_PARAM fi @@ -124,6 +138,8 @@ jobs: pylint $source_dir tests elif ${{ inputs.package-manager == 'poetry' }}; then poetry run pylint $source_dir tests + elif ${{ inputs.package-manager == 'pixi' }}; then + pixi run pylint $source_dir tests else hatch run pylint $source_dir tests fi