-
Notifications
You must be signed in to change notification settings - Fork 119
WIP: build: add Nix flake infrastructure with unified tooling and formatting #487
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
Open
albertodvp
wants to merge
14
commits into
omissis:main
Choose a base branch
from
albertodvp:feat/nix-infrastructure
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+698
−77
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add Nix flake with flake-parts for building and developing go-jsonschema: - Package definition with buildGoModule - Test suite as a check derivation - Development shell with all required tools from mise.toml: - golang, golangci-lint, goreleaser - hadolint, markdownlint-cli2, shellcheck, shfmt - yamllint, yq, jsonlint, checkmake - adr-tools, gofumpt, jq This provides reproducible development environments across all systems.
Add comprehensive Nix check derivations to flake.nix: Test checks: - go-jsonschema-tests: Run test suite with coverage output Lint checks: - lint-golang: golangci-lint validation - lint-dockerfile: hadolint validation - lint-json: jsonlint validation - lint-makefile: checkmake validation - lint-markdown: markdownlint-cli2 validation - lint-shell: shellcheck validation - lint-yaml: yamllint validation Build checks: - build-goreleaser: goreleaser build test These checks can be run with 'nix flake check' and provide the foundation for CI automation. Each check is a separate derivation that can be built and cached independently.
Integrate treefmt-nix for unified code formatting: Formatters configured: - Nix files (alejandra) - Shell scripts (shfmt with 2-space indent, -ci, -sr flags) - Markdown (markdownlint-cli2 with project rules from .rules/) Disabled formatters to avoid test data changes: - Go formatters (gofmt, gofumpt, goimports) - JSON formatter (jq) - YAML formatter (yq) - causes file timestamp issues Features: - Run 'nix fmt' to format all supported files - Set as default formatter output - treefmt.build.wrapper available in devShell - Excludes .direnv/, result/, .git/ from formatting This provides a single command to format code across multiple languages while respecting project-specific rules and test data integrity.
Integrate git-hooks.nix for automatic code formatting on commit: Pre-commit hook configuration: - Runs treefmt on staged files before each commit - Auto-installs when entering 'nix develop' - Formats code automatically (no --fail-on-change) - Added to flake checks for CI validation Changes: - Added git-hooks.nix flake input - Configured treefmt hook in pre-commit.settings - Added pre-commit.installationScript to devShell hook - Added .pre-commit-config.yaml to .gitignore This ensures code is always formatted before commits, reducing review friction and maintaining consistent code style across contributions.
Add automated CI workflow using Nix flake infrastructure: Workflow steps: 1. Install Nix with flake support 2. Setup Cachix (devenv cache) for faster builds 3. Check code formatting with 'nix fmt --check' 4. Run all flake checks with 'nix flake check' 5. Build package with 'nix build' 6. Upload test coverage to Codecov Benefits: - Single workflow validates all code quality (tests, lints, builds) - Cachix caching speeds up CI runs - Hermetic builds - same results as local development - Runs on ubuntu-24.04 with same concurrency controls as existing workflow This provides an alternative to the mise-based development workflow, with all checks unified under 'nix flake check'.
Apply treefmt formatting across the codebase: Files formatted: - README.md: Fixed markdown linting issues - MD059: Use descriptive link text instead of [here] - MD013: Wrap long lines to 120 characters - MD040: Add language identifier to code fence - .goreleaser.yaml: YAML formatting (2-space indent) - codecov.yml: YAML formatting (2-space indent) - tests/data/.../gopkgYAMLv3AdditionalProperties.yaml: YAML formatting This demonstrates the formatting tools are working correctly and brings the codebase into compliance with the configured rules.
Add support for building and testing with multiple Go versions: Flake changes: - Refactored package and test derivations into reusable functions - Added go-jsonschema-go124 and go-jsonschema-go125 packages - Added tests-go124 and tests-go125 check derivations - Extracted cleanSrc for code deduplication GitHub Actions workflow: - Added matrix strategy to test Go 1.24 and 1.25 - Split workflow into test-go-versions and qa jobs - Upload coverage only from Go 1.25 tests - Fail-fast disabled to test all versions This ensures compatibility across supported Go versions and catches version-specific issues early in CI.
Remove branch restriction from nix workflow to run on all pushes, not just main branch. This ensures CI validation runs on feature branches and pull requests.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #487 +/- ##
=======================================
Coverage ? 40.92%
=======================================
Files ? 66
Lines ? 5625
Branches ? 0
=======================================
Hits ? 2302
Misses ? 3047
Partials ? 276 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- use buildGoModule for build-goreleaser check with vendor support - skip network-dependent steps (before hook, docker builds) in goreleaser - split test checks into main module and integration tests with separate vendorHash - configure lint-golang to use vendored dependencies via --modules-download-mode - exclude tests/ directory from main module linting (separate go module) These changes ensure all Nix checks pass in isolated sandbox without network access.
Document Nix setup for reproducible development: - quick start commands (develop, check, build, fmt) - benefits: hermetic testing, multi-version support, no docker dependency - explain why Nix was introduced (reproducible builds, consistent environments)
Apply Go 1.18+ improvements and performance optimizations:
- replace interface{} with any for modern Go syntax
- use strings.Builder instead of += in loops for better performance
- replace reflect.TypeOf with reflect.TypeFor for type safety
- use strings.CutPrefix instead of HasPrefix + TrimPrefix
- simplify conditionals using max() builtin
- replace manual loops with slices.Contains
These changes improve code readability, performance, and align with current Go best practices.
84cbe9d to
49090b4
Compare
- test both Go versions (1.24, 1.25) on x86_64-linux and aarch64-darwin - fix flake attribute paths (use checks.<system>.tests-go* instead of packages) - add proper system-aware build paths (packages.<system>.go-jsonschema-go*) - restrict codecov upload to x86_64-linux only to avoid duplicate reports
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a Nix flake-based infrastructure to unify tooling
management, build processes, and code formatting across the project.
Motivation
Currently, the project has fragmented tooling management:
Docker)
This creates several problems: