Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- id: roc-lint
name: Lint runs-on.yml files
entry: roc lint
language: system
files: ^.*runs-on\.yml$
pass_filenames: true
description: Validate runs-on.yml configuration files using roc lint

8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ bump-readme:
@VERSION=$$(echo $(TAG) | sed 's/^v//'); \
README_TAG=$$(grep -oE 'releases/download/v[0-9]+\.[0-9]+\.[0-9]+' README.md | head -n 1 | sed 's|releases/download/||'); \
README_VERSION=$$(echo $$README_TAG | sed 's/^v//'); \
README_REV=$$(grep -oE 'rev: v[0-9]+\.[0-9]+\.[0-9]+' README.md | head -n 1 | sed 's|rev: ||'); \
if [ -z "$$README_TAG" ]; then \
echo "No version tag found in download URLs, updating placeholder versions"; \
sed -i.bak "s|v0\.0\.0|$(TAG)|g" README.md; \
sed -i.bak "s|roc_0\.0\.0|roc_$$VERSION|g" README.md; \
sed -i.bak "s|rev: v[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*|rev: $(TAG)|g" README.md; \
rm -f README.md.bak; \
else \
echo "Current tag: $(TAG)"; \
Expand All @@ -40,10 +42,16 @@ bump-readme:
echo "Updating README.md: $$README_TAG -> $(TAG), roc_$$README_VERSION -> roc_$$VERSION"; \
sed -i.bak "s|releases/download/$$README_TAG|releases/download/$(TAG)|g" README.md; \
sed -i.bak "s|roc_$$README_VERSION|roc_$$VERSION|g" README.md; \
sed -i.bak "s|rev: $$README_TAG|rev: $(TAG)|g" README.md; \
rm -f README.md.bak; \
else \
echo "README.md already contains $(TAG)"; \
fi; \
if [ -n "$$README_REV" ] && [ "$$README_REV" != "$(TAG)" ]; then \
echo "Updating pre-commit rev: $$README_REV -> $(TAG)"; \
sed -i.bak "s|rev: $$README_REV|rev: $(TAG)|g" README.md; \
rm -f README.md.bak; \
fi; \
fi; \
if git diff --exit-code README.md > /dev/null 2>&1; then \
echo "README.md already up to date"; \
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,32 @@ else
fi
```

**Pre-commit hook:**

You can use `roc lint` as a pre-commit hook to automatically validate `runs-on.yml` files before committing. First, install [pre-commit](https://pre-commit.com/):

```bash
pip install pre-commit
```

Then add the hook to your `.pre-commit-config.yaml`:

```yaml
repos:
- repo: https://github.com/runs-on/cli
rev: v0.1.12 # Use the latest release tag
hooks:
- id: roc-lint
```

Finally, install the git hook scripts:

```bash
pre-commit install
```

Now `roc lint` will automatically run on staged `runs-on.yml` files before each commit. The commit will be blocked if validation errors are found.

## Stack Management

### `roc stack doctor`
Expand Down