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
18 changes: 9 additions & 9 deletions .github/workflows/run-pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
uses: actions/checkout@v4.2.2
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v16
- name: Cache Nix environment
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Use Nix dev shell for subsequent steps
uses: rrbutani/use-nix-shell-action@v1
with:
python-version: "3.11"
- name: Install Roc
uses: hasnep/setup-roc@main
with:
roc-version: 0.0.0-alpha2-rolling
extraNixOptions: --accept-flake-config
- name: Run Pre-commit
uses: pre-commit/action@v3.0.1
run: pre-commit run --all-files
env:
# Prevent this action failing when running on the main branch
SKIP: no-commit-to-branch
72 changes: 44 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
repos:
# General checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
- repo: local
hooks:
- name: Prevent committing to main
id: no-commit-to-branch
language: system
entry: no-commit-to-branch
args: [--branch, main]
pass_filenames: false
- name: Make sure files end with a newline character
id: end-of-file-fixer
language: system
entry: end-of-file-fixer
types: [text]
- name: Remove trailing whitespace
id: trailing-whitespace
id: trailing-whitespace-fixer
language: system
entry: trailing-whitespace-fixer
types: [text]
- name: Check for files that would conflict on case-insensitive filesystem
id: check-case-conflict
language: system
entry: check-case-conflict
- name: Check for merge conflicts
id: check-merge-conflict
language: system
entry: check-merge-conflict
- name: Check executable files have a shebang
id: check-executables-have-shebangs
language: system
entry: check-executables-have-shebangs
types: [executable]
- name: Check scripts with a shebang are executable
id: check-shebang-scripts-are-executable
language: system
entry: check-shebang-scripts-are-executable
- name: Don't allow adding large files
id: check-added-large-files
language: system
entry: check-added-large-files

# Roc
- repo: https://github.com/hasnep/pre-commit-roc
Expand All @@ -32,42 +51,39 @@ repos:
id: format

# YAML
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- name: Validate YAML
id: check-yaml
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
- repo: local
hooks:
- name: Format YAML files
id: prettier
id: yaml-format
language: system
entry: prettier --write
types: [yaml]

# Markdown
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
- repo: local
hooks:
- name: Format markdown files
id: prettier
id: markdown-format
language: system
entry: prettier --write
types: [markdown]

# GitHub Actions
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.23.2
- repo: local
hooks:
- name: Validate GitHub Actions workflow files
id: check-github-workflows
id: github-workflows-check
language: system
entry: actionlint
types: [yaml]
files: \.github/workflows/.*\.ya?ml$

# Pre-commit
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.23.2
# Nix
- repo: local
hooks:
- name: Validate Pre-commit config
id: check-jsonschema
files: ^.*\.pre-commit-config.yaml$
args:
[
"--schemafile",
"https://json.schemastore.org/pre-commit-config.json",
]
- name: Format Nix files
id: nix-format
language: system
entry: alejandra
args: [--quiet]
types: [nix]
15 changes: 6 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@
extra-trusted-substituters = "https://roc-lang.cachix.org";
};

outputs = inputs @ {
self,
nixpkgs,
flake-parts,
roc,
...
}:
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux"];
perSystem = {
Expand All @@ -28,10 +22,13 @@
name = "roc-math";
packages = [
inputs'.roc.packages.cli
pkgs.just
pkgs.pre-commit
pkgs.actionlint
pkgs.alejandra
pkgs.fd
pkgs.just
pkgs.nodePackages.prettier
pkgs.pre-commit
pkgs.python312Packages.pre-commit-hooks
];
enterShell = "pre-commit install --overwrite";
};
Expand Down
Loading