diff --git a/.envrc b/.envrc index 5333707..e0370ec 100644 --- a/.envrc +++ b/.envrc @@ -1,4 +1,5 @@ -if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" +if ! has nix_direnv_version || ! nix_direnv_version 3.0.7; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.7/direnvrc" "sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM=" fi +watch_file nix/** use flake . diff --git a/.forgejo/workflows/renovate-config-validation.yaml b/.forgejo/workflows/renovate-config-validation.yaml new file mode 100644 index 0000000..96a34e1 --- /dev/null +++ b/.forgejo/workflows/renovate-config-validation.yaml @@ -0,0 +1,24 @@ +--- +name: Checking Renovate configuration + +on: # yamllint disable-line rule:truthy + pull_request: + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Cache npm (renovate) + uses: actions/cache@v4 + with: + path: ~/.npm + key: ${{ runner.os }}-npm-renovate + restore-keys: | + ${{ runner.os }}-npm-renovate- + - name: Validate Renovate configuration + uses: suzuki-shunsuke/github-action-renovate-config-validator@v1.1.1 + env: + NPM_CONFIG_CACHE: ~/.npm +... diff --git a/.forgejo/workflows/rust.yml b/.forgejo/workflows/rust.yml new file mode 100644 index 0000000..7d37f49 --- /dev/null +++ b/.forgejo/workflows/rust.yml @@ -0,0 +1,127 @@ +--- +# yamllint disable rule:line-length + +name: Build and test + +on: # yamllint disable-line rule:truthy + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Cache Rust toolchain + uses: actions/cache@v4 + with: + path: ~/.rustup + key: ${{ runner.os }}-rustup-toolchain-stable-clippy-rustfmt + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1.15.2 + with: + toolchain: stable + components: clippy, rustfmt + - name: Show versions + run: | + rustc --version + cargo --version + - name: Check formatting + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --check + - name: Run tests + uses: actions-rs/cargo@v1 + with: + command: test + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Cache Rust toolchain + uses: actions/cache@v4 + with: + path: ~/.rustup + key: ${{ runner.os }}-rustup-toolchain-stable-clippy-rustfmt + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1.15.2 + with: + toolchain: stable + components: clippy, rustfmt + - name: Show versions + run: | + rustc --version + cargo --version + - name: Clippy check + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + build-amd64: + name: Build AMD64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Cache Rust toolchain + uses: actions/cache@v4 + with: + path: ~/.rustup + key: ${{ runner.os }}-rustup-toolchain-stable-clippy-rustfmt + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1.15.2 + with: + toolchain: stable + components: clippy, rustfmt + - name: Show versions + run: | + rustc --version + cargo --version + - name: Build release binary + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --all-features + - name: Upload binary artifact + uses: https://code.forgejo.org/forgejo/upload-artifact@v4 + with: + name: reddit-magnet-linux-amd64 + path: target/release/reddit-magnet + + rustdoc: + name: Generate Documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Cache Rust toolchain + uses: actions/cache@v4 + with: + path: ~/.rustup + key: ${{ runner.os }}-rustup-toolchain-stable-clippy-rustfmt + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1.15.2 + with: + toolchain: stable + components: clippy, rustfmt + - name: Show versions + run: | + rustc --version + cargo --version + - name: Generate documentation + uses: actions-rs/cargo@v1 + with: + command: doc + args: --all-features --workspace --no-deps + - name: Compress documentation + run: tar -czf rustdoc.tar.gz -C target doc + - name: Upload documentation artifact + uses: https://code.forgejo.org/forgejo/upload-artifact@v4 + with: + name: rustdoc + path: rustdoc.tar.gz +... diff --git a/.forgejo/workflows/yamllint.yaml b/.forgejo/workflows/yamllint.yaml new file mode 100644 index 0000000..1b5cb26 --- /dev/null +++ b/.forgejo/workflows/yamllint.yaml @@ -0,0 +1,18 @@ +--- +name: Checking yaml + +on: # yamllint disable-line rule:truthy + pull_request: + +jobs: + yamllint: + name: Run yamllint + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Run YAML linter + uses: bewuethr/yamllint-action@v1 + with: + config-file: .yamllint.yaml +... diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 36e791a..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,84 +0,0 @@ ---- -stages: - - test - - build - - publish - - -default: - -tests: - stage: test - image: rust - before_script: - - rustc --version - - cargo --version - - rustup component add rustfmt - script: - - cargo fmt --check - - cargo test - -flake-check: - stage: test - image: nixpkgs/nix-flakes:nixos-24.11-x86_64-linux - before_script: - - mkdir -p ~/.ssh - - eval $(ssh-agent -s) - - chmod 400 "$NIX_SSH_PRIVATE_KEY" - - ssh-add "$NIX_SSH_PRIVATE_KEY" - - cp "$SSH_KNOWN_HOSTS" ~/.ssh/known_hosts - - chmod 644 ~/.ssh/known_hosts - - echo "substituters = ssh://nix-ssh@build.enoent.fr?priority=10 https://cache.nixos.org?priority=40 https://cuda-maintainers.cachix.org https://nix-community.cachix.org https://statix.cachix.org https://pre-commit-hooks.cachix.org" >> /etc/nix/nix.conf - - echo "trusted-substituters = ssh://nix-ssh@build.enoent.fr" >> /etc/nix/nix.conf - - echo "trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= statix.cachix.org-1:Z9E/g1YjCjU117QOOt07OjhljCoRZddiAm4VVESvais= pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc=" >> /etc/nix/nix.conf - - echo "extra-trusted-public-keys = galatea-0:E7F1FzfoY+X9l9Xn9AvNWDkW1U7H644FHDzX3lpxHkI=" >> /etc/nix/nix.conf - - echo "builders-use-substitutes = true" >> /etc/nix/nix.conf - - echo "max-jobs = 0" >> /etc/nix/nix.conf - - echo "ssh://nix-ssh@build.enoent.fr x86_64-linux" >> /etc/nix/machines - - echo "ssh://nix-ssh@build.enoent.fr aarch64-linux" >> /etc/nix/machines - - nix store info --store ssh://nix-ssh@build.enoent.fr - script: - - nix flake check - -build:amd64: - stage: build - image: rust - before_script: - - rustc --version - - cargo --version - script: - - cargo build --release - artifacts: - paths: - - target/release/reddit-magnet - -rustdoc: - stage: build - image: rust - before_script: - - rustc --version - - cargo --version - script: - - cargo doc - artifacts: - paths: - - target/doc - -pages: - stage: publish - image: alpine - dependencies: - - build:amd64 - - rustdoc - script: - - mkdir -p public - - mv target/doc public/doc - - mv target/release/reddit-magnet public/reddit-magnet-amd64 - artifacts: - paths: - - public - only: - - main -... - - diff --git a/flake.lock b/flake.lock index b0d5b5f..10544b1 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", "owner": "edolstra", "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", "type": "github" }, "original": { @@ -57,11 +57,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1747744144, - "narHash": "sha256-W7lqHp0qZiENCDwUZ5EX/lNhxjMdNapFnbErcbnP11Q=", + "lastModified": 1761373498, + "narHash": "sha256-Q/uhWNvd7V7k1H1ZPMy/vkx3F8C13ZcdrKjO7Jv7v0c=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2795c506fe8fb7b03c36ccb51f75b6df0ab2553f", + "rev": "6a08e6bb4e46ff7fcbb53d409b253f6bad8a28ce", "type": "github" }, "original": { @@ -80,11 +80,11 @@ ] }, "locked": { - "lastModified": 1747372754, - "narHash": "sha256-2Y53NGIX2vxfie1rOW0Qb86vjRZ7ngizoo+bnXU9D9k=", + "lastModified": 1760663237, + "narHash": "sha256-BflA6U4AM1bzuRMR8QqzPXqh8sWVCNDzOdsxXEguJIc=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "80479b6ec16fefd9c1db3ea13aeb038c60530f46", + "rev": "ca5b894d3e3e151ffc1db040b6ce4dcc75d31c37", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index d3dd6f0..6895953 100644 --- a/flake.nix +++ b/flake.nix @@ -33,7 +33,7 @@ in { checks = import ./nix/git-hooks.nix { inherit inputs pkgs; }; - devShells = import ./nix/shell.nix { inherit pkgs rust-toolchain self; }; + devShells = import ./nix/shell.nix { inherit pkgs rust-toolchain self; inherit (pkgs) lib; }; formatter = pkgs.nixpkgs-fmt; }); } diff --git a/nix/shell.nix b/nix/shell.nix index 4442aa3..1df0831 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -1,4 +1,4 @@ -{ pkgs, rust-toolchain, self, ... }: +{ lib, pkgs, rust-toolchain, self, ... }: { default = pkgs.mkShell { @@ -18,10 +18,13 @@ rust-toolchain sqlfluff sqlite + sccache ] ++ lib.optionals stdenv.isDarwin [ libiconv ] ++ self.checks.${pkgs.system}.pre-commit-check.enabledPackages; + RUST_BACKTRACE = 1; + RUSTC_WRAPPER = lib.getExe pkgs.sccache; # Copy rust-toolchain to project directory for easy use in IntelliJ shellHook = ''