-
Notifications
You must be signed in to change notification settings - Fork 0
Add create-pixi-lock action
#1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9164eaa
dbe36f8
c6461a1
97e4e5e
1bffeff
e82dcf7
b473bf1
85a6a81
cec51cb
0913a52
58b4056
6e70a6e
be63ffa
011e2f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # SCM syntax highlighting & preventing 3-way merges | ||
| pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| name: Test cache-pixi-lock action | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, test-me/*] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| PIXI_VERSION: "v0.63.0" | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-latest, macos-latest, windows-latest] | ||
| cache-frequency: [daily, weekly, monthly] | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| path: create-pixi-lock | ||
|
|
||
| - name: Copy test files to working directory | ||
| shell: bash | ||
| run: cp -r create-pixi-lock/ci/test/* . | ||
|
|
||
| - name: Run create-pixi-lock action | ||
| uses: ./create-pixi-lock | ||
| with: | ||
| cache-frequency: ${{ matrix.cache-frequency }} | ||
| pixi-version: ${{ env.PIXI_VERSION }} | ||
|
|
||
| - name: Verify pixi.lock exists | ||
| shell: bash | ||
| run: | | ||
| if [ -f "pixi.lock" ]; then | ||
| echo "pixi.lock exists" | ||
| else | ||
| echo "pixi.lock does not exist" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Setup pixi and install environment | ||
| uses: prefix-dev/setup-pixi@v0.9.3 | ||
| with: | ||
| pixi-version: ${{ env.PIXI_VERSION }} | ||
|
Comment on lines
+50
to
+53
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do get an error which to be honest I did expect - I didn't think Also I just saw
in the README.md - making using Is there a way that we can, in the lock generation, install pixi to a set location (unlikely to interfere with other things), generate the lock file, all while being cross platform?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Looking at the guts of setup-pixi https://github.com/prefix-dev/setup-pixi/blob/51b98037a96d8c8de9468a767400f984d173fd90/src/util.ts#L60-L71 - uhhhh, maybe not as simple as I hoped! 😅
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And looks like Docker container actions are Linux only - that was going to be my next try 😭 https://docs.github.com/en/actions/concepts/workflows-and-actions/custom-actions#types-of-actions Hopefully someone has more ideas |
||
|
|
||
|
|
||
| - name: Verify environment installed | ||
| shell: bash | ||
| run: | | ||
| if [ -d ".pixi/envs/default" ]; then | ||
| echo "Environment installed successfully" | ||
| else | ||
| echo "Environment not installed" | ||
| exit 1 | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # pixi environments | ||
| .pixi/* | ||
| !.pixi/config.toml | ||
|
|
||
| pixi.lock |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v6.0.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| - id: end-of-file-fixer | ||
| - id: check-yaml | ||
| - id: check-ast | ||
| - id: check-json | ||
| types: [text] | ||
| files: \.(json|ipynb)$ | ||
| - repo: https://github.com/rbubley/mirrors-prettier # Update mirror as official mirror is deprecated | ||
| rev: v3.6.2 | ||
| hooks: | ||
| - id: prettier | ||
| - repo: https://github.com/ComPWA/taplo-pre-commit | ||
| rev: v0.9.3 | ||
| hooks: | ||
| - id: taplo-format | ||
| args: | ||
| [ | ||
| "--option", | ||
| "array_auto_collapse=false", | ||
| "--option", | ||
| "align_comments=false", | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # create-pixi-lock | ||
|
|
||
| > [!NOTE] | ||
| > This repo is likely to be moved to https://github.com/xarray-contrib | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. depending on how useful this is it might actually make sense to ask the pixi devs whether they would like to move it to the official pixi org |
||
|
|
||
| This action creates a `pixi.lock` file and caches it for future use. Subsequent runs of this action on the same day restore the lock file instead of generating it anew. | ||
|
|
||
|
|
||
| ## Usage | ||
|
|
||
| Basic usage with a set version of Pixi as well as daily cached lockfile: | ||
|
|
||
| ```yaml | ||
| env: | ||
| PIXI_VERSION: "v0.63.0" | ||
|
|
||
| # ... | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: Parcels-code/create-pixi-lock@v1 | ||
| with: | ||
| pixi-version: ${{ env.PIXI_VERSION }} # Default is latest - same as setup-pixi | ||
| cache-frequency: daily # options are "daily", "weekly", "monthly". Default "daily" | ||
| - uses: prefix-dev/setup-pixi@v0.9.3 | ||
| with: | ||
| pixi-version: ${{ env.PIXI_VERSION }} | ||
| ``` | ||
|
|
||
| > [!NOTE] | ||
| > Pinning your Pixi version in CI and updating this pin manually ensures better | ||
| > stability. Otherwise updates to Pixi which introduce breaking changes in: | ||
| > - (a) the format of the lock file - which would break your CI for a period of `cache-frequency`, or | ||
| > - (b) the format of `pixi.toml` - which would break your CI until you fix it. | ||
|
|
||
| ## Why not commit the lock file? | ||
|
|
||
| Committing your lock file is considered good practice when working on application code. Providing fixed package versions results in perfect reproducibility of environments between machines, and hence also reproducibility of results. | ||
|
|
||
| When developing and testing _library_ code, we don't want our environments to stay completely fixed - we want to test against environments covering a wide range of package versions to ensure compatability, including an environment that includes the latest available versions of packages. | ||
|
|
||
| The easiest way to test against the latest versions of packages - and avoid the noisy commit history (and additional overhead) of regularly updating a lock file in git - is instead to ignore the lock file and rely on developers and CI to generate their own lock files. This forgoes perfect reprodubility between developer machines, and with CI machines. | ||
|
|
||
|
|
||
| ## Dev notes | ||
|
|
||
| ### Release checklist | ||
|
|
||
| - Update the `README.md` bumping the version of action | ||
| - Cut release | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| name: Create Pixi Lock | ||
| description: Generate and cache a pixi.lock file, restoring from cache when available. | ||
|
|
||
| inputs: | ||
| pixi-version: | ||
| description: "Version of pixi to use for generating the lock file" | ||
| required: false | ||
| default: "latest" | ||
| cache-frequency: | ||
| description: "How often to regenerate the lock file: 'daily', 'weekly', or 'monthly'" | ||
| required: false | ||
| default: "daily" | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Get cache key | ||
| id: cache-key | ||
| shell: bash | ||
| run: | | ||
| case "${{ inputs.cache-frequency }}" in | ||
| daily) | ||
| key=$(date +'%Y-%m-%d') | ||
| ;; | ||
| weekly) | ||
| key=$(date +'%Y-week-%V') | ||
| ;; | ||
| monthly) | ||
| key=$(date +'%Y-month-%m') | ||
| ;; | ||
| *) | ||
| echo "Invalid cache-frequency: ${{ inputs.cache-frequency }}. Must be 'daily', 'weekly', or 'monthly'." | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| echo "key=$key" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Restore pixi.lock from cache | ||
| uses: actions/cache/restore@v5 | ||
| id: restore | ||
| with: | ||
| path: pixi.lock | ||
| key: ${{ steps.cache-key.outputs.key }}_${{ inputs.pixi-version }}_${{ hashFiles('pixi.toml') }} | ||
|
|
||
| - name: Setup pixi | ||
| uses: prefix-dev/setup-pixi@v0.9.3 | ||
| if: ${{ !steps.restore.outputs.cache-hit }} | ||
| with: | ||
| pixi-version: ${{ inputs.pixi-version }} | ||
| run-install: false | ||
|
Comment on lines
+45
to
+50
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a concern with using |
||
|
|
||
| - name: Run pixi lock | ||
| if: ${{ !steps.restore.outputs.cache-hit }} | ||
| shell: bash | ||
| run: pixi lock | ||
|
|
||
| - name: Save pixi.lock to cache | ||
| uses: actions/cache/save@v5 | ||
| if: ${{ !steps.restore.outputs.cache-hit }} | ||
| with: | ||
| path: pixi.lock | ||
| key: ${{ steps.cache-key.outputs.key }}_${{ inputs.pixi-version }}_${{ hashFiles('pixi.toml') }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [workspace] | ||
| authors = ["Vecko <36369090+VeckoTheGecko@users.noreply.github.com>"] | ||
| channels = ["conda-forge"] | ||
| name = "test" | ||
| platforms = ["win-64", "linux-64", "osx-64", "osx-arm64", "linux-aarch64"] | ||
| version = "0.1.0" | ||
|
|
||
| [tasks] | ||
|
|
||
| [dependencies] | ||
| python = "*" | ||
| numpy = "*" | ||
| pandas = "*" | ||
| xarray = "*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pinning the version of Pixi for now. Thinking of making dependabot manage this - though that would come in a future PR