Skip to content

Commit

Permalink
feat: dir option added (#4)
Browse files Browse the repository at this point in the history
- document the option in README.md
- test it in ci
  • Loading branch information
garbas authored Dec 10, 2024
1 parent 353d9b6 commit 2131fbc
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 3 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ jobs:
with:
channel: "${{ matrix.channel }}"

- name: "Test Remote environment"
uses: "./"
with:
environment: "flox/python-pip"
command: "python --version"

- name: "Test Local Action"
uses: "./"
with:
environment: "flox/nb"
command: "python --version"
dir: "./test-env"
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ jobs:
uses: flox/activate-action@v1
with:
command: npm run build
dir: ./frontend

- name: Activate remote environment
uses: flox/activate-action@v1
with:
environment: my-username/my-netlify-env
command: netlify publish
```
## 📫 Have a question? Want to chat? Ran into a problem?
Expand Down
6 changes: 4 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ inputs:
environment:
description: "Environment to run the command in. If not specified it will try to find local Flox environment."
default: null
dir:
description: "Path containing a .flox/ directory."
default: null

runs:
using: "composite"
steps:
# TODO: automatically login to floxhub if not logged in already and FLOX_TOKEN is present
- name: "Run flox activate"
shell: "bash"
run: "flox activate ${{ inputs.environment != null && format('--remote={0}', inputs.environment) || '' }} -- ${{ inputs.command }}"
run: "flox activate ${{ inputs.environment != null && format('--remote={0}', inputs.environment) || '' }} ${{ inputs.dir != null && format('--dir={0}', inputs.dir) || '' }} -- ${{ inputs.command }}"
4 changes: 4 additions & 0 deletions test-env/.flox/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
run/
cache/
lib/
log/
4 changes: 4 additions & 0 deletions test-env/.flox/env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "test-env",
"version": 1
}
145 changes: 145 additions & 0 deletions test-env/.flox/env/manifest.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
"lockfile-version": 1,
"manifest": {
"version": 1,
"install": {
"python3": {
"pkg-path": "python3"
}
},
"hook": {},
"profile": {},
"options": {
"systems": [
"aarch64-darwin",
"aarch64-linux",
"x86_64-darwin",
"x86_64-linux"
],
"allow": {
"licenses": []
},
"semver": {}
}
},
"packages": [
{
"attr_path": "python3",
"broken": false,
"derivation": "/nix/store/f9hl5kjzr19apnwr86r91sg8l1vhp9df-python3-3.12.7.drv",
"description": "High-level dynamically-typed programming language",
"install_id": "python3",
"license": "Python-2.0",
"locked_url": "https://github.com/flox/nixpkgs?rev=22c3f2cf41a0e70184334a958e6b124fb0ce3e01",
"name": "python3-3.12.7",
"pname": "python3",
"rev": "22c3f2cf41a0e70184334a958e6b124fb0ce3e01",
"rev_count": 718224,
"rev_date": "2024-12-07T14:17:20Z",
"scrape_date": "2024-12-09T04:05:32Z",
"stabilities": [
"unstable"
],
"unfree": false,
"version": "3.12.7",
"outputs_to_install": [
"out"
],
"outputs": {
"out": "/nix/store/7c494qcmh62av43zsxr3wvzh8hcpy1vl-python3-3.12.7"
},
"system": "aarch64-darwin",
"group": "toplevel",
"priority": 5
},
{
"attr_path": "python3",
"broken": false,
"derivation": "/nix/store/zmj2nziiz98ndjap1hbhnvc8bwd4rakd-python3-3.12.7.drv",
"description": "High-level dynamically-typed programming language",
"install_id": "python3",
"license": "Python-2.0",
"locked_url": "https://github.com/flox/nixpkgs?rev=22c3f2cf41a0e70184334a958e6b124fb0ce3e01",
"name": "python3-3.12.7",
"pname": "python3",
"rev": "22c3f2cf41a0e70184334a958e6b124fb0ce3e01",
"rev_count": 718224,
"rev_date": "2024-12-07T14:17:20Z",
"scrape_date": "2024-12-09T04:05:32Z",
"stabilities": [
"unstable"
],
"unfree": false,
"version": "3.12.7",
"outputs_to_install": [
"out"
],
"outputs": {
"debug": "/nix/store/s5biairx04d930rlh4szdbqsrai3w8gm-python3-3.12.7-debug",
"out": "/nix/store/c1fbv3y657fp2m514gjxqqgqfsvayp6v-python3-3.12.7"
},
"system": "aarch64-linux",
"group": "toplevel",
"priority": 5
},
{
"attr_path": "python3",
"broken": false,
"derivation": "/nix/store/bvr6nhyqhbzy2w869f0xlsvj0y5qw55v-python3-3.12.7.drv",
"description": "High-level dynamically-typed programming language",
"install_id": "python3",
"license": "Python-2.0",
"locked_url": "https://github.com/flox/nixpkgs?rev=22c3f2cf41a0e70184334a958e6b124fb0ce3e01",
"name": "python3-3.12.7",
"pname": "python3",
"rev": "22c3f2cf41a0e70184334a958e6b124fb0ce3e01",
"rev_count": 718224,
"rev_date": "2024-12-07T14:17:20Z",
"scrape_date": "2024-12-09T04:05:32Z",
"stabilities": [
"unstable"
],
"unfree": false,
"version": "3.12.7",
"outputs_to_install": [
"out"
],
"outputs": {
"out": "/nix/store/c0zcl6sav8305n3pb1crk2ysrlfk9ppk-python3-3.12.7"
},
"system": "x86_64-darwin",
"group": "toplevel",
"priority": 5
},
{
"attr_path": "python3",
"broken": false,
"derivation": "/nix/store/yjlx78f4khvqxa9d3j906qk8vdh6bd3r-python3-3.12.7.drv",
"description": "High-level dynamically-typed programming language",
"install_id": "python3",
"license": "Python-2.0",
"locked_url": "https://github.com/flox/nixpkgs?rev=22c3f2cf41a0e70184334a958e6b124fb0ce3e01",
"name": "python3-3.12.7",
"pname": "python3",
"rev": "22c3f2cf41a0e70184334a958e6b124fb0ce3e01",
"rev_count": 718224,
"rev_date": "2024-12-07T14:17:20Z",
"scrape_date": "2024-12-09T04:05:32Z",
"stabilities": [
"unstable"
],
"unfree": false,
"version": "3.12.7",
"outputs_to_install": [
"out"
],
"outputs": {
"debug": "/nix/store/66ln8wcdigr854aacj657zfjilwn4lrv-python3-3.12.7-debug",
"out": "/nix/store/zv1kaq7f1q20x62kbjv6pfjygw5jmwl6-python3-3.12.7"
},
"system": "x86_64-linux",
"group": "toplevel",
"priority": 5
}
]
}
59 changes: 59 additions & 0 deletions test-env/.flox/env/manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# This is a Flox environment manifest.
# Visit flox.dev/docs/concepts/manifest/
# or see flox-edit(1), manifest.toml(5) for more information.
#
# Flox manifest version managed by Flox CLI
version = 1

# List packages you wish to install in your environment inside
# the `[install]` section.
[install]
python3.pkg-path = "python3"
# hello.pkg-path = "hello"
# nodejs = { version = "^20.15.1", pkg-path = "nodejs" }

# Set environment variables in the `[vars]` section. These variables may not
# reference one another, and are added to the environment without first
# expanding them. They are available for use in the `[profile]` and `[hook]`
# scripts.
[vars]
# message = "Howdy"

# The `hook.on-activate` script is run by the *bash* shell immediately upon
# activating an environment, and will not be invoked if Flox detects that the
# environment has previously been activated. Variables set by the script will
# be inherited by `[profile]` scripts defined below. Note that any stdout
# generated by the script will be redirected to stderr.
[hook]
# on-activate = '''
# # Set variables, create files and directories
# venv_dir="$(mktemp -d)"
# export venv_dir
#
# # Perform initialization steps, e.g. create a python venv
# python -m venv "$venv_dir"
# '''

# Scripts defined in the `[profile]` section are *sourced* by *your shell* and
# inherit environment variables set in the `[vars]` section and by `[hook]` scripts.
# The `profile.common` script is sourced by all shells and special care should be
# taken to ensure compatibility with all shells, after which exactly one of
# `profile.{bash,fish,tcsh,zsh}` is sourced by the corresponding shell.
[profile]
# common = '''
# echo "it's gettin' flox in here"
# '''

# The `[services]` section of the manifest allows you to define services.
# Services defined here use the packages provided by the `[install]` section
# and any variables you've defined in the `[vars]` section or `hook.on-activate` script.
[services]
# postgres.command = "postgres --config-file=pg.conf"

# Additional options can be set in the `[options]` section. Refer to
# manifest.toml(5) for a list of available options.
[options]
systems = ["aarch64-darwin", "aarch64-linux", "x86_64-darwin", "x86_64-linux"]
# Uncomment to disable CUDA detection.
# cuda-detection = false

0 comments on commit 2131fbc

Please sign in to comment.