diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1bbfeef --- /dev/null +++ b/.envrc @@ -0,0 +1,4 @@ +if ! has nix_direnv_version || ! nix_direnv_version 2.1.0; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.1.0/direnvrc" "sha256-FAT2R9yYvVg516v3LiogjIc8YfsbWbMM/itqWsm5xTA=" +fi +use flake diff --git a/.github/workflows/dagger.yaml b/.github/workflows/dagger.yaml new file mode 100644 index 0000000..d8bd946 --- /dev/null +++ b/.github/workflows/dagger.yaml @@ -0,0 +1,41 @@ +name: Dagger + +on: + push: + branches: + - master + pull_request: + +jobs: + test: + name: Test + runs-on: ubuntu-latest + strategy: + matrix: + go: ['1.14', '1.15', '1.16', '1.17', '1.18'] + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Dagger + uses: dagger/dagger-for-github@v3 + with: + cmds: | + project update + do check test go ${{ matrix.go }} + + lint: + name: Lint + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Dagger + uses: dagger/dagger-for-github@v3 + with: + cmds: | + project update + do check lint diff --git a/.gitignore b/.gitignore index 373715a..39d3e11 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.direnv/ /tmp/ /vendor/ diff --git a/Taskfile.yaml b/Taskfile.yaml new file mode 100644 index 0000000..7ba6546 --- /dev/null +++ b/Taskfile.yaml @@ -0,0 +1,14 @@ +version: '3' + +tasks: + check: + cmds: + - dagger do check + + lint: + cmds: + - dagger do check lint + + fmt: + cmds: + - golangci-lint run --fix diff --git a/cue.mod/.gitignore b/cue.mod/.gitignore new file mode 100644 index 0000000..089b067 --- /dev/null +++ b/cue.mod/.gitignore @@ -0,0 +1,3 @@ +/gen/ +/pkg/ +/tmp/ diff --git a/cue.mod/dagger.mod b/cue.mod/dagger.mod new file mode 100644 index 0000000..5f38a63 --- /dev/null +++ b/cue.mod/dagger.mod @@ -0,0 +1 @@ +github.com/sagikazarmark/dagger main diff --git a/cue.mod/dagger.sum b/cue.mod/dagger.sum new file mode 100644 index 0000000..4b81d6b --- /dev/null +++ b/cue.mod/dagger.sum @@ -0,0 +1 @@ +github.com/sagikazarmark/dagger h1:tiyrgWTRtUgipmeZEaoN3y/ejlHHYI7pVSVTxmm/NWQ= diff --git a/cue.mod/module.cue b/cue.mod/module.cue new file mode 100644 index 0000000..859c833 --- /dev/null +++ b/cue.mod/module.cue @@ -0,0 +1 @@ +module: "emperror.dev/errors" \ No newline at end of file diff --git a/dagger.cue b/dagger.cue new file mode 100644 index 0000000..36989a1 --- /dev/null +++ b/dagger.cue @@ -0,0 +1,56 @@ +package main + +import ( + "dagger.io/dagger" + + "universe.dagger.io/go" + + "github.com/sagikazarmark/dagger/go/golangci" +) + +dagger.#Plan & { + client: filesystem: ".": read: exclude: [ + ".github", + "bin", + "build", + "tmp", + ] + // client: filesystem: "./build": write: contents: actions.build.debug.output + client: network: "unix:///var/run/docker.sock": connect: dagger.#Socket + + actions: { + _source: client.filesystem["."].read.contents + + check: { + test: { + "go": { + "1.14": _ + "1.15": _ + "1.16": _ + "1.17": _ + "1.18": _ + + [v=string]: go.#Test & { + source: _source + name: "go_test_\(v)" + package: "./..." + + _image: go.#Image & { + version: v + } + + input: _image.output + command: flags: "-race": true + } + } + } + + lint: { + "golangci": golangci.#Lint & { + source: _source + version: "1.46" + } + } + } + } +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0f19413 --- /dev/null +++ b/flake.lock @@ -0,0 +1,84 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1652776076, + "narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gobin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1652111277, + "narHash": "sha256-jxl+fhzykhPP708r+WMotsg8Bjti9fpRoh4KiwPJ7XM=", + "owner": "sagikazarmark", + "repo": "go-bin-flake", + "rev": "7520b0da6c41e9d698ff5b408688de426c0218ea", + "type": "github" + }, + "original": { + "owner": "sagikazarmark", + "repo": "go-bin-flake", + "type": "github" + } + }, + "goflake": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1653238580, + "narHash": "sha256-oY/LS2l70cLC58TQ+ByuJDSa6kYg+ka46bKqJItwSpA=", + "owner": "sagikazarmark", + "repo": "go-flake", + "rev": "1d00595d82d74ca0f3ba0cf8bd52bb42f3801b1d", + "type": "github" + }, + "original": { + "owner": "sagikazarmark", + "repo": "go-flake", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1653407748, + "narHash": "sha256-g9puJaILRTb9ttlLQ7IehpV7Wcy0n+vs8LOFu6ylQcM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5ce6597eca7d7b518c03ecda57d45f9404b5e060", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "gobin": "gobin", + "goflake": "goflake", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..63b872f --- /dev/null +++ b/flake.nix @@ -0,0 +1,62 @@ +{ + description = "Drop-in replacement for the standard library errors package"; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + goflake.url = "github:sagikazarmark/go-flake"; + goflake.inputs.nixpkgs.follows = "nixpkgs"; + gobin.url = "github:sagikazarmark/go-bin-flake"; + gobin.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, flake-utils, goflake, gobin, ... }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { + inherit system; + + overlays = [ + goflake.overlay + + ( + final: prev: { + golangci-lint = gobin.packages.${system}.golangci-lint-bin; + dagger = prev.buildGo118Module rec { + pname = "dagger"; + version = "0.2.12"; + + src = prev.fetchFromGitHub { + owner = "dagger"; + repo = "dagger"; + rev = "v${version}"; + sha256 = "sha256-t58+dfsf6A38RG4uT8SJPi07gkC9dGZo0WpVwN9N31k="; + }; + + vendorSha256 = "sha256-7YKuOApIw4SG39BLb4kh7ZuZjhCBduzKo3iS8v8KZZU="; + + proxyModule = true; + + subPackages = [ + "cmd/dagger" + ]; + + ldflags = [ "-s" "-w" "-X go.dagger.io/dagger/version.Revision=${version}" ]; + }; + } + ) + ]; + }; + + buildDeps = with pkgs; [ git go_1_17 gnumake ]; + devDeps = with pkgs; buildDeps ++ [ + golangci-lint + gotestsum + dagger + go-task + ]; + in + { devShell = pkgs.mkShell { buildInputs = devDeps; }; } + ); +}