From 606f39cb00766e5be46b38e3c3034e702c3795e6 Mon Sep 17 00:00:00 2001 From: Mateus Cruz Date: Tue, 6 Feb 2024 03:08:10 -0300 Subject: chore: rename app --- .github/workflows/build.yml | 27 +++++++++++++++++++++++++++ bin/dune | 4 ++-- bin/main.ml | 4 ++-- combattant.opam | 31 +++++++++++++++++++++++++++++++ docker-compose.yml | 4 ++-- dune-project | 4 ++-- flake.nix | 14 +++++++------- lib/dune | 2 +- rinha.opam | 31 ------------------------------- test/dune | 2 +- test/test_combattant.ml | 0 test/test_rinha.ml | 0 12 files changed, 75 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 combattant.opam delete mode 100644 rinha.opam create mode 100644 test/test_combattant.ml delete mode 100644 test/test_rinha.ml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..b983ab9 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,27 @@ +name: 'Build' +on: + pull_request: + branches: + - main + push: + branches: + - main + +jobs: + build: + permissions: write-all + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v20 + - uses: DeterminateSystems/magic-nix-cache-action@v2 + - run: nix build -L .#docker + - run: nix develop -L -c dune runtest + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - run: docker load < result + - run: docker push ghcr.io/molvrr/combattant:latest diff --git a/bin/dune b/bin/dune index 9c34236..3978ff9 100644 --- a/bin/dune +++ b/bin/dune @@ -1,10 +1,10 @@ (executable - (public_name rinha) + (public_name combattant) (name main) (flags (:standard -cclib -static -cclib -no-pie)) (libraries - rinha + combattant piaf routes eio_main diff --git a/bin/main.ml b/bin/main.ml index 03cc5ca..3839f6f 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -9,7 +9,7 @@ let setup_log ?style_renderer level = ;; let request_handler ~db_pool Server.{ request; _ } = - match Rinha.Router.match_route request.meth request.target with + match Combattant.Router.match_route request.meth request.target with | Some handler -> Result.get_ok @@ handler db_pool request | None -> Logs.info (fun d -> d "Não encontrei %S\n" request.target); @@ -29,7 +29,7 @@ let () = in let config = Server.Config.create config in let db_uri = - Uri.make ~scheme:"postgres" ~userinfo:"admin:123" ~host:"db" ~path:"rinha" () + Uri.make ~scheme:"postgres" ~userinfo:"admin:123" ~host:"db" ~path:"combattant" () in let db_pool = Result.get_ok diff --git a/combattant.opam b/combattant.opam new file mode 100644 index 0000000..3b957d2 --- /dev/null +++ b/combattant.opam @@ -0,0 +1,31 @@ +# This file is generated by dune, edit dune-project instead +opam-version: "2.0" +synopsis: "A short synopsis" +description: "A longer description" +maintainer: ["Maintainer Name"] +authors: ["Author Name"] +license: "LICENSE" +tags: ["topics" "to describe" "your" "project"] +homepage: "https://github.com/username/reponame" +doc: "https://url/to/documentation" +bug-reports: "https://github.com/username/reponame/issues" +depends: [ + "ocaml" + "dune" {>= "3.13"} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/username/reponame.git" diff --git a/docker-compose.yml b/docker-compose.yml index 3304f71..bcbd47f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.5' services: api01: &api - image: rinha:latest + image: ghcr.io/molvrr/combattant:latest environment: - DB_HOST=db depends_on: @@ -39,7 +39,7 @@ services: environment: - POSTGRES_PASSWORD=123 - POSTGRES_USER=admin - - POSTGRES_DB=rinha + - POSTGRES_DB=combattant ports: - "5432:5432" volumes: diff --git a/dune-project b/dune-project index 1170cb9..c6da9f6 100644 --- a/dune-project +++ b/dune-project @@ -1,6 +1,6 @@ (lang dune 3.13) -(name rinha) +(name combattant) (generate_opam_files true) @@ -16,7 +16,7 @@ (documentation https://url/to/documentation) (package - (name rinha) + (name combattant) (synopsis "A short synopsis") (description "A longer description") (depends ocaml dune) diff --git a/flake.nix b/flake.nix index 1c549c0..d0080d5 100644 --- a/flake.nix +++ b/flake.nix @@ -21,8 +21,8 @@ pkgs' = pkgs.pkgsCross.musl64; - rinha = pkgs'.ocamlPackages.buildDunePackage { - pname = "rinha"; + combattant = pkgs'.ocamlPackages.buildDunePackage { + pname = "combattant"; version = "0.0.1"; src = ./.; buildInputs = with pkgs'.ocamlPackages; [ @@ -50,21 +50,21 @@ pkgs.openjdk17 ]; - buildInputs = rinha.buildInputs + buildInputs = combattant.buildInputs ++ (with pkgs'.ocamlPackages; [ utop ]); }; - packages.default = rinha; + packages.default = combattant; packages.docker = pkgs.dockerTools.buildImage { - name = "rinha"; + name = "ghcr.io/molvrr/combattant"; tag = "latest"; copyToRoot = pkgs.buildEnv { name = "image-root"; - paths = [ pkgs.bashInteractive pkgs.coreutils pkgs.curl rinha ]; + paths = [ pkgs.bashInteractive pkgs.coreutils pkgs.curl combattant ]; pathsToLink = [ "/bin" ]; }; - config = { Cmd = [ "rinha" ]; }; + config = { Cmd = [ "combattant" ]; }; }; formatter = pkgs.nixfmt; diff --git a/lib/dune b/lib/dune index 6c8a064..b5507d7 100644 --- a/lib/dune +++ b/lib/dune @@ -1,5 +1,5 @@ (library - (name rinha) + (name combattant) (libraries piaf routes yojson caqti caqti-driver-postgresql caqti-eio ppx_rapper_eio) (preprocess (pps ppx_rapper))) diff --git a/rinha.opam b/rinha.opam deleted file mode 100644 index 3b957d2..0000000 --- a/rinha.opam +++ /dev/null @@ -1,31 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -synopsis: "A short synopsis" -description: "A longer description" -maintainer: ["Maintainer Name"] -authors: ["Author Name"] -license: "LICENSE" -tags: ["topics" "to describe" "your" "project"] -homepage: "https://github.com/username/reponame" -doc: "https://url/to/documentation" -bug-reports: "https://github.com/username/reponame/issues" -depends: [ - "ocaml" - "dune" {>= "3.13"} - "odoc" {with-doc} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] -dev-repo: "git+https://github.com/username/reponame.git" diff --git a/test/dune b/test/dune index df3754d..6caed9b 100644 --- a/test/dune +++ b/test/dune @@ -1,2 +1,2 @@ (test - (name test_rinha)) + (name test_combattant)) diff --git a/test/test_combattant.ml b/test/test_combattant.ml new file mode 100644 index 0000000..e69de29 diff --git a/test/test_rinha.ml b/test/test_rinha.ml deleted file mode 100644 index e69de29..0000000 -- cgit v1.2.3