diff --git a/.copier-answers.yml b/.copier-answers.yml new file mode 100644 index 0000000..bcbd320 --- /dev/null +++ b/.copier-answers.yml @@ -0,0 +1,6 @@ +# Changes here will be overwritten by Copier +_commit: v1.7.2 +_src_path: https://github.com/DeveloperC286/template +project_name: monkey_interpreter +project_type: rust +uses_git: false diff --git a/.github/renovate.json5 b/.github/renovate.json5 index d79fc9d..945c8ab 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -4,6 +4,9 @@ "config:best-practices" ], "automerge": true, + "github-actions": { + "enabled": false + }, "nix": { "enabled": true, "lockFileMaintenance": { diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 560b6d0..ec3687c 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -6,6 +6,19 @@ permissions: contents: read jobs: + permissions: + name: Permissions + runs-on: ${{ matrix.architecture }} + strategy: + matrix: + architecture: [ubuntu-24.04, ubuntu-24.04-arm] + language: [shell] + steps: + - name: Checkout code. + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + - name: Check permissions. + run: make check-${{ matrix.language }}-permissions + formatting: name: Formatting runs-on: ${{ matrix.architecture }} @@ -36,17 +49,20 @@ jobs: - name: Check linting. run: nix develop -c make check-${{ matrix.language }}-linting - scripts-permissions: - name: Scripts Permissions + dependencies: + name: Dependencies runs-on: ${{ matrix.architecture }} strategy: matrix: architecture: [ubuntu-24.04, ubuntu-24.04-arm] + language: [rust] steps: - name: Checkout code. uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - - name: Check scripts permissions. - run: make check-scripts-permissions + - name: Setup Nix. + uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0 + - name: Check dependencies. + run: nix develop -c make check-${{ matrix.language }}-dependencies compile: name: Compile diff --git a/.github/workflows/conventional-commits.yml b/.github/workflows/conventional-commits.yml index 56eb9a6..358f390 100644 --- a/.github/workflows/conventional-commits.yml +++ b/.github/workflows/conventional-commits.yml @@ -1,6 +1,8 @@ name: Conventional Commits -on: pull_request +on: + pull_request: + types: [opened, edited, synchronize, reopened] permissions: contents: read @@ -10,7 +12,7 @@ jobs: name: Linting runs-on: ubuntu-24.04 container: - image: ghcr.io/developerc286/conventional_commits_linter:0.17.0@sha256:d6fb0dfd79c2e06897692bc3f0dc62bcb7ce90a92030c81a3137935516d525d7 + image: ghcr.io/developerc286/conventional_commits_linter:0.17.1@sha256:f1b947937ee884ba7f886d04939cd4858f9aeafb50dcf94925a516c50e43021b steps: - name: Checkout code. uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 @@ -18,4 +20,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 - name: Check Conventional Commits linting. - run: conventional_commits_linter --type angular "origin/${{ github.base_ref }}" + env: + PR_TITLE: ${{ github.event.pull_request.title }} + PR_BODY: ${{ github.event.pull_request.body }} + run: printf '%s\n\n%s' "$PR_TITLE" "$PR_BODY" | conventional_commits_linter - diff --git a/.github/workflows/git-history.yml b/.github/workflows/git-history.yml index 476fc11..1b18abe 100644 --- a/.github/workflows/git-history.yml +++ b/.github/workflows/git-history.yml @@ -10,7 +10,7 @@ jobs: name: Clean runs-on: ubuntu-24.04 container: - image: ghcr.io/developerc286/clean_git_history:1.1.5@sha256:b1374591d48393f6b5fcc888f6bc7da05f7d218961f7850112130b1cad78186a + image: ghcr.io/developerc286/clean_git_history:1.1.6@sha256:93fd9c692f6e629956921b8d068ccad33760882b6e0c6d4d32cd963380aec25f steps: - name: Checkout code. uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 diff --git a/.gitignore b/.gitignore index 97a06e3..2b4217c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,13 @@ # Rust .gitignore # Generated by Cargo -debug/ -target/ +debug +target # Generated by rustfmt **/*.rs.bk # Generated by proptest -proptest-regressions/ - -# Generated by IntelliJ IDEA -.idea/ +proptest-regressions # Generated by direnv & Nix. -.direnv/ +.direnv diff --git a/Makefile b/Makefile index 25691b9..4b28345 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,10 @@ # Auto-detect musl target for static binaries (Linux only) +# Only set MUSL_TARGET on supported architectures; targets that need it will check MUSL_TARGET := $(shell uname -m | sed 's/^x86_64$$/x86_64-unknown-linux-musl/;s/^aarch64$$/aarch64-unknown-linux-musl/') -ifeq ($(filter %unknown-linux-musl,$(MUSL_TARGET)),) - $(error Unsupported architecture: $(shell uname -m). Static musl builds only supported on Linux x86_64 and aarch64) -endif + +define check-musl-target +$(if $(filter %unknown-linux-musl,$(MUSL_TARGET)),,$(error Unsupported architecture: $(shell uname -m). Static musl builds only supported on Linux x86_64 and aarch64)) +endef # Use --locked in CI to ensure reproducible builds CARGO_LOCKED := $(if $(CI),--locked,) @@ -10,26 +12,30 @@ CARGO_LOCKED := $(if $(CI),--locked,) .PHONY: default default: compile +.PHONY: check-shell-permissions +check-shell-permissions: + ./ci/check-scripts-permissions.sh + .PHONY: check-rust-formatting check-rust-formatting: cargo fmt --all -- --check --config=group_imports=StdExternalCrate -.PHONY: check-shell-formatting -check-shell-formatting: - shfmt --simplify --diff ci/* - -.PHONY: check-yaml-formatting -check-yaml-formatting: - yamlfmt -verbose -lint -dstar .github/workflows/* - .PHONY: fix-rust-formatting fix-rust-formatting: cargo fmt --all -- --config=group_imports=StdExternalCrate +.PHONY: check-shell-formatting +check-shell-formatting: + shfmt --simplify --diff ci/* + .PHONY: fix-shell-formatting fix-shell-formatting: shfmt --simplify --write ci/* +.PHONY: check-yaml-formatting +check-yaml-formatting: + yamlfmt -verbose -lint -dstar .github/workflows/* + .PHONY: fix-yaml-formatting fix-yaml-formatting: yamlfmt -verbose -dstar .github/workflows/* @@ -46,9 +52,9 @@ check-shell-linting: check-github-actions-workflows-linting: actionlint -verbose -color -.PHONY: check-scripts-permissions -check-scripts-permissions: - ./ci/check-scripts-permissions.sh +.PHONY: check-rust-dependencies +check-rust-dependencies: + cargo machete .PHONY: compile compile: @@ -60,6 +66,7 @@ unit-test: .PHONY: release release: + $(call check-musl-target) cargo build --release --target=$(MUSL_TARGET) --locked --verbose .PHONY: publish-binary diff --git a/flake.nix b/flake.nix index 512784b..6868128 100644 --- a/flake.nix +++ b/flake.nix @@ -48,6 +48,8 @@ pkgs.shellcheck # GitHub Actions workflows linting. pkgs.actionlint + # Rust dependencies check. + pkgs.cargo-machete # Deploying. pkgs.gh ];