Skip to content

Commit e7d8801

Browse files
Add devenv (#24)
Enables linting for typos (#23) and markdownlint (#22) and others, to ensure continued quality. The CI workflow automatically checks changes. It's based on the version from the Crystal repo and includes the latest update from crystal-lang/crystal#16682.
1 parent 500c460 commit e7d8801

File tree

6 files changed

+229
-0
lines changed

6 files changed

+229
-0
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# devenv
2+
.devenv.flake.nix -merge linguist-generated
3+
devenv.lock -merge linguist-generated

.github/workflows/lint.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Lint
2+
on:
3+
push:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
permissions: {}
8+
9+
jobs:
10+
prek:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Download source
14+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
15+
with:
16+
persist-credentials: false
17+
fetch-depth: 0
18+
- uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
19+
- uses: cachix/cachix-action@3ba601ff5bbb07c7220846facfa2cd81eeee15a1 # v16
20+
with:
21+
name: devenv
22+
- name: Install devenv.sh
23+
run: nix profile install nixpkgs#devenv
24+
- name: "Download target branch: ${{ github.base_ref || 'master' }}"
25+
run: git fetch origin "${TARGET_BRANCH}"
26+
- name: Check whether to run full test on all files
27+
id: test_full_run
28+
if: ${{ github.event_name != 'workflow_dispatch' }}
29+
run: |
30+
# Trigger full run if devenv.lock or this workflow file changed
31+
if git diff --quiet "origin/${TARGET_BRANCH}" HEAD -- devenv.lock .github/workflows/lint.yml; then
32+
echo "test_full_run=false" >> "$GITHUB_OUTPUT"
33+
else
34+
echo "test_full_run=true" >> "$GITHUB_OUTPUT"
35+
fi
36+
- name: Run prek on all files
37+
id: run_full
38+
run: prek run --all-files
39+
shell: devenv shell bash -- -e {0}
40+
if: ${{ github.event_name == 'workflow_dispatch' || steps.test_full_run.outputs.test_full_run == 'true' }}
41+
- name: Run prek hooks for changes against target branch (${{ github.base_ref || 'master' }})
42+
run: prek run --from-ref "origin/${TARGET_BRANCH}" --to-ref HEAD
43+
shell: devenv shell bash -- -e {0}
44+
if: "${{ steps.run_full.outcome == 'skipped' }}"
45+
env:
46+
TARGET_BRANCH: "${{ github.base_ref || 'master' }}"

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Environment configuration
2+
Makefile.local
3+
Makefile.win.local
4+
.env
5+
.env.*
6+
.envrc
7+
.envrc.*
8+
9+
# Devenv
10+
.devenv*
11+
devenv.local.nix
12+
devenv.local.yaml
13+
14+
# direnv
15+
.direnv
16+
17+
# pre-commit
18+
.pre-commit-config.yaml

devenv.lock

Lines changed: 139 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

devenv.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{ pkgs, lib, config, inputs, ... }:
2+
3+
{
4+
git-hooks.hooks = {
5+
actionlint.enable = true;
6+
check-toml.enable = true;
7+
check-vcs-permalinks.enable = true;
8+
markdownlint.enable = true;
9+
shellcheck = {
10+
enable = true;
11+
excludes = [
12+
".*\.zsh$"
13+
];
14+
};
15+
typos.enable = true;
16+
zizmor.enable = true;
17+
};
18+
}

devenv.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
inputs:
2+
git-hooks:
3+
url: github:cachix/git-hooks.nix
4+
nixpkgs:
5+
url: github:cachix/devenv-nixpkgs/rolling

0 commit comments

Comments
 (0)