-
Notifications
You must be signed in to change notification settings - Fork 0
Initial working version #5
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
wlix13
wants to merge
9
commits into
main
Choose a base branch
from
feature/initial-version
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.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3adaafa
ci(code-quality): add workflow for code quality checks
wlix13 737a34c
ci(release): add workflow for tagged releases
wlix13 14028ce
feat(infra): add deployment scripts and configurations for various seβ¦
wlix13 ff4af3c
feat(runes): add NTP synchronization configuration
wlix13 314fe48
fixup! feat(infra): add deployment scripts and configurations for varβ¦
wlix13 0dfef69
refactor: replace MTG with MTProto in deployment scripts and models, β¦
wlix13 0a30ecc
fix(netsec): ensure UFW status command does not fail by adding '|| true'
wlix13 477725b
fix(runes): prevent failure of getfacl command by appending '|| true'
wlix13 f045de0
fix(runes): add retry logic for NTP synchronization configuration
wlix13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: π Check code quality | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| quality: | ||
| name: π Code Quality | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| enable-cache: true | ||
| cache-dependency-glob: uv.lock | ||
|
|
||
| - run: uv sync --group dev | ||
|
|
||
| - name: Check formatting | ||
| run: uv run ruff format --check . | ||
|
|
||
| - name: Lint code | ||
| run: uv run ruff check . | ||
|
|
||
| - name: Type check | ||
| run: uv run ty check |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| name: π Tagged Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v*.*.*" # Semantic version tags: v1.2.3 | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| attestations: write | ||
|
|
||
| jobs: | ||
| build: | ||
| name: π¦ Build distribution | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: astral-sh/setup-uv@v7 | ||
|
|
||
| - run: uv build | ||
|
|
||
| - name: Upload distribution artifacts | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: python-package-distributions | ||
| path: dist/ | ||
|
|
||
| attest-artifacts: | ||
| name: π Generate artifact attestations | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Download distribution artifacts | ||
| uses: actions/download-artifact@v8 | ||
| with: | ||
| name: python-package-distributions | ||
| path: dist/ | ||
|
|
||
| - name: Generate artifact attestations | ||
| uses: actions/attest-build-provenance@v4 | ||
| with: | ||
| subject-path: dist/* | ||
|
|
||
| publish-pypi: | ||
| name: π€ Publish to PyPI | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| environment: | ||
| name: pypi | ||
| url: https://pypi.org/project/netloom/ | ||
| permissions: | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - uses: astral-sh/setup-uv@v7 | ||
|
|
||
| - name: Download distribution artifacts | ||
| uses: actions/download-artifact@v8 | ||
| with: | ||
| name: python-package-distributions | ||
| path: dist/ | ||
|
|
||
| - name: Publish to PyPI | ||
| run: uv publish --trusted-publishing always | ||
|
|
||
| create-release: | ||
| name: π Create GitHub Release | ||
| needs: [publish-pypi, attest-artifacts] | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Download distribution artifacts | ||
| uses: actions/download-artifact@v8 | ||
| with: | ||
| name: python-package-distributions | ||
| path: dist/ | ||
|
|
||
| - name: Create GitHub Release | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| TAG_NAME: ${{ github.ref_name }} | ||
| run: | | ||
| gh release create $TAG_NAME \ | ||
| --title "π Release $TAG_NAME" \ | ||
| --verify-tag \ | ||
| --generate-notes \ | ||
| dist/* | ||
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
Empty file.
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
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||||||
| from pyinfra import local | ||||||||
| from pyinfra.context import host | ||||||||
|
|
||||||||
| from nullforge.models.dns import DnsMode | ||||||||
| from nullforge.molds.utils import ensure_features, ensure_system | ||||||||
|
|
||||||||
|
|
||||||||
| def cast_full() -> None: | ||||||||
| """Cast the full NullForge's deployment blueprint.""" | ||||||||
|
|
||||||||
| host.data.features = ensure_features(getattr(host.data, "features", None)) | ||||||||
| host.data.system = ensure_system(getattr(host.data, "system", None)) | ||||||||
|
|
||||||||
| local.include("nullforge/runes/prepare.py") | ||||||||
|
|
||||||||
| local.include("nullforge/runes/base.py") | ||||||||
|
|
||||||||
| if host.data.features.users.manage: | ||||||||
| local.include("nullforge/runes/users.py") | ||||||||
|
|
||||||||
| local.include("nullforge/runes/netsec.py") | ||||||||
|
|
||||||||
| if host.data.features.profiles.for_root or host.data.features.profiles.for_user: | ||||||||
| local.include("nullforge/runes/profiles.py") | ||||||||
|
|
||||||||
| if host.data.features.dns.mode != DnsMode.NONE: | ||||||||
| local.include("nullforge/runes/dns.py") | ||||||||
|
|
||||||||
| if host.data.features.warp.install: | ||||||||
| local.include("nullforge/runes/warp.py") | ||||||||
|
|
||||||||
| if host.data.features.zerotrust.install: | ||||||||
| local.include("nullforge/runes/zerotrust.py") | ||||||||
|
|
||||||||
| if host.data.features.haproxy.install: | ||||||||
| local.include("nullforge/runes/haproxy.py") | ||||||||
|
|
||||||||
| if host.data.features.containers.install: | ||||||||
| local.include("nullforge/runes/containers.py") | ||||||||
|
|
||||||||
| if host.data.features.tor.install: | ||||||||
| local.include("nullforge/runes/tor.py") | ||||||||
|
|
||||||||
| if host.data.features.xray.install: | ||||||||
| local.include("nullforge/runes/xray.py") | ||||||||
|
|
||||||||
| if host.data.features.mtproto.install: | ||||||||
| local.include("nullforge/runes/mtproto.py") | ||||||||
|
|
||||||||
|
|
||||||||
| cast_full() | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calling
Suggested change
|
||||||||
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| from nullforge.models.dns import DnsMode | ||
| from nullforge.models.users import Shell | ||
| from nullforge.molds import DnsMold, UserMold, WarpMold | ||
| from nullforge.molds.base import BASE_FEATURES, BASE_SYSTEM | ||
| from nullforge.molds.utils import merge_features, merge_system | ||
|
|
||
|
|
||
| users = UserMold( | ||
| manage=True, | ||
| name="example", | ||
| shell=Shell.ZSH, | ||
| ) | ||
| """User configuration preset | ||
| with user management enabled and the user "example". | ||
| with shell set to ZSH (default behavior). | ||
| """ | ||
|
|
||
| warp = WarpMold( | ||
| install=True, | ||
| iface="warp-example", | ||
| ) | ||
| """WARP configuration preset | ||
| setup Cloudflare WARP | ||
| with default MASQUE engine and interface "warp-example". | ||
| """ | ||
|
|
||
| dns = DnsMold( | ||
| mode=DnsMode.DOH_RAW, | ||
| ) | ||
| """DNS configuration preset | ||
| with DNS over HTTPS raw mode. | ||
| """ | ||
|
|
||
| overrides = ( | ||
| users, | ||
| warp, | ||
| dns, | ||
| ) | ||
| """Wrappers for the features to be merged with the base features.""" | ||
|
|
||
| hosts = [ | ||
| ( | ||
| "203.0.113.10", | ||
| { | ||
| "system": merge_system(BASE_SYSTEM, {"hostname": "example-node1.local"}), | ||
| "features": merge_features(BASE_FEATURES, *overrides), | ||
| }, | ||
| ), | ||
| ( | ||
| "203.0.113.20", | ||
| { | ||
| "system": merge_system(BASE_SYSTEM, {"hostname": "example-node2.local"}), | ||
| "features": merge_features(BASE_FEATURES, *overrides), | ||
| }, | ||
| ), | ||
| ] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Internal models for NullForge.""" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| """Containers configuration models.""" | ||
|
|
||
| from enum import StrEnum | ||
| from typing import Annotated, Literal | ||
|
|
||
| from pydantic import BaseModel, Field | ||
|
|
||
|
|
||
| class ContainersBackendType(StrEnum): | ||
| DOCKER = "docker" | ||
| PODMAN = "podman" | ||
| CRIO = "crio" | ||
|
|
||
|
|
||
| class ContainersRuntimeType(StrEnum): | ||
| DEFAULT = "default" | ||
| CRUN = "crun" | ||
| GVISOR = "gvisor" | ||
|
|
||
|
|
||
| class _ContainersBackendBase(BaseModel): | ||
| """Base for a containers backend.""" | ||
|
|
||
| type: ContainersBackendType = Field(description="The type of containers backend") | ||
| runtime: ContainersRuntimeType = Field(description="The type of containers runtime") | ||
|
|
||
|
|
||
| class DockerContainersBackend(_ContainersBackendBase): | ||
| type: Literal[ContainersBackendType.DOCKER] = ContainersBackendType.DOCKER | ||
| runtime: Literal[ContainersRuntimeType.GVISOR] = ContainersRuntimeType.GVISOR | ||
|
|
||
|
|
||
| class PodmanContainersBackend(_ContainersBackendBase): | ||
| type: Literal[ContainersBackendType.PODMAN] = ContainersBackendType.PODMAN | ||
| runtime: Literal[ContainersRuntimeType.CRUN] = ContainersRuntimeType.CRUN | ||
|
|
||
|
|
||
| class CrioContainersBackend(_ContainersBackendBase): | ||
| type: Literal[ContainersBackendType.CRIO] = ContainersBackendType.CRIO | ||
| runtime: Literal[ContainersRuntimeType.DEFAULT] = ContainersRuntimeType.DEFAULT | ||
|
|
||
|
|
||
| ContainersBackend = Annotated[ | ||
| DockerContainersBackend | PodmanContainersBackend | CrioContainersBackend, | ||
| Field(discriminator="type"), | ||
| ] | ||
|
|
||
|
|
||
| def containers_backend_factory(type: ContainersBackendType) -> ContainersBackend: | ||
| """Factory function for containers backends.""" | ||
|
|
||
| match type: | ||
| case ContainersBackendType.DOCKER: | ||
| return DockerContainersBackend() | ||
| case ContainersBackendType.PODMAN: | ||
| return PodmanContainersBackend() | ||
| case ContainersBackendType.CRIO: | ||
| return CrioContainersBackend() |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π§© Analysis chain
π Script executed:
Repository: wlix13/NullForge
Length of output: 102
π Script executed:
head -100 .github/workflows/create-tag.yaml | tail -20Repository: wlix13/NullForge
Length of output: 594
π Script executed:
Repository: wlix13/NullForge
Length of output: 196
Quote
TAG_NAMEin the release command for consistency and defensive coding.Line 91 should quote the variable to avoid word-splitting edge cases. Note that line 92 already quotes
TAG_NAMEin the title, making the unquoted usage on line 91 inconsistent.Suggested patch
π§° Tools
πͺ actionlint (1.7.12)
[error] 90-90: shellcheck reported issue in this script: SC2086:info:1:19: Double quote to prevent globbing and word splitting
(shellcheck)
π€ Prompt for AI Agents