Skip to content

Commit c67c85c

Browse files
committed
ci: dagger support
Signed-off-by: Mark Sagi-Kazar <[email protected]>
1 parent 7d0c4c2 commit c67c85c

File tree

11 files changed

+267
-0
lines changed

11 files changed

+267
-0
lines changed

.envrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
if ! has nix_direnv_version || ! nix_direnv_version 2.1.0; then
2+
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.1.0/direnvrc" "sha256-FAT2R9yYvVg516v3LiogjIc8YfsbWbMM/itqWsm5xTA="
3+
fi
4+
use flake

.github/workflows/dagger.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Dagger
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
go: ['1.14', '1.15', '1.16', '1.17', '1.18']
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
21+
- name: Dagger
22+
uses: dagger/dagger-for-github@v3
23+
with:
24+
cmds: |
25+
project update
26+
do check test go ${{ matrix.go }}
27+
28+
lint:
29+
name: Lint
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v3
35+
36+
- name: Dagger
37+
uses: dagger/dagger-for-github@v3
38+
with:
39+
cmds: |
40+
do check lint

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.direnv/
12
/tmp/
23
/vendor/
34

Taskfile.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: '3'
2+
3+
tasks:
4+
check:
5+
cmds:
6+
- dagger do check
7+
8+
lint:
9+
cmds:
10+
- dagger do check lint
11+
12+
fmt:
13+
cmds:
14+
- golangci-lint run --fix

cue.mod/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/gen/
2+
/pkg/
3+
/tmp/

cue.mod/dagger.mod

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github.com/sagikazarmark/dagger main

cue.mod/dagger.sum

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github.com/sagikazarmark/dagger h1:Ic3l+siv5qrEkFi0MOUHpP6Hk1asrhII4kNFfyYjODQ=

cue.mod/module.cue

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module: "emperror.dev/errors"

dagger.cue

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package main
2+
3+
import (
4+
"dagger.io/dagger"
5+
6+
"universe.dagger.io/go"
7+
8+
"github.com/sagikazarmark/dagger/go/golangci"
9+
)
10+
11+
dagger.#Plan & {
12+
client: filesystem: ".": read: exclude: [
13+
".github",
14+
"bin",
15+
"build",
16+
"tmp",
17+
]
18+
// client: filesystem: "./build": write: contents: actions.build.debug.output
19+
client: network: "unix:///var/run/docker.sock": connect: dagger.#Socket
20+
21+
actions: {
22+
_source: client.filesystem["."].read.contents
23+
24+
check: {
25+
test: {
26+
"go": {
27+
"1.14": _
28+
"1.15": _
29+
"1.16": _
30+
"1.17": _
31+
"1.18": _
32+
33+
[v=string]: go.#Test & {
34+
source: _source
35+
name: "go_test_\(v)"
36+
package: "./..."
37+
38+
_image: go.#Image & {
39+
version: v
40+
}
41+
42+
input: _image.output
43+
command: flags: "-race": true
44+
}
45+
}
46+
}
47+
48+
lint: {
49+
"golangci": golangci.#Lint & {
50+
source: _source
51+
version: "1.46"
52+
}
53+
}
54+
}
55+
}
56+
}

flake.lock

+84
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
description = "Drop-in replacement for the standard library errors package";
3+
4+
inputs = {
5+
nixpkgs.url = "nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
goflake.url = "github:sagikazarmark/go-flake";
8+
goflake.inputs.nixpkgs.follows = "nixpkgs";
9+
gobin.url = "github:sagikazarmark/go-bin-flake";
10+
gobin.inputs.nixpkgs.follows = "nixpkgs";
11+
};
12+
13+
outputs = { self, nixpkgs, flake-utils, goflake, gobin, ... }:
14+
flake-utils.lib.eachDefaultSystem (
15+
system:
16+
let
17+
pkgs = import nixpkgs {
18+
inherit system;
19+
20+
overlays = [
21+
goflake.overlay
22+
23+
(
24+
final: prev: {
25+
golangci-lint = gobin.packages.${system}.golangci-lint-bin;
26+
dagger = prev.buildGo118Module rec {
27+
pname = "dagger";
28+
version = "0.2.12";
29+
30+
src = prev.fetchFromGitHub {
31+
owner = "dagger";
32+
repo = "dagger";
33+
rev = "v${version}";
34+
sha256 = "sha256-t58+dfsf6A38RG4uT8SJPi07gkC9dGZo0WpVwN9N31k=";
35+
};
36+
37+
vendorSha256 = "sha256-7YKuOApIw4SG39BLb4kh7ZuZjhCBduzKo3iS8v8KZZU=";
38+
39+
proxyModule = true;
40+
41+
subPackages = [
42+
"cmd/dagger"
43+
];
44+
45+
ldflags = [ "-s" "-w" "-X go.dagger.io/dagger/version.Revision=${version}" ];
46+
};
47+
}
48+
)
49+
];
50+
};
51+
52+
buildDeps = with pkgs; [ git go_1_17 gnumake ];
53+
devDeps = with pkgs; buildDeps ++ [
54+
golangci-lint
55+
gotestsum
56+
dagger
57+
go-task
58+
];
59+
in
60+
{ devShell = pkgs.mkShell { buildInputs = devDeps; }; }
61+
);
62+
}

0 commit comments

Comments
 (0)