Skip to content
Open
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
61 changes: 61 additions & 0 deletions .github/workflows/nix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
name: nix
on:
push:
pull_request:
permissions:
contents: read
pull-requests: read
concurrency:
group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
test-go-versions:
strategy:
fail-fast: false
matrix:
go-version: ['124', '125']
os:
- system: x86_64-linux
runs-on: ubuntu-24.04
- system: aarch64-darwin
runs-on: macos-14
runs-on: ${{ matrix.os.runs-on }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
accept-flake-config = true
- name: Setup Cachix
uses: cachix/cachix-action@v15
with:
name: devenv
- name: Build with Go 1.${{ matrix.go-version }} on ${{ matrix.os.system }}
run: nix build .#packages.${{ matrix.os.system }}.go-jsonschema-go${{ matrix.go-version }} --print-build-logs
- name: Test with Go 1.${{ matrix.go-version }} on ${{ matrix.os.system }}
run: nix build .#checks.${{ matrix.os.system }}.tests-go${{ matrix.go-version }} --print-build-logs
- name: Upload coverage to Codecov
if: matrix.go-version == '125' && matrix.os.system == 'x86_64-linux'
uses: codecov/codecov-action@v5
with:
files: ./result/coverage.out
fail_ci_if_error: false
qa:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
accept-flake-config = true
- name: Setup Cachix
uses: cachix/cachix-action@v15
with:
name: devenv
- name: Run Nix flake checks
run: nix flake check --print-build-logs --show-trace
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ mise.toml.tmp
dist/
output/
vendor/
.direnv
result
.pre-commit-config.yaml
*.log
8 changes: 4 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ archives:
checksum:
name_template: checksums.txt
snapshot:
version_template: "{{ incpatch .Version }}-next"
version_template: '{{ incpatch .Version }}-next'
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
- '^docs:'
- '^test:'
release:
github:
owner: omissis
name: go-jsonschema
name_template: "{{ .Tag }}"
name_template: '{{ .Tag }}'
prerelease: auto
brews:
- name: go-jsonschema
Expand Down
1 change: 1 addition & 0 deletions .rules/yamllint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ ignore: |
**/node_modules/**
**/helm_chart/**
**/.github/**
.pre-commit-config.yaml
42 changes: 39 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ along with unmarshalling code that validates the input JSON according to the sch

## Installing

* **Download**: Get a release [here](https://github.com/atombender/go-jsonschema/releases).
* **Download**: Get a release from the
[releases page](https://github.com/atombender/go-jsonschema/releases).

* **Install from source**: To install with Go 1.23+:

Expand All @@ -42,6 +43,40 @@ This project makes use of [go workspaces](https://go.dev/ref/mod#workspaces) in
generated code during development while keeping the codebase as tidy and maintainable as possible.
It's an unusual choice, but it allows to not only test the code-generation logic, but also the generated code itself.

## Nix Development Environment

This project uses [Nix](https://nixos.org/) for reproducible development environments and CI/CD.
Nix solves dependency management across different systems, ensuring consistent builds and tests regardless of your
local setup.

### Quick Start

```shell
# Enter development shell with all tools
nix develop

# Run all checks (tests, lints, formatting)
nix flake check

# Run specific checks
nix build .#checks.x86_64-linux.tests-go125 # Integration tests
nix build .#checks.x86_64-linux.lint-golang # Go linting
nix build .#checks.x86_64-linux.build-goreleaser # GoReleaser build

# Format code
nix fmt

# Test CI workflows locally
nix run .#test-ci
```

### Why Nix?

- **Reproducible builds**: Same dependencies across all environments (dev, CI, production)
- **Hermetic testing**: Tests run in isolated sandboxes with no external network access
- **Multi-version support**: Test against Go 1.24 and 1.25 simultaneously
- **No Docker required**: Native support for NixOS and other Linux distributions

## Usage

At its most basic:
Expand Down Expand Up @@ -76,9 +111,10 @@ Note the flag format:

### Regenerating tests' golden files

It sometimes happen that new features or bug fixes to the library require regenerating the tests' golden files, here's how to do it:
It sometimes happen that new features or bug fixes to the library require
regenerating the tests' golden files, here's how to do it:

```
```shell
export OVERWRITE_EXPECTED_GO_FILE="true"
make test
```
Expand Down
42 changes: 20 additions & 22 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
ignore:
- "**/*.json"
- "**/*.md"
- "**/*.mod"
- "**/*.sum"
- "**/*.yaml"
- "**/*.yml"
- "**/*_test.go"
- "**/Dockerfile"
- "**/LICENSE"
- "**/Makefile"
- ".github/"
- ".rules/"
- ".vscode/"
- "coverage/"
- "dist/"
- "docs/"
- "output/"
- "scripts/"

- '**/*.json'
- '**/*.md'
- '**/*.mod'
- '**/*.sum'
- '**/*.yaml'
- '**/*.yml'
- '**/*_test.go'
- '**/Dockerfile'
- '**/LICENSE'
- '**/Makefile'
- .github/
- .rules/
- .vscode/
- coverage/
- dist/
- docs/
- output/
- scripts/
codecov:
require_ci_to_pass: true
branch: main

coverage:
status:
project:
app:
target: auto
paths: "!tests/"
paths: '!tests/'
tests:
target: auto
paths: "tests/"
paths: tests/
patch:
enabled: true
target: auto
Expand Down
142 changes: 142 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading