Skip to content

Commit 8440f27

Browse files
authored
Merge pull request #54 from MiraGeoscience/DEVOPS-584
DEVOPS-584: POC on pixi env for HPC
2 parents 2fe3021 + e6176e0 commit 8440f27

4 files changed

Lines changed: 86 additions & 7 deletions

File tree

.github/actions/reusable-python-setup_conda/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Setup conda env
22
description: Setup conda environment for Python
33
inputs:
4+
cache-number:
5+
description: 'Cache number to reset cache if conda lock file has not changed'
6+
required: true
7+
type: number
48
python-version:
59
description: 'Python version to use'
610
required: true
@@ -32,6 +36,7 @@ runs:
3236
micromamba-version: ${{ env.micromamba_version }}
3337
init-shell: bash
3438
cache-downloads: true
39+
cache-downloads-key: micromamba-dl${{ inputs.cache-number }}
3540
environment-name: ""
3641
post-cleanup: none
3742
- name: Authenticate to Artifactory
@@ -47,6 +52,7 @@ runs:
4752
environment-name: test_env
4853
init-shell: bash
4954
cache-downloads: true
55+
cache-downloads-key: micromamba-dl${{ inputs.cache-number }}
5056
post-cleanup: none
5157
env:
5258
PYTHONUTF8: 1
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Setup pixi env
2+
description: Setup pixi environment for Python
3+
inputs:
4+
cache-number:
5+
description: 'Cache number to reset cache if pixi.lock has not changed'
6+
required: true
7+
type: number
8+
python-version:
9+
description: 'Python version to decide on the pixi environment to install'
10+
required: false
11+
type: string
12+
JFROG_ARTIFACTORY_URL:
13+
description: 'JFrog Artifactory URL'
14+
required: true
15+
type: string
16+
JFROG_ARTIFACTORY_TOKEN:
17+
description: 'JFrog Artifactory Token'
18+
required: false
19+
type: string
20+
21+
runs:
22+
using: "composite"
23+
steps:
24+
- id: get-env-name
25+
name: Get pixi environment name
26+
shell: bash
27+
env:
28+
PYTHON_VERSION: ${{ inputs.python-version }}
29+
run: |
30+
pixi_env="py${PYTHON_VERSION//./}"
31+
echo "pixi-env=$pixi_env" >> "$GITHUB_OUTPUT"
32+
- uses: prefix-dev/setup-pixi@v0.9.0
33+
with:
34+
pixi-version: v0.54.1
35+
environments: ${{ steps.get-env-name.outputs.pixi-env }}
36+
activate-environment: true
37+
cache-key: pixi-env${{ inputs.cache-number }}
38+
cache: true
39+
locked: true
40+
auth-host: ${{ inputs.JFROG_ARTIFACTORY_URL }}
41+
auth-username: ${{ inputs.JFROG_ARTIFACTORY_TOKEN && 'github' || '' }}
42+
auth-password: ${{ inputs.JFROG_ARTIFACTORY_TOKEN }}
43+
env:
44+
GIT_LFS_SKIP_SMUDGE: 1

.github/workflows/reusable-python-pytest.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_call:
55
inputs:
66
package-manager:
7-
description: 'Package manager to use (e.g. "conda", "poetry")'
7+
description: 'Package manager to use (e.g. "conda", "poetry", "pixi")'
88
required: true
99
type: string
1010
default: 'poetry'
@@ -37,7 +37,7 @@ on:
3737
required: false
3838
type: string
3939
virtual-repo-names:
40-
description: 'List of repository names to publish on (e.g. ["public-dev-pypi"])'
40+
description: 'List of repository names to resolve on (e.g. ["public-dev-pypi"])'
4141
required: false
4242
type: string
4343
lfs:
@@ -84,13 +84,15 @@ jobs:
8484

8585
- name: Set up Python version
8686
uses: actions/setup-python@v5
87+
if: ${{ inputs.package-manager == 'poetry' || inputs.package-manager == 'hatch' }}
8788
with:
8889
python-version: ${{ matrix.python-version }}
8990

90-
- uses: MiraGeoscience/CI-tools/.github/actions/reusable-python-setup_conda@main
91+
- uses: MiraGeoscience/CI-tools/.github/actions/reusable-python-setup_conda@DEVOPS-584
9192
name: Setup conda env
9293
if: ${{ inputs.package-manager == 'conda' }}
9394
with:
95+
cache-number: ${{ inputs.cache-number }}
9496
python-version: ${{ matrix.python-version }}
9597
JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }}
9698
JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }}
@@ -112,12 +114,23 @@ jobs:
112114
cache-number: ${{ inputs.cache-number }}
113115
runner-os: ${{ runner.os }}
114116

117+
- uses: MiraGeoscience/CI-tools/.github/actions/reusable-python-setup_pixi@DEVOPS-584
118+
name: Setup pixi env
119+
if: ${{ inputs.package-manager == 'pixi' }}
120+
with:
121+
cache-number: ${{ inputs.cache-number }}
122+
python-version: ${{ matrix.python-version }}
123+
JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }}
124+
JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }}
125+
115126
- name: Run Pytest
116127
run: |
117128
if ${{ inputs.package-manager == 'conda' }}; then
118129
pytest --cov --cov-report=xml
119130
elif ${{ inputs.package-manager == 'poetry' }}; then
120131
poetry run pytest --cov --cov-report=xml
132+
elif ${{ inputs.package-manager == 'pixi' }}; then
133+
pixi run pytest --cov --cov-report=xml
121134
else
122135
hatch run pytest --cov --cov-report=xml
123136
fi

.github/workflows/reusable-python-static_analysis.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_call:
55
inputs:
66
package-manager:
7-
description: 'Package manager to use (e.g. "conda", "poetry")'
7+
description: 'Package manager to use (e.g. "conda", "poetry", "pixi")'
88
required: true
99
type: string
1010
default: 'poetry'
@@ -68,15 +68,18 @@ jobs:
6868
with:
6969
lfs: ${{ inputs.lfs }}
7070
fetch-depth: 0
71+
7172
- name: Set up Python version
7273
uses: actions/setup-python@v5
74+
if: ${{ inputs.package-manager == 'poetry' || inputs.package-manager == 'hatch' }}
7375
with:
7476
python-version: ${{inputs.python-version}}
7577

76-
- uses: MiraGeoscience/CI-tools/.github/actions/reusable-python-setup_conda@main
78+
- uses: MiraGeoscience/CI-tools/.github/actions/reusable-python-setup_conda@DEVOPS-584
7779
name: Setup conda env
7880
if: ${{ inputs.package-manager == 'conda' }}
7981
with:
82+
cache-number: ${{ inputs.cache-number }}
8083
python-version: ${{ inputs.python-version }}
8184
JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }}
8285
JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }}
@@ -85,7 +88,7 @@ jobs:
8588
name: Setup poetry env
8689
if: ${{ inputs.package-manager == 'poetry' }}
8790
with:
88-
cache-number: 1
91+
cache-number: ${{ inputs.cache-number }}
8992
runner-os: ${{ runner.os }}
9093
install-extras: ${{ inputs.install-extras }}
9194
virtual-repo-names: ${{ inputs.virtual-repo-names }}
@@ -95,9 +98,18 @@ jobs:
9598
name: Setup hatch env
9699
if: ${{ inputs.package-manager == 'hatch' }}
97100
with:
98-
cache-number: 1
101+
cache-number: ${{ inputs.cache-number }}
99102
runner-os: ${{ runner.os }}
100103

104+
- uses: MiraGeoscience/CI-tools/.github/actions/reusable-python-setup_pixi@DEVOPS-584
105+
name: Setup pixi env
106+
if: ${{ inputs.package-manager == 'pixi' }}
107+
with:
108+
cache-number: ${{ inputs.cache-number }}
109+
python-version: ${{ inputs.python-version }}
110+
JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }}
111+
JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }}
112+
101113
- name: Capture modified files
102114
if: github.event_name == 'pull_request'
103115
run: >-
@@ -113,6 +125,8 @@ jobs:
113125
pylint $FILES_PARAM
114126
elif ${{ inputs.package-manager == 'poetry' }}; then
115127
poetry run pylint $FILES_PARAM
128+
elif ${{ inputs.package-manager == 'pixi' }}; then
129+
pixi run pylint $FILES_PARAM
116130
else
117131
hatch run pylint $FILES_PARAM
118132
fi
@@ -124,6 +138,8 @@ jobs:
124138
pylint $source_dir tests
125139
elif ${{ inputs.package-manager == 'poetry' }}; then
126140
poetry run pylint $source_dir tests
141+
elif ${{ inputs.package-manager == 'pixi' }}; then
142+
pixi run pylint $source_dir tests
127143
else
128144
hatch run pylint $source_dir tests
129145
fi

0 commit comments

Comments
 (0)