Skip to content

Commit

Permalink
ci: dagger support
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sagi-Kazar <[email protected]>
  • Loading branch information
sagikazarmark committed May 28, 2022
1 parent 7d0c4c2 commit 5d86c6b
Show file tree
Hide file tree
Showing 11 changed files with 268 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions .github/workflows/dagger.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.direnv/
/tmp/
/vendor/

Expand Down
14 changes: 14 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3'

tasks:
check:
cmds:
- dagger do check

lint:
cmds:
- dagger do check lint

fmt:
cmds:
- golangci-lint run --fix
3 changes: 3 additions & 0 deletions cue.mod/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/gen/
/pkg/
/tmp/
1 change: 1 addition & 0 deletions cue.mod/dagger.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github.com/sagikazarmark/dagger main
1 change: 1 addition & 0 deletions cue.mod/dagger.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github.com/sagikazarmark/dagger h1:tiyrgWTRtUgipmeZEaoN3y/ejlHHYI7pVSVTxmm/NWQ=
1 change: 1 addition & 0 deletions cue.mod/module.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module: "emperror.dev/errors"
56 changes: 56 additions & 0 deletions dagger.cue
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
}
84 changes: 84 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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; }; }
);
}

0 comments on commit 5d86c6b

Please sign in to comment.