Compare commits
3 Commits
master
..
13af3aeedf
| Author | SHA1 | Date | |
|---|---|---|---|
| 13af3aeedf | |||
| 3de605d321 | |||
| 9ca3340f10 |
@@ -31,24 +31,6 @@ repos:
|
|||||||
"-s",
|
"-s",
|
||||||
]
|
]
|
||||||
|
|
||||||
- repo: local
|
|
||||||
hooks:
|
|
||||||
- id: pytest
|
|
||||||
name: Run unit tests
|
|
||||||
entry: make test
|
|
||||||
language: system
|
|
||||||
types: [python]
|
|
||||||
pass_filenames: false
|
|
||||||
|
|
||||||
- repo: https://github.com/python-jsonschema/check-jsonschema
|
|
||||||
rev: 0.37.2
|
|
||||||
hooks:
|
|
||||||
- id: check-jsonschema
|
|
||||||
name: Validate RPM package metadata
|
|
||||||
files: ^rpms/[^/]+/metadata\.yaml$
|
|
||||||
args: [--schemafile, schema/metadata.json]
|
|
||||||
language_version: python3.11
|
|
||||||
|
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.14.7
|
rev: v0.14.7
|
||||||
hooks:
|
hooks:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ DISTRO ?= almalinux/el9
|
|||||||
PACKAGES := $(shell find $(ROOT_DIR)/rpms -mindepth 1 -maxdepth 1 -type d -exec test -f {}/metadata.yaml \; -print | xargs -n1 basename | sort)
|
PACKAGES := $(shell find $(ROOT_DIR)/rpms -mindepth 1 -maxdepth 1 -type d -exec test -f {}/metadata.yaml \; -print | xargs -n1 basename | sort)
|
||||||
|
|
||||||
# Default target to build all packages
|
# Default target to build all packages
|
||||||
.PHONY: all list build clean test
|
.PHONY: all list build clean
|
||||||
all: build-all
|
all: build-all
|
||||||
|
|
||||||
# List all available packages
|
# List all available packages
|
||||||
@@ -47,10 +47,6 @@ dry-run:
|
|||||||
@echo "Dry run - showing what would be built for distro $(DISTRO):"
|
@echo "Dry run - showing what would be built for distro $(DISTRO):"
|
||||||
$(BUILD_TOOL) build-all --distro $(DISTRO) --dry-run
|
$(BUILD_TOOL) build-all --distro $(DISTRO) --dry-run
|
||||||
|
|
||||||
# Run unit tests
|
|
||||||
test:
|
|
||||||
@uv run --group dev pytest tests/ -q; rc=$$?; [ $$rc -eq 5 ] && exit 0 || exit $$rc
|
|
||||||
|
|
||||||
# Clean target
|
# Clean target
|
||||||
clean:
|
clean:
|
||||||
@echo "Cleaning build artifacts..."
|
@echo "Cleaning build artifacts..."
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
[project]
|
|
||||||
name = "rpmbuilder"
|
|
||||||
version = "0.1.0"
|
|
||||||
requires-python = ">=3.11"
|
|
||||||
|
|
||||||
[dependency-groups]
|
|
||||||
dev = [
|
|
||||||
"pytest>=8",
|
|
||||||
"jsonschema>=4",
|
|
||||||
"pyyaml>=6",
|
|
||||||
]
|
|
||||||
@@ -11,9 +11,10 @@ builds:
|
|||||||
release: 1
|
release: 1
|
||||||
repository:
|
repository:
|
||||||
- almalinux/el8
|
- almalinux/el8
|
||||||
version: 2.1.156
|
version: 2.1.126
|
||||||
- image: git.unkin.net/unkin/almalinux9-rpmbuilder:latest
|
- image: git.unkin.net/unkin/almalinux9-rpmbuilder:latest
|
||||||
release: 1
|
release: 1
|
||||||
repository:
|
repository:
|
||||||
- almalinux/el9
|
- almalinux/el9
|
||||||
version: 2.1.156
|
version: 2.1.126
|
||||||
|
claude_ai: true
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ set -e
|
|||||||
dnf install -y unzip
|
dnf install -y unzip
|
||||||
|
|
||||||
# Download and extract vault
|
# Download and extract vault
|
||||||
curl -L -o /app/vault.zip https://artifactapi.k8s.syd1.au.unkin.net/api/v1/remote/hashicorp-releases/vault/${PACKAGE_VERSION}/vault_${PACKAGE_VERSION}_linux_amd64.zip
|
curl -L -o /app/vault.zip https://releases.hashicorp.com/vault/${PACKAGE_VERSION}/vault_${PACKAGE_VERSION}_linux_amd64.zip
|
||||||
unzip vault.zip
|
unzip vault.zip
|
||||||
|
|
||||||
# Process the nfpm.yaml template with environment variables
|
# Process the nfpm.yaml template with environment variables
|
||||||
|
|||||||
@@ -1,111 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
||||||
"additionalProperties": false,
|
|
||||||
"description": "Schema for rpms/*/metadata.yaml files",
|
|
||||||
"properties": {
|
|
||||||
"arch": {
|
|
||||||
"enum": [
|
|
||||||
"amd64",
|
|
||||||
"arm64",
|
|
||||||
"x86_64"
|
|
||||||
],
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"builds": {
|
|
||||||
"items": {
|
|
||||||
"additionalProperties": false,
|
|
||||||
"properties": {
|
|
||||||
"image": {
|
|
||||||
"minLength": 1,
|
|
||||||
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9\\-_.:/@]+$",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"release": {
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"minLength": 1,
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "number"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"items": {
|
|
||||||
"enum": [
|
|
||||||
"almalinux/el8",
|
|
||||||
"almalinux/el9",
|
|
||||||
"fedora/42",
|
|
||||||
"fedora/43",
|
|
||||||
"fedora/44"
|
|
||||||
],
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"minItems": 1,
|
|
||||||
"type": "array"
|
|
||||||
},
|
|
||||||
"version": {
|
|
||||||
"minLength": 1,
|
|
||||||
"pattern": "^[0-9]+(\\.[0-9]+)*(-[a-zA-Z0-9]+)*$",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"repository",
|
|
||||||
"image",
|
|
||||||
"release",
|
|
||||||
"version"
|
|
||||||
],
|
|
||||||
"type": "object"
|
|
||||||
},
|
|
||||||
"minItems": 1,
|
|
||||||
"type": "array"
|
|
||||||
},
|
|
||||||
"description": {
|
|
||||||
"minLength": 1,
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"dist_tag": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"github": {
|
|
||||||
"minLength": 1,
|
|
||||||
"pattern": "^[a-zA-Z0-9\\-_]+/[a-zA-Z0-9\\-_.]+$",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"github_release_pattern": {
|
|
||||||
"minLength": 1,
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"homepage": {
|
|
||||||
"minLength": 1,
|
|
||||||
"pattern": "^https?://.+",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"license": {
|
|
||||||
"minLength": 1,
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"maintainer": {
|
|
||||||
"minLength": 1,
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"minLength": 1,
|
|
||||||
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9\\-_.]*$",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"platform": {
|
|
||||||
"minLength": 1,
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"name",
|
|
||||||
"description",
|
|
||||||
"builds"
|
|
||||||
],
|
|
||||||
"title": "RPM Package Metadata",
|
|
||||||
"type": "object"
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# Tests for tools/build and tools/update-gh.
|
|
||||||
# See https://git.unkin.net/unkin/rpmbuilder/issues/162
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
"""Validate every rpms/*/metadata.yaml against schema/metadata.json."""
|
|
||||||
|
|
||||||
import json
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import jsonschema
|
|
||||||
import pytest
|
|
||||||
import yaml
|
|
||||||
|
|
||||||
REPO_ROOT = Path(__file__).parent.parent
|
|
||||||
SCHEMA_FILE = REPO_ROOT / "schema" / "metadata.json"
|
|
||||||
RPMS_DIR = REPO_ROOT / "rpms"
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
|
||||||
def schema():
|
|
||||||
with open(SCHEMA_FILE) as f:
|
|
||||||
return json.load(f)
|
|
||||||
|
|
||||||
|
|
||||||
def metadata_files():
|
|
||||||
return sorted(RPMS_DIR.glob("*/metadata.yaml"))
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("metadata_file", metadata_files(), ids=lambda p: p.parent.name)
|
|
||||||
def test_metadata_valid(metadata_file, schema):
|
|
||||||
with open(metadata_file) as f:
|
|
||||||
data = yaml.safe_load(f)
|
|
||||||
|
|
||||||
validator = jsonschema.Draft7Validator(schema)
|
|
||||||
errors = sorted(validator.iter_errors(data), key=str)
|
|
||||||
|
|
||||||
assert not errors, "\n".join(
|
|
||||||
f" {'.'.join(str(p) for p in e.absolute_path) or '(root)'}: {e.message}"
|
|
||||||
for e in errors
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user