Skip to content

Commit

Permalink
Fixes for the GHA action (#8)
Browse files Browse the repository at this point in the history
* pip install .

* fetch full repo?

* add SETUPTOOLS_SCM_PRETEND_VERSION

* cd

* Try with python parsing

* use triple quotes just in case

* unbuffer, split

* clean action

* amend pages

* enable jekyll
  • Loading branch information
jaimergp authored May 16, 2024
1 parent ffd9c8c commit 522d787
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 36 deletions.
79 changes: 46 additions & 33 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ runs:
run: |
echo "::error title=⛔ error hint::Only Linux is supported"
exit 1
- name: Validate arguments
- name: Validate inputs
shell: bash
id: validate
run: |
# Validate inputs
if [[
"${{ inputs.after }}" == ""
&& "${{ inputs.before }}" == ""
Expand All @@ -71,43 +72,54 @@ runs:
manifest-path: ${{ github.action_path }}/pyproject.toml
- name: Setup project
shell: bash
run: cd "${{ github.action_path }}" && pixi run --environment default dev
- name: Run subchannel
shell: pixi run --manifest-path "${{ github.action_path }}/pyproject.toml" --environment default bash -e {0}
run: |
args="--channel ${{ inputs.channel }}"
args+=" --output ${{ steps.validate.outputs.output-directory }}"
args+=" --repodata-fn ${{ inputs.repodata-fn }}"
for subdir in ${{ inputs.subdirs }}; do
args+=" --subdir $subdir"
done
if [[ "${{ inputs.after }}" != "" ]]; then
args+=" --after ${{ inputs.after }}"
fi
if [[ "${{ inputs.before }}" != "" ]]; then
args+=" --before ${{ inputs.before }}"
fi
if [[ "${{ inputs.keep-trees }}" != "" ]]; then
for spec in ${{ inputs.keep-trees }}; do
args+=" --keep-tree $spec"
done
fi
if [[ "${{ inputs.keep-specs }}" != "" ]]; then
for spec in ${{ inputs.keep-specs }}; do
args+=" --keep $spec"
done
fi
if [[ "${{ inputs.remove-specs }}" != "" ]]; then
for spec in ${{ inputs.remove-specs }}; do
args+=" --remove $spec"
done
fi
echo "Running: conda subchannel $args"
conda subchannel $args
# Install project
cd "${{ github.action_path }}"
SETUPTOOLS_SCM_PRETEND_VERSION=0.1 pixi run --environment default python -mpip install --no-deps .
- name: Prepare command
shell: pixi run --manifest-path "${{ github.action_path }}/pyproject.toml" --environment default python -u {0}
run: |
# Prepare and run conda subchannel
import subprocess
import sys
args = [
"--channel",
"""${{ inputs.channel }}""".strip(),
"--output",
"${{ steps.validate.outputs.output-directory }}",
"--repodata-fn",
"""${{ inputs.repodata-fn }}""".strip(),
]
after = """${{ inputs.after }}""".strip()
if after:
args += ["--after", after]
before = """${{ inputs.before }}""".strip()
if before:
args += ["--before", before]
subdirs = """${{ inputs.subdirs }}""".strip()
for subdir in subdirs.split():
args += ["--subdir", subdir]
keep_trees = """${{ inputs.keep-trees }}""".strip()
for spec in keep_trees.split():
args += ["--keep-tree", spec]
keep_specs = """${{ inputs.keep-specs }}""".strip()
for spec in keep_specs.split():
args += ["--keep", spec]
remove_specs = """${{ inputs.remove-specs }}""".strip()
for spec in remove_specs.split():
args += ["--remove", spec]
print("Running: conda subchannel", *args)
p = subprocess.run(
[sys.executable, "-mconda", "subchannel", *args],
)
sys.exit(p.returncode)
- name: Decide deployment
id: decide
shell: bash
run: |
# Decide if we deploy to GH Pages or not
if [[ "${{ inputs.gh-pages-branch }}" != "" && "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "deploy=true" >> $GITHUB_OUTPUT
else
Expand All @@ -122,3 +134,4 @@ runs:
publish_dir: ${{ steps.validate.outputs.output-directory }}
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
enable_jekyll: true
9 changes: 6 additions & 3 deletions conda_subchannel/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,22 @@ def _write_channel_index_md(source_channel: Channel, channel_path: Path):
"",
f"Derived from [{source_channel.name}]({source_channel.base_url})",
"",
""
"",
"Available subdirs:",
"",
]
for subdir in channel_path.glob("*"):
for subdir in sorted(channel_path.glob("*")):
if subdir.is_file():
continue
lines[-1] += f"[{subdir.name}]({subdir.name}) "
lines.append(f"- [{subdir.name}]({subdir.name})")
(channel_path / "index.md").write_text("\n".join(lines))


def _write_subdir_index_md(subdir_path: Path):
subdir_path = Path(subdir_path)
lines = [
f"# {'/'.join(subdir_path.parts[-2:])}",
"",
"| Filename | Size (B) | Last modified | SHA256 | MD5 |",
"|----------|----------|---------------|--------|-----|",
]
Expand Down

0 comments on commit 522d787

Please sign in to comment.