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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
33 changes: 33 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
on:
push:
branches:
- master
tags-ignore:
- '**'

jobs:
default:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: iffy/install-nim@v5.1.1
with:
version: stable
- run: nim build
- run: ./package_index sync-git "${{ github.event.before }}" "${{ github.sha }}" packages.json pkgs
- run: ./package_scanner packages.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
if [ -z "$(git status --porcelain -- packages.json pkgs)" ]; then
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add packages.json pkgs
git commit -m "Sync packages.json and pkgs [skip ci]"
git push
4 changes: 2 additions & 2 deletions .github/workflows/testpr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: iffy/install-nim@v5.1.1
with:
version: stable
- run: ./getmergebase.sh
- run: nim r -d:ssl -d:release package_scanner.nim packages.json --old=packages_old.json --check-urls
- run: nim build
- run: ./package_scanner packages.json --check-pr --check-urls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 0 additions & 13 deletions .github/workflows/testpush.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
pull_request:
paths:
- package_index.nim
- package_scanner.nim
- config.nims
- tests/**
push:
branches:
- master
paths:
- package_index.nim
- package_scanner.nim
- config.nims
- tests/**

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: iffy/install-nim@v5.1.1
with:
version: stable
- run: nim test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore files without extensions
*
!*/
!*.*
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,92 @@ For example:
...
```

## Sharded package metadata

This repo now supports per-package metadata files under:

```text
pkgs/<first-letter>/<package-name>/package.json
```

For example:

```text
pkgs/a/AccurateSums/package.json
pkgs/n/nimble/package.json
```

The long-term direction is for this sharded `pkgs/` layout to become the
canonical source of package metadata.

For now, this repository keeps both `packages.json` and `pkgs/` in sync-git to
support existing tooling and workflows that still update `packages.json`
directly, including current `nimble publish` behavior.

Split `packages.json` into shard files:

```sh
nim r package_index.nim split packages.json pkgs
```

Add one package from an existing metadata JSON file:

```sh
nim r package_index.nim add path/to/package.json pkgs packages.json
```

Create one package interactively:

```sh
nim r package_index.nim create pkgs packages.json
```

This prompts for the package metadata fields, writes the new package into
`pkgs/` first, and then regenerates `packages.json` from the sharded metadata.

Remove one package:

```sh
nim r package_index.nim remove PackageName pkgs packages.json
```

Build `packages.json` from those shard folders:

```sh
nim r package_index.nim
```

The combine step also validates each shard's JSON metadata shape before writing
the merged manifest.

In CI, PR validation is handled by the scanner directly from the git merge base:

```sh
nim test
```

On push, CI also keeps `packages.json` and `pkgs/` in sync-git by generating the
missing counterpart when it can determine a single authoritative side.

The current push-sync rules are:

* if only `packages.json` changed, CI regenerates `pkgs/`
* if only `pkgs/` changed, CI regenerates `packages.json`
* if both changed and already agree, CI accepts them as-is
* if the checked-out tree inherited one-sided drift from an earlier commit,
CI repairs the missing side when the changed side is a strict superset of the
unchanged side and all overlapping package metadata matches
* if both sides contain conflicting metadata, CI fails and requires a manual
fix

The test suite lives under `tests/` and can be run locally with:

```sh
nim test
```

# License

* `package_scanner.nim` - [GPLv3](LICENSE-GPLv3.txt)
* Everything else - [CC-BY-4.0](LICENSE.txt)

8 changes: 8 additions & 0 deletions config.nims
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
--define:ssl

task build, "Build package_index.nim and package_scanner.nim":
exec "nim c package_index.nim"
exec "nim c package_scanner.nim"

task test, "Run test suite":
exec "nim c -r tests/tpackage_index.nim"
exec "nim c -r tests/tpackage_scanner.nim"
27 changes: 0 additions & 27 deletions getmergebase.sh

This file was deleted.

Loading