From d3e0aaf7fe1bb4eb49b94db1eb9d9811fc233831 Mon Sep 17 00:00:00 2001 From: siddhantCodes Date: Tue, 23 Jan 2024 18:53:17 +0530 Subject: [PATCH 1/7] x86_64-unknow-linux-musl working with https://github.com/NixOS/nixpkgs/pull/282798 --- flake.lock | 122 +++++------------------------------------------------ flake.nix | 60 ++++++++++++++------------ 2 files changed, 44 insertions(+), 138 deletions(-) diff --git a/flake.lock b/flake.lock index 940c21d2ae..60e8e2132c 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "type": "github" }, "original": { @@ -18,84 +18,18 @@ "type": "github" } }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, - "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "naersk": { - "inputs": { - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1698420672, - "narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=", - "owner": "nix-community", - "repo": "naersk", - "rev": "aeb58d5e8faead8980a807c840232697982d47b9", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "naersk", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1697730408, - "narHash": "sha256-Ww//zzukdTrwTrCUkaJA/NsaLEfUfQpWZXBdXBYfhak=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "ff0a5a776b56e0ca32d47a4a47695452ec7f7d80", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1704008649, - "narHash": "sha256-rGPSWjXTXTurQN9beuHdyJhB8O761w1Zc5BqSSmHvoM=", - "owner": "NixOS", + "lastModified": 1705901790, + "narHash": "sha256-gZzL+E91/DJyvF+OxRNbgzAGTLkcm9CxIgFZyeDXCBU=", + "owner": "junjihashimoto", "repo": "nixpkgs", - "rev": "d44d59d2b5bd694cd9d996fd8c51d03e3e9ba7f7", + "rev": "8c2abbaad6456d7a3c9752bfc2caf4d982427100", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { - "locked": { - "lastModified": 1681358109, - "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", + "owner": "junjihashimoto", + "ref": "feature/rust-dup", "repo": "nixpkgs", "type": "github" } @@ -103,28 +37,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", - "naersk": "naersk", - "nixpkgs": "nixpkgs_2", - "rust-overlay": "rust-overlay" - } - }, - "rust-overlay": { - "inputs": { - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_3" - }, - "locked": { - "lastModified": 1704075545, - "narHash": "sha256-L3zgOuVKhPjKsVLc3yTm2YJ6+BATyZBury7wnhyc8QU=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "a0df72e106322b67e9c6e591fe870380bd0da0d5", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" + "nixpkgs": "nixpkgs" } }, "systems": { @@ -141,21 +54,6 @@ "repo": "default", "type": "github" } - }, - "systems_2": { - "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", diff --git a/flake.nix b/flake.nix index c25873cd25..7b48ef47a3 100644 --- a/flake.nix +++ b/flake.nix @@ -2,47 +2,55 @@ inputs = { flake-utils.url = "github:numtide/flake-utils"; - naersk.url = "github:nix-community/naersk"; - - rust-overlay.url = "github:oxalica/rust-overlay"; - - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nixpkgs.url = "github:junjihashimoto/nixpkgs/feature/rust-dup"; }; - outputs = { self, flake-utils, nixpkgs, rust-overlay, naersk }: + outputs = { self, flake-utils, nixpkgs }: flake-utils.lib.eachDefaultSystem (system: let pkgs = (import nixpkgs) { inherit system; overlays = [ - (import rust-overlay) + (final: prev: { + postgresql-static = (prev.postgresql.overrideAttrs (old: { dontDisableStatic = true; })).override { + # We need libpq, which does not need systemd, + # and systemd doesn't currently build with musl. + enableSystemd = false; + }; + }) ]; }; - toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain; - - naersk' = pkgs.callPackage naersk { - cargo = toolchain; - rustc = toolchain; - }; - - cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); - - fastn = naersk'.buildPackage { + fastn = pkgs.pkgsStatic.rustPlatform.buildRustPackage { name = "fastn"; - version = cargoToml.workspace.package.version; + version = "0.4.47"; src = pkgs.lib.cleanSource ./.; + doCheck = false; - nativeBuildInputs = with pkgs; [ - pkg-config - openssl.dev - ] ++ lib.optionals stdenv.isDarwin [ xcbuild ]; + nativeBuildInputs = [ pkgs.pkgsStatic.pkg-config pkgs.postgresql-static ]; - buildInputs = with pkgs; lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.SystemConfiguration - ]; + PKG_CONFIG_PATH = "${pkgs.pkgsStatic.openssl.dev}/lib/pkgconfig"; + + buildFeatures = [ "auth" ]; + + cargoLock = { + lockFile = ./Cargo.lock; + allowBuiltinFetchGit = true; + }; }; + + # my-bin = pkgs.pkgsCross.mingwW64.rustPlatform.buildRustPackage { + # name = "fastn"; + # version = "0.4.42"; + # src = pkgs.lib.cleanSource ./.; + # cargoLock = { + # lockFile = ./Cargo.lock; + # allowBuiltinFetchGit = true; + # }; + + # target = "x86_64-pc-windows-gnu"; + # }; in rec { # For `nix build` & `nix run`: @@ -55,7 +63,7 @@ # nix develop devShell = pkgs.mkShell { name = "fastn-shell"; - nativeBuildInputs = with pkgs; [ toolchain pkg-config openssl.dev postgresql_14 rust-analyzer ]; + nativeBuildInputs = with pkgs; [ pkg-config openssl.dev postgresql_14 rust-analyzer ]; shellHook = '' export PATH="$PATH:$HOME/.cargo/bin" From 82c4d8cef402c0f05227fafa9f046eebe6ad2428 Mon Sep 17 00:00:00 2001 From: siddhantCodes Date: Sat, 27 Jan 2024 14:23:52 +0530 Subject: [PATCH 2/7] nix windows and linux-musl builds --- Cargo.lock | 10 ----- Cargo.toml | 10 +---- fastn.nix | 29 +++++++++++++ flake.nix | 49 +++++----------------- integration-tests/_tests/00-hello.test.ftd | 7 ++++ integration-tests/test.js | 21 ++++++++++ 6 files changed, 69 insertions(+), 57 deletions(-) create mode 100644 fastn.nix create mode 100644 integration-tests/_tests/00-hello.test.ftd create mode 100644 integration-tests/test.js diff --git a/Cargo.lock b/Cargo.lock index 7fc0c22310..6ddfd9f0f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1333,7 +1333,6 @@ dependencies = [ "chrono", "diesel_derives", "itoa", - "pq-sys", ] [[package]] @@ -3595,15 +3594,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "pq-sys" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0052426df997c0cbd30789eb44ca097e3541717a7b8fa36b1c464ee7edebd" -dependencies = [ - "vcpkg", -] - [[package]] name = "precomputed-hash" version = "0.1.1" diff --git a/Cargo.toml b/Cargo.toml index 38eafa47ff..6885717c5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -148,7 +148,7 @@ prettify-js = "0.1.0" indexmap = { version = "2", features = ["serde"] } argon2 = "0.5" lettre = { version = "0.11", features = ["serde", "tokio1", "tokio1-native-tls"]} -diesel = { version = "2.1", features = ["chrono", "postgres", "postgres_backend"]} +diesel = { version = "2.1", features = ["chrono", "postgres_backend"]} diesel-async = { version = "0.4", features = ["postgres", "deadpool", "async-connection-wrapper"]} diesel_async_migrations = "0.12" chrono = { version = "0.4", features = ["serde"]} @@ -181,14 +181,6 @@ features = [ "column_decltype", ] -[workspace.dependencies.pq-sys] -version = "0.4" -features = [ - # see workspace.dependencies.rusqlite - "bundled" -] - - [workspace.dependencies.web-sys] version = "0.3" features = [ diff --git a/fastn.nix b/fastn.nix new file mode 100644 index 0000000000..36e623d130 --- /dev/null +++ b/fastn.nix @@ -0,0 +1,29 @@ +{ rustPlatform, stdenv, pkg-config, lib, windows, openssl }: +rustPlatform.buildRustPackage { + name = "fastn"; + version = "0.4.47"; + src = lib.cleanSource ./.; + doCheck = false; + + nativeBuildInputs = [ pkg-config ]; + + buildInputs = lib.optional stdenv.targetPlatform.isWindows [ + windows.mingw_w64_pthreads + windows.pthreads + ]; + + # https://docs.rs/pkg-config/latest/pkg_config/ + PKG_CONFIG_ALL_STATIC = "1"; + + PKG_CONFIG_PATH = "${openssl.dev}/lib/pkgconfig"; + + RUSTFLAGS = "-C target-feature=+crt-static"; + + buildFeatures = [ "auth" ]; + + cargoLock = { + lockFile = ./Cargo.lock; + allowBuiltinFetchGit = true; + }; +} + diff --git a/flake.nix b/flake.nix index 7b48ef47a3..84e75362ed 100644 --- a/flake.nix +++ b/flake.nix @@ -11,46 +11,12 @@ pkgs = (import nixpkgs) { inherit system; - overlays = [ - (final: prev: { - postgresql-static = (prev.postgresql.overrideAttrs (old: { dontDisableStatic = true; })).override { - # We need libpq, which does not need systemd, - # and systemd doesn't currently build with musl. - enableSystemd = false; - }; - }) - ]; - }; - - fastn = pkgs.pkgsStatic.rustPlatform.buildRustPackage { - name = "fastn"; - version = "0.4.47"; - src = pkgs.lib.cleanSource ./.; - doCheck = false; - - nativeBuildInputs = [ pkgs.pkgsStatic.pkg-config pkgs.postgresql-static ]; - - PKG_CONFIG_PATH = "${pkgs.pkgsStatic.openssl.dev}/lib/pkgconfig"; - - buildFeatures = [ "auth" ]; - - cargoLock = { - lockFile = ./Cargo.lock; - allowBuiltinFetchGit = true; - }; + overlays = [ ]; }; - # my-bin = pkgs.pkgsCross.mingwW64.rustPlatform.buildRustPackage { - # name = "fastn"; - # version = "0.4.42"; - # src = pkgs.lib.cleanSource ./.; - # cargoLock = { - # lockFile = ./Cargo.lock; - # allowBuiltinFetchGit = true; - # }; - # target = "x86_64-pc-windows-gnu"; - # }; + fastn = pkgs.pkgsStatic.callPackage ./fastn.nix { }; + fastn-win = pkgs.pkgsStatic.pkgsCross.mingwW64.callPackage ./fastn.nix { }; in rec { # For `nix build` & `nix run`: @@ -58,12 +24,19 @@ packages = { inherit fastn; + inherit fastn-win; }; # nix develop devShell = pkgs.mkShell { name = "fastn-shell"; - nativeBuildInputs = with pkgs; [ pkg-config openssl.dev postgresql_14 rust-analyzer ]; + nativeBuildInputs = with pkgs; [ + rustc + cargo + pkg-config + openssl.dev + rust-analyzer + ]; shellHook = '' export PATH="$PATH:$HOME/.cargo/bin" diff --git a/integration-tests/_tests/00-hello.test.ftd b/integration-tests/_tests/00-hello.test.ftd new file mode 100644 index 0000000000..f4b961d39e --- /dev/null +++ b/integration-tests/_tests/00-hello.test.ftd @@ -0,0 +1,7 @@ +-- import: fastn + +-- fastn.test: Hello route + +-- fastn.get: Fetching Test Data (from test server) +url: /hello/ +http-status: 200 diff --git a/integration-tests/test.js b/integration-tests/test.js new file mode 100644 index 0000000000..6aa02bec14 --- /dev/null +++ b/integration-tests/test.js @@ -0,0 +1,21 @@ +{"redirect":"http://localhost:8080/hello/","user":{"created_at":"2024-01-15T10:56:59.885382Z","id":35,"name":"John","username":"john"}} +fastn.test_results = {}; + +fastn.test_results["1"] = {"data":null,"errors":{"payload":"invalid payload: SerdeJsonError(Error(\"missing field `email`\", line: 1, column: 24))"}}; + +fastn.http_status = 200; + +fastn.http_location = ""; + + + +fastn.test_result = []; + + +fastn.assert = {eq: function (a, b) {n a = fastn_utils.getStaticValue(a);n b = fastn_utils.getStaticValue(b);n fastn.test_result.push(a === b);n },n ne: function (a, b) {n a = fastn_utils.getStaticValue(a);n b = fastn_utils.getStaticValue(b);n fastn.test_result.push(a !== b);n },n exists: function (a) {n a = fastn_utils.getStaticValue(a);n fastn.test_result.push(a !== undefined);n },n not_empty: function (a) {n a = fastn_utils.getStaticValue(a);n if (Array.isArray(a)) {n fastn.test_result.push(a.length > 0);n }n if (a instanceof String) {n fastn.test_result.push(a.length > 0);n }n fastn.test_result.push(a !== undefined);n }}; + +fastn.assert.eq(1, 1); + + +nfastn.test_result + From 2645f38cd7f3f9922514f336a914f2e100b782d4 Mon Sep 17 00:00:00 2001 From: siddhantCodes Date: Sat, 3 Feb 2024 20:20:30 +0530 Subject: [PATCH 3/7] WIP: test nix on CI --- .github/workflows/test-ci-release.yml | 70 +++++++++++++++++++++++++++ fastn.nix | 9 +++- flake.nix | 2 + 3 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test-ci-release.yml diff --git a/.github/workflows/test-ci-release.yml b/.github/workflows/test-ci-release.yml new file mode 100644 index 0000000000..daae7d9228 --- /dev/null +++ b/.github/workflows/test-ci-release.yml @@ -0,0 +1,70 @@ +name: Test nix on + +on: + push: + branches: [ feat/nix ] +jobs: + release-ubuntu: + name: Build for Linux + runs-on: ubuntu-latest + env: + CARGO_TERM_COLOR: always + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@v9 + - name: build linux-musl + run: nix build -L .#fastn + - name: test the output binary + run: | + ldd result/bin/fastn + ./result/bin/fastn --version + # - name: Build-musl + # run: | + # echo "Building static binaries using ekidd/rust-musl-builder" + # docker build -t fastn-build-image -f .github/Dockerfile . + # docker run --name fastn-build fastn-build-image + # mkdir -p out + # docker cp fastn-build:/home/rust/src/target/x86_64-unknown-linux-musl/release/fastn out/ + # - name: run fastn + # run: out/fastn --version + # - uses: actions/upload-artifact@v4 + # with: + # name: linux_musl_x86_64 + # path: out/fastn + release-windows: + name: Build for win 64 + runs-on: ubuntu-latest + env: + CARGO_TERM_COLOR: always + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@v9 + - name: build mingwW64 + run: nix build -L .#fastn-win + - name: test the output binary + # wine? + # run: ldd result/bin/fastn.exe + # run: ./result/bin/fastn.exe --version + run: | + ls result/bin/ + file result/bin/fastn.exe + ldd result/bin/fastn.exe + release-macos: + name: Build for MacOS + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@v9 + - name: build mac + run: nix build -L .#fastn + - name: test the output binary on mac + run: | + ldd result/bin/fastn + ./result/bin/fastn --version + # - name: run fastn + # run: ./target/release/fastn --version + # - uses: actions/upload-artifact@v4 + # with: + # name: macos_x64_latest + # path: | + # target/release/fastn diff --git a/fastn.nix b/fastn.nix index 36e623d130..398b784783 100644 --- a/fastn.nix +++ b/fastn.nix @@ -1,9 +1,14 @@ { rustPlatform, stdenv, pkg-config, lib, windows, openssl }: +let + fastnCargo = builtins.fromTOML (builtins.readFile ./fastn/Cargo.toml); + version = fastnCargo.package.version; +in rustPlatform.buildRustPackage { name = "fastn"; - version = "0.4.47"; + inherit version; src = lib.cleanSource ./.; - doCheck = false; + + doCheck = false; # set this to true to run cargo test nativeBuildInputs = [ pkg-config ]; diff --git a/flake.nix b/flake.nix index 84e75362ed..8efb538412 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,8 @@ inputs = { flake-utils.url = "github:numtide/flake-utils"; + # TODO: use nixpkgs/unstable when this is merged: + # https://github.com/NixOS/nixpkgs/pull/282798 nixpkgs.url = "github:junjihashimoto/nixpkgs/feature/rust-dup"; }; From ca14ee20ad959dd9cbf7d3a0377ad1fac3f1c4b7 Mon Sep 17 00:00:00 2001 From: siddhantCodes Date: Sat, 3 Feb 2024 21:51:54 +0530 Subject: [PATCH 4/7] test CI time with magic-nix-cache --- .github/workflows/test-ci-release.yml | 3 +++ fastn.nix | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-ci-release.yml b/.github/workflows/test-ci-release.yml index daae7d9228..d1244bf2a6 100644 --- a/.github/workflows/test-ci-release.yml +++ b/.github/workflows/test-ci-release.yml @@ -12,6 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@v9 + - uses: DeterminateSystems/magic-nix-cache-action@v3 - name: build linux-musl run: nix build -L .#fastn - name: test the output binary @@ -39,6 +40,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@v9 + - uses: DeterminateSystems/magic-nix-cache-action@v3 - name: build mingwW64 run: nix build -L .#fastn-win - name: test the output binary @@ -55,6 +57,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@v9 + - uses: DeterminateSystems/magic-nix-cache-action@v3 - name: build mac run: nix build -L .#fastn - name: test the output binary on mac diff --git a/fastn.nix b/fastn.nix index 398b784783..853e756184 100644 --- a/fastn.nix +++ b/fastn.nix @@ -22,7 +22,7 @@ rustPlatform.buildRustPackage { PKG_CONFIG_PATH = "${openssl.dev}/lib/pkgconfig"; - RUSTFLAGS = "-C target-feature=+crt-static"; + # RUSTFLAGS = "-C target-feature=+crt-static"; buildFeatures = [ "auth" ]; From 867386c1ada933a8ff1e9e7655d7125d0827e582 Mon Sep 17 00:00:00 2001 From: siddhantCodes Date: Sat, 3 Feb 2024 22:36:19 +0530 Subject: [PATCH 5/7] release builds using nix --- .github/workflows/release.yml | 51 ++++----------- .github/workflows/test-ci-release.yml | 73 ---------------------- fastn.nix | 2 +- integration-tests/_tests/00-hello.test.ftd | 7 --- integration-tests/test.js | 21 ------- 5 files changed, 13 insertions(+), 141 deletions(-) delete mode 100644 .github/workflows/test-ci-release.yml delete mode 100644 integration-tests/_tests/00-hello.test.ftd delete mode 100644 integration-tests/test.js diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8661531f07..1ab2070301 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,56 +17,29 @@ jobs: CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - ftd/target - fifthtry_content/target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Build-musl - run: | - echo "Building static binaries using ekidd/rust-musl-builder" - docker build -t fastn-build-image -f .github/Dockerfile . - docker run --name fastn-build fastn-build-image - mkdir -p out - docker cp fastn-build:/home/rust/src/target/x86_64-unknown-linux-musl/release/fastn out/ + - uses: DeterminateSystems/nix-installer-action@v9 + - uses: DeterminateSystems/magic-nix-cache-action@v3 + - name: build linux-musl + run: nix build -L .#fastn - name: run fastn - run: out/fastn --version + run: ./result/bin/fastn --version - uses: actions/upload-artifact@v4 with: name: linux_musl_x86_64 - path: out/fastn + path: result/bin/fastn release-windows: name: Build for Windows - runs-on: windows-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - ftd/target - fifthtry_content/target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Run Build - id: build-windows - continue-on-error: false - uses: actions-rs/cargo@v1 - with: - command: build - args: --release - - name: run fastn - run: ./target/release/fastn.exe --version + - uses: DeterminateSystems/nix-installer-action@v9 + - uses: DeterminateSystems/magic-nix-cache-action@v3 + - name: build mingwW64 + run: nix build -L .#fastn-win - uses: actions/upload-artifact@v4 with: name: windows_x64_latest - path: target/release/fastn.exe + path: result/bin/fastn.exe - name: Download EnVar plugin for NSIS uses: carlosperate/download-file-action@v1.0.3 with: diff --git a/.github/workflows/test-ci-release.yml b/.github/workflows/test-ci-release.yml deleted file mode 100644 index d1244bf2a6..0000000000 --- a/.github/workflows/test-ci-release.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Test nix on - -on: - push: - branches: [ feat/nix ] -jobs: - release-ubuntu: - name: Build for Linux - runs-on: ubuntu-latest - env: - CARGO_TERM_COLOR: always - steps: - - uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@v9 - - uses: DeterminateSystems/magic-nix-cache-action@v3 - - name: build linux-musl - run: nix build -L .#fastn - - name: test the output binary - run: | - ldd result/bin/fastn - ./result/bin/fastn --version - # - name: Build-musl - # run: | - # echo "Building static binaries using ekidd/rust-musl-builder" - # docker build -t fastn-build-image -f .github/Dockerfile . - # docker run --name fastn-build fastn-build-image - # mkdir -p out - # docker cp fastn-build:/home/rust/src/target/x86_64-unknown-linux-musl/release/fastn out/ - # - name: run fastn - # run: out/fastn --version - # - uses: actions/upload-artifact@v4 - # with: - # name: linux_musl_x86_64 - # path: out/fastn - release-windows: - name: Build for win 64 - runs-on: ubuntu-latest - env: - CARGO_TERM_COLOR: always - steps: - - uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@v9 - - uses: DeterminateSystems/magic-nix-cache-action@v3 - - name: build mingwW64 - run: nix build -L .#fastn-win - - name: test the output binary - # wine? - # run: ldd result/bin/fastn.exe - # run: ./result/bin/fastn.exe --version - run: | - ls result/bin/ - file result/bin/fastn.exe - ldd result/bin/fastn.exe - release-macos: - name: Build for MacOS - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@v9 - - uses: DeterminateSystems/magic-nix-cache-action@v3 - - name: build mac - run: nix build -L .#fastn - - name: test the output binary on mac - run: | - ldd result/bin/fastn - ./result/bin/fastn --version - # - name: run fastn - # run: ./target/release/fastn --version - # - uses: actions/upload-artifact@v4 - # with: - # name: macos_x64_latest - # path: | - # target/release/fastn diff --git a/fastn.nix b/fastn.nix index 853e756184..398b784783 100644 --- a/fastn.nix +++ b/fastn.nix @@ -22,7 +22,7 @@ rustPlatform.buildRustPackage { PKG_CONFIG_PATH = "${openssl.dev}/lib/pkgconfig"; - # RUSTFLAGS = "-C target-feature=+crt-static"; + RUSTFLAGS = "-C target-feature=+crt-static"; buildFeatures = [ "auth" ]; diff --git a/integration-tests/_tests/00-hello.test.ftd b/integration-tests/_tests/00-hello.test.ftd deleted file mode 100644 index f4b961d39e..0000000000 --- a/integration-tests/_tests/00-hello.test.ftd +++ /dev/null @@ -1,7 +0,0 @@ --- import: fastn - --- fastn.test: Hello route - --- fastn.get: Fetching Test Data (from test server) -url: /hello/ -http-status: 200 diff --git a/integration-tests/test.js b/integration-tests/test.js deleted file mode 100644 index 6aa02bec14..0000000000 --- a/integration-tests/test.js +++ /dev/null @@ -1,21 +0,0 @@ -{"redirect":"http://localhost:8080/hello/","user":{"created_at":"2024-01-15T10:56:59.885382Z","id":35,"name":"John","username":"john"}} -fastn.test_results = {}; - -fastn.test_results["1"] = {"data":null,"errors":{"payload":"invalid payload: SerdeJsonError(Error(\"missing field `email`\", line: 1, column: 24))"}}; - -fastn.http_status = 200; - -fastn.http_location = ""; - - - -fastn.test_result = []; - - -fastn.assert = {eq: function (a, b) {n a = fastn_utils.getStaticValue(a);n b = fastn_utils.getStaticValue(b);n fastn.test_result.push(a === b);n },n ne: function (a, b) {n a = fastn_utils.getStaticValue(a);n b = fastn_utils.getStaticValue(b);n fastn.test_result.push(a !== b);n },n exists: function (a) {n a = fastn_utils.getStaticValue(a);n fastn.test_result.push(a !== undefined);n },n not_empty: function (a) {n a = fastn_utils.getStaticValue(a);n if (Array.isArray(a)) {n fastn.test_result.push(a.length > 0);n }n if (a instanceof String) {n fastn.test_result.push(a.length > 0);n }n fastn.test_result.push(a !== undefined);n }}; - -fastn.assert.eq(1, 1); - - -nfastn.test_result - From 2a2cd8cd98528be3071ab2b47e8af14868da8bc6 Mon Sep 17 00:00:00 2001 From: siddhantCodes Date: Sat, 3 Feb 2024 22:55:20 +0530 Subject: [PATCH 6/7] add clippy and rustfmt in nix devenv --- fastn.nix | 2 +- flake.nix | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fastn.nix b/fastn.nix index 398b784783..75c0bb28aa 100644 --- a/fastn.nix +++ b/fastn.nix @@ -2,7 +2,7 @@ let fastnCargo = builtins.fromTOML (builtins.readFile ./fastn/Cargo.toml); version = fastnCargo.package.version; -in +in rustPlatform.buildRustPackage { name = "fastn"; inherit version; diff --git a/flake.nix b/flake.nix index d63e80a5a6..c6b5b8fc26 100644 --- a/flake.nix +++ b/flake.nix @@ -34,12 +34,14 @@ name = "fastn-shell"; nativeBuildInputs = with pkgs; [ rustc + rustfmt + clippy cargo pkg-config openssl.dev - rust-analyzer postgresql_14 diesel-cli + rust-analyzer ]; shellHook = '' From 3b382abb613beb7d4fe6fa4e1c41b41736153993 Mon Sep 17 00:00:00 2001 From: siddhantCodes Date: Sat, 3 Feb 2024 23:24:43 +0530 Subject: [PATCH 7/7] version bump to 0.4.54 and clippy fixes --- fastn/Cargo.toml | 2 +- ftd/src/executor/test.rs | 2 +- ftd/src/interpreter/test.rs | 2 +- ftd/src/node/test.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fastn/Cargo.toml b/fastn/Cargo.toml index 7d9d054066..24aa186f7b 100644 --- a/fastn/Cargo.toml +++ b/fastn/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fastn" -version = "0.4.53" +version = "0.4.54" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ftd/src/executor/test.rs b/ftd/src/executor/test.rs index 461bd33e40..026fd01da6 100644 --- a/ftd/src/executor/test.rs +++ b/ftd/src/executor/test.rs @@ -78,7 +78,7 @@ fn p(s: &str, t: &str, fix: bool, file_location: &std::path::PathBuf) { let mut executor = ftd::executor::ExecuteDoc::from_interpreter(doc).unwrap_or_else(|e| panic!("{:?}", e)); for thing in ftd::interpreter::default::get_default_bag().keys() { - executor.bag.remove(thing); + executor.bag.swap_remove(thing); } let expected_json = serde_json::to_string_pretty(&executor).unwrap(); if fix { diff --git a/ftd/src/interpreter/test.rs b/ftd/src/interpreter/test.rs index 85ba03bf35..7ee460746a 100644 --- a/ftd/src/interpreter/test.rs +++ b/ftd/src/interpreter/test.rs @@ -74,7 +74,7 @@ pub fn interpret_helper( fn p(s: &str, t: &str, fix: bool, file_location: &std::path::PathBuf) { let mut i = interpret_helper("foo", s).unwrap_or_else(|e| panic!("{:?}", e)); for thing in ftd::interpreter::default::get_default_bag().keys() { - i.data.remove(thing); + i.data.swap_remove(thing); } let expected_json = serde_json::to_string_pretty(&i).unwrap(); if fix { diff --git a/ftd/src/node/test.rs b/ftd/src/node/test.rs index 559327f8b5..6ea91f1f26 100644 --- a/ftd/src/node/test.rs +++ b/ftd/src/node/test.rs @@ -77,7 +77,7 @@ fn p(s: &str, t: &str, fix: bool, file_location: &std::path::PathBuf) { ftd::executor::ExecuteDoc::from_interpreter(doc).unwrap_or_else(|e| panic!("{:?}", e)); let mut node = ftd::node::NodeData::from_rt(executor); for thing in ftd::interpreter::default::get_default_bag().keys() { - node.bag.remove(thing); + node.bag.swap_remove(thing); } let expected_json = serde_json::to_string_pretty(&node).unwrap(); if fix {