Skip to content
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

Update install task and create pre-commit task #27

Merged
merged 8 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions install/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ runs:
run: echo "ENVS_PATH=${{ format('{0}/{1}', env.CONDA, 'envs') }}" >> $GITHUB_ENV
shell: bash -el {0}
- if: inputs.cache == 'true'
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: ${{ env.ENVS_PATH }}
key: ${{ inputs.name }}-${{ runner.os }}-${{ inputs.conda-mamba }}-${{ inputs.python-version }}-${{ hashFiles('setup.py') }}-${{ env.TODAY }}
key: ${{ inputs.name }}-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('setup.py') }}-${{ env.TODAY }}
id: cache
- run: |
echo "::group::Setup conda-libmamba-solver"
Expand Down Expand Up @@ -178,5 +178,16 @@ runs:
echo "::group::Capture environment"
conda activate test-environment
doit env_capture
conda env export > environment_${{ inputs.name }}_${{ inputs.python-version }}_${{ runner.os }}.yml
echo "REPO_NAME=$(basename ${{ github.repository }})" >> $GITHUB_ENV
echo "::endgroup::"
shell: bash -el {0}
- uses: actions/upload-artifact@v3
with:
name: ${{ env.REPO_NAME }}_${{ github.event.number }}
path: environment_${{ inputs.name }}_${{ inputs.python-version }}_${{ runner.os }}.yml
- if: inputs.cache == 'true' && steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ${{ env.ENVS_PATH }}
key: ${{ inputs.name }}-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('setup.py') }}-${{ env.TODAY }}
22 changes: 22 additions & 0 deletions pre-commit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Pre-commit Action for HoloViz CI

This action runs the pre-commit actions and will output the results to the summary page.

## Example

Here is an example using the pre-commit action to set up and cache a complicated environment:
hoxbro marked this conversation as resolved.
Show resolved Hide resolved

```yaml
jobs:
pre_commit:
name: Run pre-commit
runs-on: "ubuntu-latest"
steps:
- uses: holoviz-dev/holoviz_tasks/pre-commit@main
```

## Summary page

The summary page will show the results of the pre-commit actions.

![Summary page](example.png)
35 changes: 35 additions & 0 deletions pre-commit/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Run pre-commit
description: Run pre-commit

runs:
using: "composite"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: "1"
- name: set PY
shell: bash -el {0}
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- name: "Install pre-commit"
shell: bash -el {0}
run: pipx install pre-commit
- uses: actions/cache/restore@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
id: cache
- if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: "Run pre-commit"
shell: bash -e {0}
run: |
echo '```console' > $GITHUB_STEP_SUMMARY
# Enable color output for pre-commit and remove it for the summary
pre-commit run --all-files --show-diff-on-failure --color=always | \
tee >(sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[mGK]//g' >> $GITHUB_STEP_SUMMARY) >&1
exit_code=${PIPESTATUS[0]}
echo '```' >> $GITHUB_STEP_SUMMARY
exit $exit_code
Binary file added pre-commit/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.