From 5d86c6bc8c77687e4874322bb7a5ecb4827b32c8 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Fri, 27 May 2022 23:47:25 +0200 Subject: [PATCH 1/8] ci: dagger support Signed-off-by: Mark Sagi-Kazar --- .envrc | 4 ++ .github/workflows/dagger.yaml | 41 +++++++++++++++++ .gitignore | 1 + Taskfile.yaml | 14 ++++++ cue.mod/.gitignore | 3 ++ cue.mod/dagger.mod | 1 + cue.mod/dagger.sum | 1 + cue.mod/module.cue | 1 + dagger.cue | 56 +++++++++++++++++++++++ flake.lock | 84 +++++++++++++++++++++++++++++++++++ flake.nix | 62 ++++++++++++++++++++++++++ 11 files changed, 268 insertions(+) create mode 100644 .envrc create mode 100644 .github/workflows/dagger.yaml create mode 100644 Taskfile.yaml create mode 100644 cue.mod/.gitignore create mode 100644 cue.mod/dagger.mod create mode 100644 cue.mod/dagger.sum create mode 100644 cue.mod/module.cue create mode 100644 dagger.cue create mode 100644 flake.lock create mode 100644 flake.nix 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; }; } + ); +} From d744dec670c27a7ffb980f24280df05eb9ee330f Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Sun, 19 Jun 2022 15:05:51 +0200 Subject: [PATCH 2/8] ci: dagger codecov Signed-off-by: Mark Sagi-Kazar --- BUILD => BUILD.plz | 0 ci/codecov/image.cue | 74 +++++++++++++++++++++++++++++++++++++++ ci/codecov/test/image.cue | 11 ++++++ ci/codecov/upload.cue | 44 +++++++++++++++++++++++ dagger.cue | 69 +++++++++++++++++++++++++++++++----- flake.lock | 18 +++++----- flake.nix | 67 ++++++++++++----------------------- 7 files changed, 221 insertions(+), 62 deletions(-) rename BUILD => BUILD.plz (100%) create mode 100644 ci/codecov/image.cue create mode 100644 ci/codecov/test/image.cue create mode 100644 ci/codecov/upload.cue diff --git a/BUILD b/BUILD.plz similarity index 100% rename from BUILD rename to BUILD.plz diff --git a/ci/codecov/image.cue b/ci/codecov/image.cue new file mode 100644 index 0000000..3fe6c81 --- /dev/null +++ b/ci/codecov/image.cue @@ -0,0 +1,74 @@ +package codecov + +import ( + "universe.dagger.io/docker" + // "universe.dagger.io/alpine" + "universe.dagger.io/bash" +) + +// Build a codecov base image +#Image: { + _packages: [pkgName=string]: { + // NOTE(samalba, gh issue #1532): + // it's not recommended to pin the version as it is already pinned by the major Alpine version + // version pinning is for future use (as soon as we support custom repositories like `community`, + // `testing` or `edge`) + version: string | *"" + } + _packages: { + bash: _ + curl: _ + git: _ + gnupg: _ + coreutils: _ + "perl-utils": _ + } + docker.#Build & { + steps: [ + // alpine.#Build & { + // packages: { + // bash: _ + // curl: _ + // gnupg: _ + // coreutils: _ + // "perl-utils": _ + // } + // }, + docker.#Pull & { + source: "index.docker.io/alpine:3.15.0@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300" + }, + for pkgName, pkg in _packages { + docker.#Run & { + command: { + name: "apk" + args: ["add", "\(pkgName)\(pkg.version)"] + flags: { + "-U": true + "--no-cache": true + } + } + } + }, + bash.#Run & { + script: contents: """ + curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import + + curl -Os https://uploader.codecov.io/latest/alpine/codecov + + curl -Os https://uploader.codecov.io/latest/alpine/codecov.SHA256SUM + + curl -Os https://uploader.codecov.io/latest/alpine/codecov.SHA256SUM.sig + + gpgv codecov.SHA256SUM.sig codecov.SHA256SUM + + shasum -a 256 -c codecov.SHA256SUM + + chmod +x codecov + + mv codecov /usr/local/bin + rm codecov.SHA256SUM codecov.SHA256SUM.sig + """ + }, + ] + } +} diff --git a/ci/codecov/test/image.cue b/ci/codecov/test/image.cue new file mode 100644 index 0000000..4b309a3 --- /dev/null +++ b/ci/codecov/test/image.cue @@ -0,0 +1,11 @@ +package codecov + +import ( + "dagger.io/dagger" + + "emperror.dev/errors/ci/codecov" +) + +dagger.#Plan & { + actions: test: codecov.#Image & {} +} diff --git a/ci/codecov/upload.cue b/ci/codecov/upload.cue new file mode 100644 index 0000000..6e3abc2 --- /dev/null +++ b/ci/codecov/upload.cue @@ -0,0 +1,44 @@ +package codecov + +import ( + "dagger.io/dagger" + + "universe.dagger.io/docker" +) + +#Upload: { + // Source code + source: dagger.#FS + + // Coverage files + file: string + + // Codecov token (required for local runs and private repos) + token?: dagger.#Secret + + _image: #Image + + _sourcePath: "/src" + + docker.#Run & { + input: *_image.output | docker.#Image + command: { + name: "codecov" + flags: { + "--file": file + } + } + env: { + if token != _|_ { + CODECOV_TOKEN: token + } + } + workdir: _sourcePath + mounts: { + "source": { + dest: _sourcePath + contents: source + } + } + } +} diff --git a/dagger.cue b/dagger.cue index 36989a1..437ee60 100644 --- a/dagger.cue +++ b/dagger.cue @@ -2,21 +2,34 @@ package main import ( "dagger.io/dagger" + "dagger.io/dagger/core" "universe.dagger.io/go" "github.com/sagikazarmark/dagger/go/golangci" + "emperror.dev/errors/ci/codecov" ) dagger.#Plan & { client: filesystem: ".": read: exclude: [ ".github", "bin", - "build", + // "build", "tmp", ] // client: filesystem: "./build": write: contents: actions.build.debug.output client: network: "unix:///var/run/docker.sock": connect: dagger.#Socket + client: filesystem: "./build/test/coverage_1.18.out": write: contents: actions.check.test.go."1.18".export.files["/coverage.out"] + client: env: { + GITHUB_ACTIONS: string | *"" + GITHUB_HEAD_REF: string | *"" + GITHUB_REF: string | *"" + GITHUB_REPOSITORY: string | *"" + GITHUB_RUN_ID: string | *"" + GITHUB_SHA: string | *"" + GITHUB_WORKFLOW: string | *"" + CODECOV_TOKEN?: dagger.#Secret + } actions: { _source: client.filesystem["."].read.contents @@ -30,17 +43,55 @@ dagger.#Plan & { "1.17": _ "1.18": _ - [v=string]: go.#Test & { - source: _source - name: "go_test_\(v)" - package: "./..." + [v=string]: { + _test: go.#Test & { + source: _source + name: "go_test_\(v)" // necessary to keep cache for different versions separate + package: "./..." + + _image: go.#Image & { + version: v + } + + input: _image.output + command: flags: { + "-race": true + "-covermode": "atomic" + "-coverprofile": "/coverage.out" + } + + export: files: "/coverage.out": _ + } + + _coverage: codecov.#Upload & { + _write: core.#WriteFile & { + input: _source + path: "/coverage.out" + contents: _test.export.files."/coverage.out" + } + + source: _write.output + file: "/src/coverage.out" + + // Fixes https://github.com/dagger/dagger/issues/2680 + _env: client.env + + if _env.CODECOV_TOKEN != _|_ { + token: _env.CODECOV_TOKEN + } - _image: go.#Image & { - version: v + env: { + GITHUB_ACTIONS: client.env.GITHUB_ACTIONS + GITHUB_HEAD_REF: client.env.GITHUB_HEAD_REF + GITHUB_REF: client.env.GITHUB_REF + GITHUB_REPOSITORY: client.env.GITHUB_REPOSITORY + GITHUB_RUN_ID: client.env.GITHUB_RUN_ID + GITHUB_SHA: client.env.GITHUB_SHA + GITHUB_WORKFLOW: client.env.GITHUB_WORKFLOW + } } - input: _image.output - command: flags: "-race": true + export: files: "/coverage.out": _test.export.files."/coverage.out" } } } diff --git a/flake.lock b/flake.lock index 0f19413..ccab86a 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "flake-utils": { "locked": { - "lastModified": 1652776076, - "narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=", + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", "type": "github" }, "original": { @@ -42,11 +42,11 @@ ] }, "locked": { - "lastModified": 1653238580, - "narHash": "sha256-oY/LS2l70cLC58TQ+ByuJDSa6kYg+ka46bKqJItwSpA=", + "lastModified": 1655154025, + "narHash": "sha256-2CI379dRvr1rJbkdHGzjrp+WqhdARbZlzinRecuSUrY=", "owner": "sagikazarmark", "repo": "go-flake", - "rev": "1d00595d82d74ca0f3ba0cf8bd52bb42f3801b1d", + "rev": "1ec7a1219b4b6698bc7b8f3263761c23c66d520a", "type": "github" }, "original": { @@ -57,11 +57,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1653407748, - "narHash": "sha256-g9puJaILRTb9ttlLQ7IehpV7Wcy0n+vs8LOFu6ylQcM=", + "lastModified": 1655221618, + "narHash": "sha256-ht8HRFthDKzYt+il+sGgkBwrv+Ex2l8jdGVpsrPfFME=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5ce6597eca7d7b518c03ecda57d45f9404b5e060", + "rev": "6616de389ed55fba6eeba60377fc04732d5a207c", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 63b872f..c660a52 100644 --- a/flake.nix +++ b/flake.nix @@ -13,50 +13,29 @@ 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 + let + pkgs = import nixpkgs { + inherit system; + + overlays = [ + goflake.overlay + + ( + final: prev: { + golangci-lint = gobin.packages.${system}.golangci-lint-bin; + } + ) ]; - in - { devShell = pkgs.mkShell { buildInputs = devDeps; }; } + }; + + buildDeps = with pkgs; [ git go_1_17 gnumake ]; + devDeps = with pkgs; buildDeps ++ [ + golangci-lint + gotestsum + dagger + go-task + ]; + in + { devShell = pkgs.mkShell { buildInputs = devDeps; }; } ); } From 6f06bd71b200026a4efc9f3d369a7a064cc74610 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Sun, 19 Jun 2022 15:18:09 +0200 Subject: [PATCH 3/8] update dagger lib Signed-off-by: Mark Sagi-Kazar --- cue.mod/dagger.sum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cue.mod/dagger.sum b/cue.mod/dagger.sum index 4b81d6b..65ec048 100644 --- a/cue.mod/dagger.sum +++ b/cue.mod/dagger.sum @@ -1 +1 @@ -github.com/sagikazarmark/dagger h1:tiyrgWTRtUgipmeZEaoN3y/ejlHHYI7pVSVTxmm/NWQ= +github.com/sagikazarmark/dagger h1:ekTs7tQbia01P9hMcMFSmA5TMFybb5F15Nlx8vYwU2g= From ed665420aeb7cd4b125011a8619368d7cba6d30a Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Sun, 19 Jun 2022 19:41:09 +0200 Subject: [PATCH 4/8] do not use token parameter Signed-off-by: Mark Sagi-Kazar --- dagger.cue | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/dagger.cue b/dagger.cue index 437ee60..32d6d75 100644 --- a/dagger.cue +++ b/dagger.cue @@ -14,12 +14,10 @@ dagger.#Plan & { client: filesystem: ".": read: exclude: [ ".github", "bin", - // "build", + "build", "tmp", ] - // client: filesystem: "./build": write: contents: actions.build.debug.output client: network: "unix:///var/run/docker.sock": connect: dagger.#Socket - client: filesystem: "./build/test/coverage_1.18.out": write: contents: actions.check.test.go."1.18".export.files["/coverage.out"] client: env: { GITHUB_ACTIONS: string | *"" GITHUB_HEAD_REF: string | *"" @@ -74,13 +72,17 @@ dagger.#Plan & { file: "/src/coverage.out" // Fixes https://github.com/dagger/dagger/issues/2680 - _env: client.env + // _env: client.env - if _env.CODECOV_TOKEN != _|_ { - token: _env.CODECOV_TOKEN - } + // if _env.CODECOV_TOKEN != _|_ { + // token: _env.CODECOV_TOKEN + // } + // token: client.env.CODECOV_TOKEN env: { + if client.env.CODECOV_TOKEN != _|_ { + CODECOV_TOKEN: client.env.CODECOV_TOKEN + } GITHUB_ACTIONS: client.env.GITHUB_ACTIONS GITHUB_HEAD_REF: client.env.GITHUB_HEAD_REF GITHUB_REF: client.env.GITHUB_REF From 51b2faa3687d9b0ee80175f6d91d0f1034e7ba55 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Sun, 19 Jun 2022 20:26:14 +0200 Subject: [PATCH 5/8] fix dagger resolve Signed-off-by: Mark Sagi-Kazar --- dagger.cue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dagger.cue b/dagger.cue index 32d6d75..a376015 100644 --- a/dagger.cue +++ b/dagger.cue @@ -77,12 +77,20 @@ dagger.#Plan & { // if _env.CODECOV_TOKEN != _|_ { // token: _env.CODECOV_TOKEN // } + + // Fixes https://github.com/dagger/dagger/issues/2680 + _token: client.env.CODECOV_TOKEN + + if client.env.CODECOV_TOKEN != _|_ { + token: client.env.CODECOV_TOKEN + } + // token: client.env.CODECOV_TOKEN env: { - if client.env.CODECOV_TOKEN != _|_ { - CODECOV_TOKEN: client.env.CODECOV_TOKEN - } + // if client.env.CODECOV_TOKEN != _|_ { + // CODECOV_TOKEN: client.env.CODECOV_TOKEN + // } GITHUB_ACTIONS: client.env.GITHUB_ACTIONS GITHUB_HEAD_REF: client.env.GITHUB_HEAD_REF GITHUB_REF: client.env.GITHUB_REF From 3f25881058a432948b0c2e90060bed8704c5133d Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 20 Jun 2022 03:28:35 +0200 Subject: [PATCH 6/8] add github server URL Signed-off-by: Mark Sagi-Kazar --- ci/codecov/upload.cue | 3 ++- dagger.cue | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ci/codecov/upload.cue b/ci/codecov/upload.cue index 6e3abc2..d4977db 100644 --- a/ci/codecov/upload.cue +++ b/ci/codecov/upload.cue @@ -25,7 +25,8 @@ import ( command: { name: "codecov" flags: { - "--file": file + "--file": file + "--verbose": true } } env: { diff --git a/dagger.cue b/dagger.cue index a376015..6f8ab78 100644 --- a/dagger.cue +++ b/dagger.cue @@ -24,6 +24,7 @@ dagger.#Plan & { GITHUB_REF: string | *"" GITHUB_REPOSITORY: string | *"" GITHUB_RUN_ID: string | *"" + GITHUB_SERVER_URL: string | *"" GITHUB_SHA: string | *"" GITHUB_WORKFLOW: string | *"" CODECOV_TOKEN?: dagger.#Secret @@ -96,6 +97,7 @@ dagger.#Plan & { GITHUB_REF: client.env.GITHUB_REF GITHUB_REPOSITORY: client.env.GITHUB_REPOSITORY GITHUB_RUN_ID: client.env.GITHUB_RUN_ID + GITHUB_SERVER_URL: client.env.GITHUB_SERVER_URL GITHUB_SHA: client.env.GITHUB_SHA GITHUB_WORKFLOW: client.env.GITHUB_WORKFLOW } From 56c157c0ec4cd1ae857ef904f565cef0d2f5861a Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 20 Jun 2022 03:30:01 +0200 Subject: [PATCH 7/8] add github action to dagger Signed-off-by: Mark Sagi-Kazar --- dagger.cue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dagger.cue b/dagger.cue index 6f8ab78..d2a4153 100644 --- a/dagger.cue +++ b/dagger.cue @@ -20,6 +20,7 @@ dagger.#Plan & { client: network: "unix:///var/run/docker.sock": connect: dagger.#Socket client: env: { GITHUB_ACTIONS: string | *"" + GITHUB_ACTION: string | *"" GITHUB_HEAD_REF: string | *"" GITHUB_REF: string | *"" GITHUB_REPOSITORY: string | *"" @@ -93,6 +94,7 @@ dagger.#Plan & { // CODECOV_TOKEN: client.env.CODECOV_TOKEN // } GITHUB_ACTIONS: client.env.GITHUB_ACTIONS + GITHUB_ACTION: client.env.GITHUB_ACTION GITHUB_HEAD_REF: client.env.GITHUB_HEAD_REF GITHUB_REF: client.env.GITHUB_REF GITHUB_REPOSITORY: client.env.GITHUB_REPOSITORY From 64edce600b527a4d36029a6bd5279f367ff0fe9c Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 20 Jun 2022 03:43:06 +0200 Subject: [PATCH 8/8] codecov dry run on no CI Signed-off-by: Mark Sagi-Kazar --- ci/codecov/upload.cue | 7 +++++++ dagger.cue | 3 +++ 2 files changed, 10 insertions(+) diff --git a/ci/codecov/upload.cue b/ci/codecov/upload.cue index d4977db..e3cb073 100644 --- a/ci/codecov/upload.cue +++ b/ci/codecov/upload.cue @@ -16,6 +16,9 @@ import ( // Codecov token (required for local runs and private repos) token?: dagger.#Secret + // Don't upload files to Codecov + dryRun: bool | *false + _image: #Image _sourcePath: "/src" @@ -27,6 +30,10 @@ import ( flags: { "--file": file "--verbose": true + + if dryRun { + "--dryRun": true + } } } env: { diff --git a/dagger.cue b/dagger.cue index d2a4153..7739c86 100644 --- a/dagger.cue +++ b/dagger.cue @@ -19,6 +19,7 @@ dagger.#Plan & { ] client: network: "unix:///var/run/docker.sock": connect: dagger.#Socket client: env: { + CI: string | *"" GITHUB_ACTIONS: string | *"" GITHUB_ACTION: string | *"" GITHUB_HEAD_REF: string | *"" @@ -87,6 +88,8 @@ dagger.#Plan & { token: client.env.CODECOV_TOKEN } + dryRun: client.env.CI != "true" + // token: client.env.CODECOV_TOKEN env: {