From 33b9a0b4ec41c541aa2ebb088d7138658cf68ea5 Mon Sep 17 00:00:00 2001 From: Adriano Caloiaro Date: Sat, 20 Jan 2024 13:09:11 -0700 Subject: [PATCH 1/4] Improve dev environment --- .envrc | 11 ++ .gitignore | 7 +- README.md | 36 +++++- bin/gomod2nix | 3 + flake.lock | 308 +++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 79 +++++++++++++ go.mod | 2 +- gomod2nix.toml | 99 ++++++++++++++++ 8 files changed, 539 insertions(+), 6 deletions(-) create mode 100644 .envrc create mode 100755 bin/gomod2nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 gomod2nix.toml diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..7a861ca --- /dev/null +++ b/.envrc @@ -0,0 +1,11 @@ +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=" +fi + +watch_file flake.nix +watch_file flake.lock +if ! use flake . --impure +then + echo "devenv could not be built. The devenv environment was not loaded." >&2 +fi + diff --git a/.gitignore b/.gitignore index 87e57dc..ca1c26e 100644 --- a/.gitignore +++ b/.gitignore @@ -21,8 +21,7 @@ vendor/ # it's handy to have a docker-compose available during development docker-compose.yml -.pre-commit-config.yaml - dist/ - - +.devenv/ +.direnv/ +.pre-commit-config.yaml diff --git a/README.md b/README.md index 0e205c9..32a3ae9 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,40 @@ nq.Enqueue(ctx, &jobs.Job{ Additional example integration code can be found at https://github.com/acaloiaro/neoq/tree/main/examples +# Developing + +Neoq development is largely based on Nix and `devenv`. + +After [installing nix](https://nixos.org/download), this repository contains everything else you will need to develop +and run tests. + +## Automatic setup and teardown + +`direnv` is used to let neoq automatically configure its own dev environment. This includes installing dependencies and +developer tooling. + +See [installing direnv](https://direnv.net/docs/installation.html) if you want the dev environment setup to be automated. + +## Manual setup and teardown + +Neoq uses `devenv` to manage development environments and services. + +To enter the development shell, run `nix develop --impure`. + +In order to run the test suite, the required services need to be started. Start services by running the following: + +## Running services for tests + +The neoq development shell gives you the `devenv` executable. + +To run postgres and redis for tests and development, run + +``` +devenv up +``` + +This runs Postgres and Redis in the foreground. In a separate terminal, run `make test` to run the test suite. + # Status -This project is currently in alpha. Future releases may change the API. +This project is currently pre-1.0. Future releases may change the API. diff --git a/bin/gomod2nix b/bin/gomod2nix new file mode 100755 index 0000000..fa4275f --- /dev/null +++ b/bin/gomod2nix @@ -0,0 +1,3 @@ +#!env bash + +gomod2nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e38c9e6 --- /dev/null +++ b/flake.lock @@ -0,0 +1,308 @@ +{ + "nodes": { + "devenv": { + "inputs": { + "flake-compat": "flake-compat", + "nix": "nix", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1688058187, + "narHash": "sha256-ipDcc7qrucpJ0+0eYNlwnE+ISTcq4m03qW+CWUshRXI=", + "owner": "cachix", + "repo": "devenv", + "rev": "c8778e3dc30eb9043e218aaa3861d42d4992de77", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "v0.6.3", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "devenv", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "gomod2nix": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1705314449, + "narHash": "sha256-yfQQ67dLejP0FLK76LKHbkzcQqNIrux6MFe32MMFGNQ=", + "owner": "nix-community", + "repo": "gomod2nix", + "rev": "30e3c3a9ec4ac8453282ca7f67fca9e1da12c3e6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "gomod2nix", + "type": "github" + } + }, + "lowdown-src": { + "flake": false, + "locked": { + "lastModified": 1633514407, + "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", + "owner": "kristapsdz", + "repo": "lowdown", + "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", + "type": "github" + }, + "original": { + "owner": "kristapsdz", + "repo": "lowdown", + "type": "github" + } + }, + "nix": { + "inputs": { + "lowdown-src": "lowdown-src", + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "nixpkgs-regression": "nixpkgs-regression" + }, + "locked": { + "lastModified": 1676545802, + "narHash": "sha256-EK4rZ+Hd5hsvXnzSzk2ikhStJnD63odF7SzsQ8CuSPU=", + "owner": "domenkozar", + "repo": "nix", + "rev": "7c91803598ffbcfe4a55c44ac6d49b2cf07a527f", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "relaxed-flakes", + "repo": "nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1678875422, + "narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1685801374, + "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1705697961, + "narHash": "sha256-XepT3WS516evSFYkme3GrcI3+7uwXHqtHbip+t24J7E=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e5d1c87f5813afde2dda384ac807c57a105721cc", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": [ + "devenv", + "flake-compat" + ], + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1704725188, + "narHash": "sha256-qq8NbkhRZF1vVYQFt1s8Mbgo8knj+83+QlL5LBnYGpI=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "ea96f0c05924341c551a797aaba8126334c505d2", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "gomod2nix": "gomod2nix", + "nixpkgs": "nixpkgs_2", + "systems": "systems_3" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "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" + } + }, + "systems_3": { + "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..039cd3c --- /dev/null +++ b/flake.nix @@ -0,0 +1,79 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + systems.url = "github:nix-systems/default"; + devenv.url = "github:cachix/devenv/v0.6.3"; + + gomod2nix = { + url = "github:nix-community/gomod2nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { + self, + nixpkgs, + devenv, + systems, + gomod2nix, + ... + } @ inputs: let + forEachSystem = nixpkgs.lib.genAttrs (import systems); + in { + devShells = forEachSystem (system: let + pkgs = nixpkgs.legacyPackages.${system}; + postgresPort = 5433; + redisPort = 6380; + in { + default = devenv.lib.mkShell { + inherit inputs pkgs; + modules = [ + { + packages = with pkgs; [ + automake + go_1_21 + gomod2nix.legacyPackages.${system}.gomod2nix + gotools + go-tools + gopls + pre-commit + ]; + + enterShell = '' + export TEST_DATABASE_URL="postgres://postgres:postgres@localhost:${toString postgresPort}/neoq?sslmode=disable&pool_max_conns=100" + export TEST_REDIS_URL=localhost:${toString redisPort} + export REDIS_PASSWORD= + ''; + + pre-commit.hooks.gomod2nix = { + enable = true; + always_run = true; + name = "gomod2nix"; + description = "Run gomod2nix before commit"; + entry = "./bin/gomod2nix"; + }; + + services = { + postgres = { + package = pkgs.postgresql; + enable = true; + listen_addresses = "127.0.0.1"; + port = postgresPort; + initialScript = '' + CREATE USER postgres WITH PASSWORD 'postgres' SUPERUSER; + CREATE DATABASE neoq; + ''; + }; + + redis = { + package = pkgs.redis; + enable = true; + port = redisPort; + }; + }; + } + ]; + }; + }); + }; +} diff --git a/go.mod b/go.mod index f049094..7c1af7e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/acaloiaro/neoq -go 1.20 +go 1.21 require ( github.com/golang-migrate/migrate/v4 v4.16.2 diff --git a/gomod2nix.toml b/gomod2nix.toml new file mode 100644 index 0000000..f9311e8 --- /dev/null +++ b/gomod2nix.toml @@ -0,0 +1,99 @@ +schema = 3 + +[mod] + [mod."github.com/cespare/xxhash/v2"] + version = "v2.1.2" + hash = "sha256-YV9SmXDtmmgQylQUfrUgQLAPfqYexcHxegMBT+IX9qM=" + [mod."github.com/dgryski/go-rendezvous"] + version = "v0.0.0-20200823014737-9f7001d12a5f" + hash = "sha256-n/7xo5CQqo4yLaWMSzSN1Muk/oqK6O5dgDOFWapeDUI=" + [mod."github.com/go-redis/redis/v8"] + version = "v8.11.2" + hash = "sha256-3ltdzFcxgUtm6YlNX9C3vHOU/WzPiu687JXWmY4+h/w=" + [mod."github.com/golang-migrate/migrate/v4"] + version = "v4.16.2" + hash = "sha256-eG40Sgp1c2hrGMR7YfOKjv2Qktv/VtGrUOVkDC0cTcg=" + [mod."github.com/golang/protobuf"] + version = "v1.5.2" + hash = "sha256-IVwooaIo46iq7euSSVWTBAdKd+2DUaJ67MtBao1DpBI=" + [mod."github.com/google/uuid"] + version = "v1.3.0" + hash = "sha256-QoR55eBtA94T2tBszyxfDtO7/pjZZSGb5vm7U0Xhs0Y=" + [mod."github.com/guregu/null"] + version = "v4.0.0+incompatible" + hash = "sha256-VhFHFjDVv5mnyLGefthH2ViaPsPab4NOSSW7XqzBpfI=" + [mod."github.com/hashicorp/errwrap"] + version = "v1.1.0" + hash = "sha256-6lwuMQOfBq+McrViN3maJTIeh4f8jbEqvLy2c9FvvFw=" + [mod."github.com/hashicorp/go-multierror"] + version = "v1.1.1" + hash = "sha256-ANzPEUJIZIlToxR89Mn7Db73d9LGI51ssy7eNnUgmlA=" + [mod."github.com/hibiken/asynq"] + version = "v0.24.0" + hash = "sha256-7azyUwYCTrm//+Ar6wdK2E84UNTtc8E2RGDKDwCyMys=" + [mod."github.com/iancoleman/strcase"] + version = "v0.2.0" + hash = "sha256-sjzaiANgbiiT9+xh09AwcQGQMGYNrMGiPzDl8L+x7mU=" + [mod."github.com/jackc/pgerrcode"] + version = "v0.0.0-20220416144525-469b46aa5efa" + hash = "sha256-IaqDv1c+uj6U6cz/Y9cBOPPGOwEcPH2BjVJlYj/6AH4=" + [mod."github.com/jackc/pgpassfile"] + version = "v1.0.0" + hash = "sha256-H0nFbC34/3pZUFnuiQk9W7yvAMh6qJDrqvHp+akBPLM=" + [mod."github.com/jackc/pgservicefile"] + version = "v0.0.0-20221227161230-091c0ba34f0a" + hash = "sha256-rBtUw15WPPDp2eulHXH5e2zCIed1OPFYwlCpgDOnGRM=" + [mod."github.com/jackc/pgx/v5"] + version = "v5.3.1" + hash = "sha256-0v6gXZIirv80mlnUx3ycxB2/TLvv3rUnm98Ke1ZjYDQ=" + [mod."github.com/jackc/puddle/v2"] + version = "v2.2.0" + hash = "sha256-S9Ldac+a4auQt99hToXZ/WSuUhcEk/A5aDgQAb48B8M=" + [mod."github.com/jsuar/go-cron-descriptor"] + version = "v0.1.0" + hash = "sha256-zbADYCEzVcOlvemQa+Ly+6mRcCu3qsFxyeTd9jzZj38=" + [mod."github.com/lib/pq"] + version = "v1.10.2" + hash = "sha256-q5noElHYrGEm7etqs0eGFpm0Zd2rnakYCp9lC/ciiVo=" + [mod."github.com/pkg/errors"] + version = "v0.9.1" + hash = "sha256-mNfQtcrQmu3sNg/7IwiieKWOgFQOVVe2yXgKBpe/wZw=" + [mod."github.com/robfig/cron"] + version = "v1.2.0" + hash = "sha256-au+MD6DEjpVRAjXWmmJbZRB5IdFfcIqGm6kBkkYNY1s=" + [mod."github.com/robfig/cron/v3"] + version = "v3.0.1" + hash = "sha256-FUdqNbWYi5biQc/tjCeqzxu4iy4ot1ZvDU1M1wRf/6k=" + [mod."github.com/spf13/cast"] + version = "v1.3.1" + hash = "sha256-wT6IRl4ZFvzeyLlv7l/GJt39shnRRYHzxyDTh9AhaFE=" + [mod."go.uber.org/atomic"] + version = "v1.10.0" + hash = "sha256-E6UEDc1eh/cLUFd+J86cDesQ0B8wEv/DdaAVKb+x2t8=" + [mod."go.uber.org/multierr"] + version = "v1.9.0" + hash = "sha256-tlDRooh/V4HDhZohsUrxot/Y6uVInVBtRWCZbj/tPds=" + [mod."go.uber.org/zap"] + version = "v1.24.0" + hash = "sha256-yLzjFbMWnc5b033gcPLGP0KY1xWPJ3sjnUG/RndmC3o=" + [mod."golang.org/x/crypto"] + version = "v0.17.0" + hash = "sha256-/vzBaeD/Ymyc7cpjBvSfJfuZ57zWa9LOaZM7b33eIx0=" + [mod."golang.org/x/exp"] + version = "v0.0.0-20230713183714-613f0c0eb8a1" + hash = "sha256-VLE9CCOYpTdyBWaQ1YxXpGOBS74wpIR3JJ+JVzNyEkQ=" + [mod."golang.org/x/sync"] + version = "v0.2.0" + hash = "sha256-hKk9zsy2aXY7R0qGFZhGOVvk5qD17f6KHEuK4rGpTsg=" + [mod."golang.org/x/sys"] + version = "v0.15.0" + hash = "sha256-n7TlABF6179RzGq3gctPDKDPRtDfnwPdjNCMm8ps2KY=" + [mod."golang.org/x/text"] + version = "v0.14.0" + hash = "sha256-yh3B0tom1RfzQBf1RNmfdNWF1PtiqxV41jW1GVS6JAg=" + [mod."golang.org/x/time"] + version = "v0.0.0-20190308202827-9d24e82272b4" + hash = "sha256-azbksMSLQf1CK0jF2i+ESjFenMDR88xRW1tov0metrg=" + [mod."google.golang.org/protobuf"] + version = "v1.28.1" + hash = "sha256-sTJYgvlv5is7vHNxcuigF2lNASp0QonhUgnrguhfHSU=" From adf11193a0903f89cc9a38404b66df02d214083d Mon Sep 17 00:00:00 2001 From: Adriano Caloiaro Date: Fri, 26 Jan 2024 08:51:20 -0700 Subject: [PATCH 2/4] Fix lints --- .golangci.yaml | 10 ---------- backends/memory/memory_backend.go | 4 ++-- backends/postgres/postgres_backend.go | 1 + backends/postgres/postgres_backend_test.go | 2 -- backends/redis/redis_backend.go | 2 +- flake.nix | 1 + 6 files changed, 5 insertions(+), 15 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 871b62c..864969c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -50,14 +50,6 @@ output: #It's a .golangci.yml config file of this repo: we enable more linters than the default and have more strict settings: linters-settings: - depguard: - list-type: blacklist - packages: - # logging is allowed only by logutils.Log, logrus - # is allowed to use only in logutils package - - github.com/sirupsen/logrus - packages-with-error-message: - - github.com/sirupsen/logrus: "logging is allowed only by logutils.Log" dupl: threshold: 100 funlen: @@ -115,7 +107,6 @@ linters: - contextcheck - cyclop - decorder - - depguard - dogsled - dupl - dupword @@ -155,7 +146,6 @@ linters: - maintidx - makezero - misspell - - nakedret - nestif - nilerr - nilnil diff --git a/backends/memory/memory_backend.go b/backends/memory/memory_backend.go index b0ec080..0528cb1 100644 --- a/backends/memory/memory_backend.go +++ b/backends/memory/memory_backend.go @@ -67,7 +67,7 @@ func Backend(_ context.Context, opts ...neoq.ConfigOption) (backend neoq.Neoq, e } // Enqueue queues jobs to be executed asynchronously -func (m *MemBackend) Enqueue(ctx context.Context, job *jobs.Job) (jobID string, err error) { +func (m *MemBackend) Enqueue(_ context.Context, job *jobs.Job) (jobID string, err error) { var queueChan chan *jobs.Job var qc any var ok bool @@ -194,7 +194,7 @@ func (m *MemBackend) SetLogger(logger logging.Logger) { } // Shutdown halts the worker -func (m *MemBackend) Shutdown(ctx context.Context) { +func (m *MemBackend) Shutdown(_ context.Context) { for _, f := range m.cancelFuncs { f() } diff --git a/backends/postgres/postgres_backend.go b/backends/postgres/postgres_backend.go index ee97491..3d98dbb 100644 --- a/backends/postgres/postgres_backend.go +++ b/backends/postgres/postgres_backend.go @@ -403,6 +403,7 @@ func (p *PgBackend) Enqueue(ctx context.Context, job *jobs.Job) (jobID string, e } p.logger.Error("error enqueueing job", slog.String("queue", job.Queue), slog.Any("error", err)) err = fmt.Errorf("error enqueuing job: %w", err) + return } err = tx.Commit(ctx) diff --git a/backends/postgres/postgres_backend_test.go b/backends/postgres/postgres_backend_test.go index c41aef4..bfb7271 100644 --- a/backends/postgres/postgres_backend_test.go +++ b/backends/postgres/postgres_backend_test.go @@ -406,8 +406,6 @@ func TestMultipleCronNodes(t *testing.T) { _, exists := jobsProcessed.LoadOrStore(job.ID, "foo") if exists { t.Fatalf("job (%d) has already been processed by another worker!", job.ID) - atomic.AddUint32(&duplicateJobs, 1) - return nil } atomic.AddUint32(&jobsCompleted, 1) return diff --git a/backends/redis/redis_backend.go b/backends/redis/redis_backend.go index 6d20f91..5810b4a 100644 --- a/backends/redis/redis_backend.go +++ b/backends/redis/redis_backend.go @@ -342,7 +342,7 @@ func (b *RedisBackend) SetLogger(logger logging.Logger) { } // Shutdown halts the worker -func (b *RedisBackend) Shutdown(ctx context.Context) { +func (b *RedisBackend) Shutdown(_ context.Context) { b.client.Close() b.server.Shutdown() } diff --git a/flake.nix b/flake.nix index 039cd3c..cd68305 100644 --- a/flake.nix +++ b/flake.nix @@ -34,6 +34,7 @@ go_1_21 gomod2nix.legacyPackages.${system}.gomod2nix gotools + golangci-lint go-tools gopls pre-commit From b0bea93247cc442ec192fc679a8b57145965545d Mon Sep 17 00:00:00 2001 From: Adriano Caloiaro Date: Fri, 26 Jan 2024 08:53:46 -0700 Subject: [PATCH 3/4] Bump go version for ci --- .github/workflows/golangci-lint.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 1e5928c..b50f04e 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: '1.20' + go-version: '1.21' - uses: actions/checkout@v3 - name: go mod run: make mod diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 112172d..b54ac78 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,7 @@ jobs: --health-timeout 5s --health-retries 5 - container: golang:1.20 + container: golang:1.21 steps: - uses: actions/checkout@v3 From fa652ce0d8b2a84a4465831ecbb02c71848401e7 Mon Sep 17 00:00:00 2001 From: Adriano Caloiaro Date: Fri, 26 Jan 2024 09:00:01 -0700 Subject: [PATCH 4/4] README updates --- README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 32a3ae9..1edb714 100644 --- a/README.md +++ b/README.md @@ -132,18 +132,17 @@ and run tests. ## Automatic setup and teardown -`direnv` is used to let neoq automatically configure its own dev environment. This includes installing dependencies and -developer tooling. - See [installing direnv](https://direnv.net/docs/installation.html) if you want the dev environment setup to be automated. +`direnv allow` allows `direnv` to automatically setup all tooling and dependencies in a development shell upon entering +the neoq directory. + ## Manual setup and teardown Neoq uses `devenv` to manage development environments and services. -To enter the development shell, run `nix develop --impure`. - -In order to run the test suite, the required services need to be started. Start services by running the following: +To enter the development shell, run `nix develop --impure`. If `devenv` is installed, this step is not necessary; simply +enter the neoq directory after having run `direnv allow`. ## Running services for tests @@ -157,6 +156,12 @@ devenv up This runs Postgres and Redis in the foreground. In a separate terminal, run `make test` to run the test suite. +## Running tests + +Before submitting pull requests, always run tests locally with after having run `devenv up`. + +Run `make test` to run the test suite. + # Status This project is currently pre-1.0. Future releases may change the API.