diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..31b4342 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,20 @@ +# From https://github.com/BurntSushi/ripgrep/blob/master/.cargo/config.toml + +# Do the same for MUSL targets. At the time of writing (2023-10-23), this is +# the default. But the plan is for the default to change to dynamic linking. +# The whole point of MUSL with respect to ripgrep is to create a fully +# statically linked executable. +# +# See: https://github.com/rust-lang/compiler-team/issues/422 +# See: https://github.com/rust-lang/compiler-team/issues/422#issuecomment-812135847 +[target.x86_64-unknown-linux-musl] +rustflags = [ + "-C", "target-feature=+crt-static", + "-C", "link-self-contained=yes", +] + +[target.aarch64-unknown-linux-musl] +rustflags = [ + "-C", "target-feature=+crt-static", + "-C", "link-self-contained=yes", +] diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 351cef7..945c8ab 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -4,23 +4,18 @@ "config:best-practices" ], "automerge": true, - "dockerfile": { - "managerFilePatterns": [ - "/(^|/|\\.)Dockerfile$/", - "/(^|/)Dockerfile[^/]*$/" - ] + "github-actions": { + "enabled": false + }, + "nix": { + "enabled": true, + "lockFileMaintenance": { + "enabled": true, + "commitMessageAction": "update", + "commitMessageTopic": "Nix flake lock" + } }, "customManagers": [ - { - "customType": "regex", - "managerFilePatterns": [ - "/(^|/|\\.)Dockerfile$/", - "/(^|/)Dockerfile[^/]*$/" - ], - "matchStrings": [ - "# renovate: datasource=(?.*?) depName=(?.*?)( versioning=(?.*?))?\\s.+_VERSION=\"(?.*?)\"\\s" - ] - }, { "customType": "regex", "managerFilePatterns": [ @@ -36,18 +31,6 @@ "datasourceTemplate": "repology", "depNameTemplate": "alpine_{{alpineMajor}}_{{alpineMinor}}/{{name}}", "versioningTemplate": "loose" - }, - { - "customType": "regex", - "managerFilePatterns": [ - "/(^|/|\\.)Makefile$/", - "/(^|/)Makefile[^/]*$/" - ], - "matchStrings": [ - "# renovate: depName=(?.*?)\\s.+_VERSION=(?[a-z0-9.-]+)(?:@(?sha256:[a-f0-9]+))?" - ], - "datasourceTemplate": "docker", - "versioningTemplate": "docker" } ] } diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml new file mode 100644 index 0000000..0a8bdbc --- /dev/null +++ b/.github/workflows/continuous-delivery.yml @@ -0,0 +1,76 @@ +name: Continuous Delivery (CD) + +on: + release: + types: [published] + +# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs +permissions: + contents: write + packages: write + +jobs: + publish-binary: + name: Publish Binary + runs-on: ${{ matrix.architecture }} + strategy: + matrix: + architecture: [ubuntu-24.04, ubuntu-24.04-arm] + steps: + - name: Checkout code. + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + - name: Setup Nix. + uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0 + - name: Publish binary. + run: nix develop -c make publish-binary RELEASE="${GITHUB_REF_NAME}" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by GitHub Actions. + + publish-docker-image: + name: Publish Docker Image (${{ matrix.platform }}) + runs-on: ${{ matrix.runner }} + needs: [publish-binary] + strategy: + matrix: + include: + - platform: linux/amd64 + runner: ubuntu-24.04 + target: x86_64-unknown-linux-musl + suffix: amd64 + - platform: linux/arm64 + runner: ubuntu-24.04-arm + target: aarch64-unknown-linux-musl + suffix: arm64 + steps: + - name: Checkout code. + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0 + - name: Login to GitHub Container Registry + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Publish Docker Image + run: make publish-docker-image RELEASE="${GITHUB_REF_NAME}" PLATFORM="${{ matrix.platform }}" TARGET="${{ matrix.target }}" SUFFIX="${{ matrix.suffix }}" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-docker-manifest: + name: Publish Docker Manifest + runs-on: ubuntu-24.04 + needs: [publish-docker-image] + steps: + - name: Checkout code. + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0 + - name: Login to GitHub Container Registry + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Publish Docker Manifest + run: make publish-docker-manifest RELEASE="${GITHUB_REF_NAME}" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ffaee8f..560b6d0 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -8,39 +8,70 @@ permissions: jobs: formatting: name: Formatting - runs-on: ubuntu-latest + runs-on: ${{ matrix.architecture }} strategy: matrix: + architecture: [ubuntu-24.04, ubuntu-24.04-arm] language: [rust, shell] steps: - name: Checkout code. uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + - name: Setup Nix. + uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0 - name: Check formatting. - run: make check-${{ matrix.language }}-formatting + run: nix develop -c make check-${{ matrix.language }}-formatting + linting: name: Linting - runs-on: ubuntu-latest + runs-on: ${{ matrix.architecture }} strategy: matrix: - language: [rust] + architecture: [ubuntu-24.04, ubuntu-24.04-arm] + language: [rust, shell] steps: - name: Checkout code. uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + - name: Setup Nix. + uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0 - name: Check linting. - run: make check-${{ matrix.language }}-linting + run: nix develop -c make check-${{ matrix.language }}-linting + + scripts-permissions: + name: Scripts Permissions + runs-on: ${{ matrix.architecture }} + strategy: + matrix: + architecture: [ubuntu-24.04, ubuntu-24.04-arm] + steps: + - name: Checkout code. + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + - name: Check scripts permissions. + run: make check-scripts-permissions + compile: name: Compile - runs-on: ubuntu-latest + runs-on: ${{ matrix.architecture }} + strategy: + matrix: + architecture: [ubuntu-24.04, ubuntu-24.04-arm] steps: - name: Checkout code. uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + - name: Setup Nix. + uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0 - name: Compile. - run: make compile + run: nix develop -c make compile + unit-test: name: Unit Test - runs-on: ubuntu-latest + runs-on: ${{ matrix.architecture }} + strategy: + matrix: + architecture: [ubuntu-24.04, ubuntu-24.04-arm] steps: - name: Checkout code. uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + - name: Setup Nix. + uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0 - name: Unit test. - run: make unit-test + run: nix develop -c make unit-test diff --git a/.github/workflows/conventional-commits.yml b/.github/workflows/conventional-commits.yml index 158f6f7..56eb9a6 100644 --- a/.github/workflows/conventional-commits.yml +++ b/.github/workflows/conventional-commits.yml @@ -8,7 +8,9 @@ permissions: jobs: linting: name: Linting - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + container: + image: ghcr.io/developerc286/conventional_commits_linter:0.17.0@sha256:d6fb0dfd79c2e06897692bc3f0dc62bcb7ce90a92030c81a3137935516d525d7 steps: - name: Checkout code. uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 @@ -16,4 +18,4 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 - name: Check Conventional Commits linting. - run: make check-conventional-commits-linting FROM="origin/${{ github.base_ref }}" + run: conventional_commits_linter --type angular "origin/${{ github.base_ref }}" diff --git a/.github/workflows/git-history.yml b/.github/workflows/git-history.yml index 2745514..476fc11 100644 --- a/.github/workflows/git-history.yml +++ b/.github/workflows/git-history.yml @@ -8,7 +8,9 @@ permissions: jobs: clean: name: Clean - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + container: + image: ghcr.io/developerc286/clean_git_history:1.1.5@sha256:b1374591d48393f6b5fcc888f6bc7da05f7d218961f7850112130b1cad78186a steps: - name: Checkout code. uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 @@ -16,4 +18,4 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 - name: Check clean Git history. - run: make check-clean-git-history FROM="origin/${{ github.base_ref }}" + run: clean_git_history "origin/${{ github.base_ref }}" diff --git a/.github/workflows/github-actions-workflows.yml b/.github/workflows/github-actions-workflows.yml index 8553364..31d7778 100644 --- a/.github/workflows/github-actions-workflows.yml +++ b/.github/workflows/github-actions-workflows.yml @@ -6,19 +6,30 @@ permissions: contents: read jobs: - linting: - name: Linting - runs-on: ubuntu-latest - steps: - - name: Checkout code. - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - - name: Check GitHub Actions workflows linting. - run: make check-github-actions-workflows-linting formatting: name: Formatting - runs-on: ubuntu-latest + runs-on: ${{ matrix.architecture }} + strategy: + matrix: + architecture: [ubuntu-24.04, ubuntu-24.04-arm] steps: - name: Checkout code. uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + - name: Setup Nix. + uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0 - name: Check formatting. - run: make check-yaml-formatting + run: nix develop -c make check-yaml-formatting + + linting: + name: Linting + runs-on: ${{ matrix.architecture }} + strategy: + matrix: + architecture: [ubuntu-24.04, ubuntu-24.04-arm] + steps: + - name: Checkout code. + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + - name: Setup Nix. + uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0 + - name: Check GitHub Actions workflows linting. + run: nix develop -c make check-github-actions-workflows-linting diff --git a/.github/workflows/mirroring.yml b/.github/workflows/mirroring.yml index 8654b8f..b816fa2 100644 --- a/.github/workflows/mirroring.yml +++ b/.github/workflows/mirroring.yml @@ -9,8 +9,9 @@ concurrency: group: ${{ github.workflow }} jobs: - GitLab: - runs-on: ubuntu-latest + gitlab: + name: GitLab + runs-on: ubuntu-24.04 steps: - name: Checkout code. run: git clone --mirror "https://github.com/${GITHUB_REPOSITORY}.git" "${GITHUB_WORKSPACE}" diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index b183a88..29397dd 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -12,7 +12,7 @@ permissions: jobs: release-please: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0 with: diff --git a/.gitignore b/.gitignore index 093d8bd..97a06e3 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ proptest-regressions/ # Generated by IntelliJ IDEA .idea/ + +# Generated by direnv & Nix. +.direnv/ diff --git a/Cargo.lock b/Cargo.lock index 3ab6fa3..7165569 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,18 @@ version = 4 [[package]] name = "aho-corasick" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" dependencies = [ "anstyle", "anstyle-parse", @@ -28,9 +28,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" [[package]] name = "anstyle-parse" @@ -43,21 +43,22 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys", + "windows-sys 0.61.2", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", - "windows-sys", + "once_cell_polyfill", + "windows-sys 0.61.2", ] [[package]] @@ -66,12 +67,6 @@ version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - [[package]] name = "bitflags" version = "2.10.0" @@ -80,9 +75,9 @@ checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "clap" @@ -120,9 +115,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" +checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "colorchoice" @@ -132,21 +127,21 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" [[package]] name = "console" -version = "0.15.8" +version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" dependencies = [ "encode_unicode", - "lazy_static", "libc", - "windows-sys", + "once_cell", + "windows-sys 0.59.0", ] [[package]] name = "encode_unicode" -version = "0.3.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" [[package]] name = "env_logger" @@ -163,9 +158,9 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" @@ -174,7 +169,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.61.2", ] [[package]] @@ -185,15 +180,15 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", @@ -202,9 +197,9 @@ dependencies = [ [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-timer" @@ -214,9 +209,9 @@ checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", "futures-macro", @@ -228,26 +223,38 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", "libc", "wasi", ] +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + [[package]] name = "glob" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" [[package]] name = "heck" @@ -257,21 +264,21 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.3.9" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "humantime" -version = "2.1.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424" [[package]] name = "indexmap" -version = "2.6.0" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" dependencies = [ "equivalent", "hashbrown", @@ -291,38 +298,32 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.12" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" dependencies = [ "hermit-abi", "libc", - "windows-sys", + "windows-sys 0.61.2", ] [[package]] name = "is_terminal_polyfill" -version = "1.70.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" - -[[package]] -name = "lazy_static" -version = "1.4.0" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.179" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "c5a2d376baa530d1238d133232d15e239abad80d05838b4b59354e5268af431f" [[package]] name = "linux-raw-sys" -version = "0.4.15" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" [[package]] name = "log" @@ -332,9 +333,9 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "monkey_interpreter" @@ -352,15 +353,21 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.3" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -370,9 +377,12 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] [[package]] name = "pretty_env_logger" @@ -386,31 +396,37 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.2.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" dependencies = [ "toml_edit", ] [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "9695f8df41bb4f3d222c95a67532365f569318332d03d5f3f67f37b20e6ebdf0" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.37" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + [[package]] name = "rand" version = "0.8.5" @@ -438,14 +454,14 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.16", ] [[package]] name = "regex" -version = "1.11.0" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" dependencies = [ "aho-corasick", "memchr", @@ -455,9 +471,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" dependencies = [ "aho-corasick", "memchr", @@ -466,9 +482,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.5" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" [[package]] name = "relative-path" @@ -527,38 +543,55 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.34" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.61.2", ] [[package]] name = "semver" -version = "1.0.23" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" [[package]] -name = "similar" -version = "2.5.0" +name = "serde_core" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] [[package]] -name = "slab" -version = "0.4.9" +name = "serde_derive" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ - "autocfg", + "proc-macro2", + "quote", + "syn", ] +[[package]] +name = "similar" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" + +[[package]] +name = "slab" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" + [[package]] name = "strsim" version = "0.11.1" @@ -567,9 +600,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.87" +version = "2.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "678faa00651c9eb72dd2020cbdf275d92eccb2400d568e419efdd64838145cb4" dependencies = [ "proc-macro2", "quote", @@ -578,15 +611,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.11.0" +version = "3.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" +checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" dependencies = [ - "cfg-if", "fastrand", + "getrandom 0.3.4", "once_cell", "rustix", - "windows-sys", + "windows-sys 0.61.2", ] [[package]] @@ -620,26 +653,39 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.7.5+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" +dependencies = [ + "serde_core", +] [[package]] name = "toml_edit" -version = "0.22.22" +version = "0.23.10+spec-1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +checksum = "84c8b9f757e028cee9fa244aea147aab2a9ec09d5325a9b01e0a49730c2b5269" dependencies = [ "indexmap", "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.0.6+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44" +dependencies = [ "winnow", ] [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "utf8parse" @@ -649,33 +695,57 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.1+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +dependencies = [ + "wit-bindgen", +] [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys", + "windows-sys 0.61.2", ] +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -689,57 +759,83 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.20" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" dependencies = [ "memchr", ] + +[[package]] +name = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" + +[[package]] +name = "zerocopy" +version = "0.8.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e4772e1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM alpine:3.23.2@sha256:865b95f46d98cf867a156fe4a135ad3fe50d2056aa3f25ed31662dff6da4eb62 + +ARG TARGET +COPY ./target/${TARGET}/release/monkey_interpreter /usr/local/bin/ + +WORKDIR /workspace + +ENTRYPOINT ["monkey_interpreter"] diff --git a/Makefile b/Makefile index 7b7d8d4..25691b9 100644 --- a/Makefile +++ b/Makefile @@ -1,76 +1,75 @@ -DOCKER_RUN_OPTS := --rm -v $(PWD):/workspace -w /workspace +# Auto-detect musl target for static binaries (Linux only) +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 -UID := $(shell id -u) -GID := $(shell id -g) -DOCKER_RUN_WRITE_OPTS := $(DOCKER_RUN_OPTS) -u $(UID):$(GID) +# Use --locked in CI to ensure reproducible builds +CARGO_LOCKED := $(if $(CI),--locked,) .PHONY: default default: compile -# renovate: depName=ghcr.io/developerc286/clean_git_history -CLEAN_GIT_HISTORY_VERSION=1.1.6@sha256:93fd9c692f6e629956921b8d068ccad33760882b6e0c6d4d32cd963380aec25f - -.PHONY: check-clean-git-history -check-clean-git-history: - docker run $(DOCKER_RUN_WRITE_OPTS) ghcr.io/developerc286/clean_git_history:$(CLEAN_GIT_HISTORY_VERSION) $(FROM) - -# renovate: depName=ghcr.io/developerc286/conventional_commits_linter -CONVENTIONAL_COMMITS_LINTER_VERSION=0.17.1@sha256:f1b947937ee884ba7f886d04939cd4858f9aeafb50dcf94925a516c50e43021b - -.PHONY: check-conventional-commits-linting -check-conventional-commits-linting: - docker run $(DOCKER_RUN_WRITE_OPTS) ghcr.io/developerc286/conventional_commits_linter:$(CONVENTIONAL_COMMITS_LINTER_VERSION) --type angular $(FROM) - .PHONY: check-rust-formatting check-rust-formatting: - docker build -t check-rust-formatting -f ci/check-rust-formatting.Dockerfile . - docker run $(DOCKER_RUN_OPTS) check-rust-formatting - -# renovate: depName=mvdan/shfmt -SHFMT_VERSION=v3.12.0-alpine@sha256:204a4d2d876123342ad394bd9a28fb91e165abc03868790d4b39cfa73233f150 + cargo fmt --all -- --check --config=group_imports=StdExternalCrate .PHONY: check-shell-formatting check-shell-formatting: - docker run $(DOCKER_RUN_OPTS) mvdan/shfmt:$(SHFMT_VERSION) --simplify --diff ci/* - -# renovate: depName=ghcr.io/google/yamlfmt -YAMLFMT_VERSION=0.20.0@sha256:cd11483ba1119371593a7d55386d082da518e27dd932ee00db32e5fb6f3a58c0 + shfmt --simplify --diff ci/* .PHONY: check-yaml-formatting check-yaml-formatting: - docker run $(DOCKER_RUN_OPTS) ghcr.io/google/yamlfmt:$(YAMLFMT_VERSION) -verbose -lint -dstar .github/workflows/* + yamlfmt -verbose -lint -dstar .github/workflows/* .PHONY: fix-rust-formatting fix-rust-formatting: - docker build -t fix-rust-formatting -f ci/fix-rust-formatting.Dockerfile . - docker run $(DOCKER_RUN_WRITE_OPTS) fix-rust-formatting + cargo fmt --all -- --config=group_imports=StdExternalCrate .PHONY: fix-shell-formatting fix-shell-formatting: - docker run $(DOCKER_RUN_WRITE_OPTS) mvdan/shfmt:$(SHFMT_VERSION) --simplify --write ci/* + shfmt --simplify --write ci/* .PHONY: fix-yaml-formatting fix-yaml-formatting: - docker run $(DOCKER_RUN_WRITE_OPTS) ghcr.io/google/yamlfmt:$(YAMLFMT_VERSION) -verbose -dstar .github/workflows/* + yamlfmt -verbose -dstar .github/workflows/* .PHONY: check-rust-linting check-rust-linting: - docker build -t check-rust-linting -f ci/check-rust-linting.Dockerfile . - docker run $(DOCKER_RUN_OPTS) check-rust-linting + cargo clippy --verbose $(CARGO_LOCKED) -- -D warnings -# renovate: depName=rhysd/actionlint -ACTIONLINT_VERSION=1.7.10@sha256:ef8299f97635c4c30e2298f48f30763ab782a4ad2c95b744649439a039421e36 +.PHONY: check-shell-linting +check-shell-linting: + shellcheck ci/*.sh .PHONY: check-github-actions-workflows-linting check-github-actions-workflows-linting: - docker run $(DOCKER_RUN_WRITE_OPTS) rhysd/actionlint:$(ACTIONLINT_VERSION) -verbose -color + actionlint -verbose -color + +.PHONY: check-scripts-permissions +check-scripts-permissions: + ./ci/check-scripts-permissions.sh .PHONY: compile compile: - docker build -t compile -f ci/compile.Dockerfile . - docker run $(DOCKER_RUN_WRITE_OPTS) compile + cargo build --verbose $(CARGO_LOCKED) .PHONY: unit-test unit-test: - docker build -t unit-test -f ci/unit-test.Dockerfile . - docker run $(DOCKER_RUN_WRITE_OPTS) unit-test + cargo test --verbose $(CARGO_LOCKED) + +.PHONY: release +release: + cargo build --release --target=$(MUSL_TARGET) --locked --verbose + +.PHONY: publish-binary +publish-binary: release + ./ci/publish-binary.sh ${RELEASE} $(MUSL_TARGET) + +.PHONY: publish-docker-image +publish-docker-image: + ./ci/publish-docker-image.sh ${RELEASE} ${PLATFORM} ${TARGET} ${SUFFIX} + +.PHONY: publish-docker-manifest +publish-docker-manifest: + ./ci/publish-docker-manifest.sh ${RELEASE} diff --git a/ci/check-rust-formatting.Dockerfile b/ci/check-rust-formatting.Dockerfile deleted file mode 100644 index 1d285ca..0000000 --- a/ci/check-rust-formatting.Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM rust:1.92.0-alpine3.21@sha256:82e772a24cfceaea095cc3f36b7bdeab048fc4f1164e0948939ee7a3f070ddbb -RUN rustup component add rustfmt - -ENTRYPOINT ["cargo", "fmt", "--all", "--", "--check", "--config=group_imports=StdExternalCrate"] diff --git a/ci/check-rust-linting.Dockerfile b/ci/check-rust-linting.Dockerfile deleted file mode 100644 index 040c7e6..0000000 --- a/ci/check-rust-linting.Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM rust:1.92.0-alpine3.21@sha256:82e772a24cfceaea095cc3f36b7bdeab048fc4f1164e0948939ee7a3f070ddbb -RUN apk add --no-cache \ - musl-dev=1.2.5-r9 -RUN rustup component add clippy - -ENTRYPOINT ["cargo", "clippy", "--verbose", "--target=x86_64-unknown-linux-musl", "--locked", "--", "-D", "warnings"] diff --git a/ci/check-scripts-permissions.sh b/ci/check-scripts-permissions.sh new file mode 100755 index 0000000..67821de --- /dev/null +++ b/ci/check-scripts-permissions.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env sh + +set -o errexit +set -o xtrace + +exit_code=0 +for script in ci/*.sh; do + if [ -f "$script" ] && [ ! -x "$script" ]; then + exit_code=1 + fi +done + +exit $exit_code diff --git a/ci/compile.Dockerfile b/ci/compile.Dockerfile deleted file mode 100644 index 1357901..0000000 --- a/ci/compile.Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM rust:1.92.0-alpine3.21@sha256:82e772a24cfceaea095cc3f36b7bdeab048fc4f1164e0948939ee7a3f070ddbb -RUN apk add --no-cache \ - musl-dev=1.2.5-r9 - -ENTRYPOINT ["cargo", "build", "--target=x86_64-unknown-linux-musl", "--locked"] diff --git a/ci/fix-rust-formatting.Dockerfile b/ci/fix-rust-formatting.Dockerfile deleted file mode 100644 index 0125465..0000000 --- a/ci/fix-rust-formatting.Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM rust:1.92.0-alpine3.21@sha256:82e772a24cfceaea095cc3f36b7bdeab048fc4f1164e0948939ee7a3f070ddbb -RUN rustup component add rustfmt - -ENTRYPOINT ["cargo", "fmt", "--all", "--", "--config=group_imports=StdExternalCrate"] diff --git a/ci/publish-binary.sh b/ci/publish-binary.sh new file mode 100755 index 0000000..fcf0df9 --- /dev/null +++ b/ci/publish-binary.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh + +set -o errexit +set -o xtrace + +if [ "$#" -ne 2 ]; then + echo "Usage: $0 RELEASE_TAG TARGET" + echo "$#" + exit 1 +fi + +RELEASE="$1" +TARGET="$2" + +tar -czvf "${TARGET}.tar.gz" -C "target/${TARGET}/release" "monkey_interpreter" +gh release upload "${RELEASE}" "${TARGET}.tar.gz" +rm "${TARGET}.tar.gz" diff --git a/ci/publish-docker-image.sh b/ci/publish-docker-image.sh new file mode 100755 index 0000000..a078c21 --- /dev/null +++ b/ci/publish-docker-image.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +set -o errexit +set -o xtrace + +if [ $# -ne 4 ]; then + echo "Usage: $0 " + exit 1 +fi + +RELEASE="$1" +PLATFORM="$2" +TARGET="$3" +SUFFIX="$4" + +REPOSITORY="$(basename "$(git rev-parse --show-toplevel)")" +IMAGE="ghcr.io/developerc286/${REPOSITORY}" + +# Download and extract pre-built binary from the GitHub release for this architecture. +gh release download "${RELEASE}" --pattern "${TARGET}.tar.gz" +mkdir -p "target/${TARGET}/release" +tar -xzf "${TARGET}.tar.gz" -C "target/${TARGET}/release" + +# Build and push the Docker image for this architecture natively (no QEMU emulation). +docker buildx build --platform "${PLATFORM}" --build-arg TARGET="${TARGET}" --tag "${IMAGE}:${RELEASE}-${SUFFIX}" --file Dockerfile . --push diff --git a/ci/publish-docker-manifest.sh b/ci/publish-docker-manifest.sh new file mode 100755 index 0000000..7c203c5 --- /dev/null +++ b/ci/publish-docker-manifest.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env sh + +set -o errexit +set -o xtrace + +if [ $# -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +RELEASE="$1" +REPOSITORY="$(basename "$(git rev-parse --show-toplevel)")" +IMAGE="ghcr.io/developerc286/${REPOSITORY}" + +# Create and push the multi-architecture manifest. +docker buildx imagetools create --tag "${IMAGE}:${RELEASE}" \ + "${IMAGE}:${RELEASE}-amd64" \ + "${IMAGE}:${RELEASE}-arm64" + +# Create alternate version tag (with/without 'v' prefix). +if [ "${RELEASE#v}" != "${RELEASE}" ]; then + # Release has 'v' prefix (v1.2.3), also create version without 'v' prefix (1.2.3). + docker buildx imagetools create --tag "${IMAGE}:${RELEASE#v}" "${IMAGE}:${RELEASE}" +else + # Release has no 'v' prefix (1.2.3), also create version with 'v' prefix (v1.2.3). + docker buildx imagetools create --tag "${IMAGE}:v${RELEASE}" "${IMAGE}:${RELEASE}" +fi diff --git a/ci/unit-test.Dockerfile b/ci/unit-test.Dockerfile deleted file mode 100644 index 52d752b..0000000 --- a/ci/unit-test.Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM rust:1.92.0-alpine3.21@sha256:82e772a24cfceaea095cc3f36b7bdeab048fc4f1164e0948939ee7a3f070ddbb -RUN apk add --no-cache \ - musl-dev=1.2.5-r9 - -ENTRYPOINT ["cargo", "test", "--verbose", "--target=x86_64-unknown-linux-musl", "--locked"] diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c8db83a --- /dev/null +++ b/flake.lock @@ -0,0 +1,82 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1767364772, + "narHash": "sha256-fFUnEYMla8b7UKjijLnMe+oVFOz6HjijGGNS1l7dYaQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "16c7794d0a28b5a37904d55bcca36003b9109aaa", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1767408057, + "narHash": "sha256-0TD2PNTt6olOonFgcvZJcNGiU3x5cX+RMzrfWfHB9Jw=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "294198315a13d6d130565ad08e97685df7b0d458", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..87930f2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,55 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + + # Architecture-specific target + rustTarget = if pkgs.stdenv.isAarch64 + then "aarch64-unknown-linux-musl" + else "x86_64-unknown-linux-musl"; + + rustWithTargets = pkgs.rust-bin.stable.latest.default.override { + targets = [ rustTarget ]; + }; + in + { + devShells.default = pkgs.mkShell { + # Disable all Nix hardening flags to prevent interference with Cargo builds. + # These flags are designed for C/C++ and can cause issues with: + # - MUSL builds (fortify adds glibc-specific functions) + # - Crates that vendor C libraries (e.g., git2 vendoring libgit2) + # Rust already provides memory safety, so these hardening flags provide + # minimal benefit while causing build problems. + hardeningDisable = [ "all" ]; + + buildInputs = [ + # Rust with cross-compilation targets built-in. + rustWithTargets + # Shell scripts. + pkgs.shfmt + pkgs.shellcheck + # GitHub Action Workflows. + pkgs.yamlfmt + pkgs.actionlint + # Deploying. + pkgs.gh + ]; + }; + } + ); +} diff --git a/release-please-config.json b/release-please-config.json index 351d3cc..f06761c 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -4,6 +4,10 @@ "pull-request-title-pattern": "chore: release ${version}", "include-component-in-tag": false, "packages": { - ".": {} + ".": { + "extra-files": [ + "README.md" + ] + } } }