From f90b1ad079281e375a137d196311e1dd349b2fd4 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 31 Mar 2022 19:17:11 -0700 Subject: [PATCH 01/10] universe: go: do not hardcode default platform Signed-off-by: Andrea Luzzardi --- pkg/universe.dagger.io/go/build.cue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/universe.dagger.io/go/build.cue b/pkg/universe.dagger.io/go/build.cue index eb0a080e..5e64b171 100644 --- a/pkg/universe.dagger.io/go/build.cue +++ b/pkg/universe.dagger.io/go/build.cue @@ -13,10 +13,10 @@ import ( package: *"." | string // Target architecture - arch: *"amd64" | string + arch?: string // Target OS - os: *"linux" | string + os?: string // Build tags to use for building tags: *"" | string @@ -30,8 +30,12 @@ import ( "source": source "env": { env - GOOS: os - GOARCH: arch + if os != _|_ { + GOOS: os + } + if arch != _|_ { + GOARCH: arch + } } command: { args: [package] From 3e8c9379b5cecbb84ebe92f61652a4af8b67f8e4 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 31 Mar 2022 19:19:15 -0700 Subject: [PATCH 02/10] universe: go: improve cache management Signed-off-by: Andrea Luzzardi --- pkg/universe.dagger.io/go/build.cue | 1 + pkg/universe.dagger.io/go/container.cue | 22 +++++++++++++------- pkg/universe.dagger.io/go/test.cue | 1 + pkg/universe.dagger.io/go/test/container.cue | 10 +++++++-- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/pkg/universe.dagger.io/go/build.cue b/pkg/universe.dagger.io/go/build.cue index 5e64b171..72e1eef1 100644 --- a/pkg/universe.dagger.io/go/build.cue +++ b/pkg/universe.dagger.io/go/build.cue @@ -38,6 +38,7 @@ import ( } } command: { + name: "go" args: [package] flags: { build: true diff --git a/pkg/universe.dagger.io/go/container.cue b/pkg/universe.dagger.io/go/container.cue index d53009dd..df52f57b 100644 --- a/pkg/universe.dagger.io/go/container.cue +++ b/pkg/universe.dagger.io/go/container.cue @@ -18,25 +18,31 @@ import ( // Use go image _image: #Image - _sourcePath: "/src" - _cachePath: "/root/.cache/gocache" + _sourcePath: "/src" + _modCachePath: "/root/.cache/go-mod" + _buildCachePath: "/root/.cache/go-build" docker.#Run & { input: *_image.output | docker.#Image - workdir: "/src" - command: name: "go" + workdir: _sourcePath mounts: { "source": { dest: _sourcePath contents: source } - "go assets cache": { + "go mod cache": { contents: core.#CacheDir & { - id: "\(name)_assets" + id: "\(name)_mod" } - dest: _cachePath + dest: _modCachePath + } + "go build cache": { + contents: core.#CacheDir & { + id: "\(name)_build" + } + dest: _buildCachePath } } - env: GOMODCACHE: _cachePath + env: GOMODCACHE: _modCachePath } } diff --git a/pkg/universe.dagger.io/go/test.cue b/pkg/universe.dagger.io/go/test.cue index 5de2b94b..167c6a23 100644 --- a/pkg/universe.dagger.io/go/test.cue +++ b/pkg/universe.dagger.io/go/test.cue @@ -7,6 +7,7 @@ package go #Container & { command: { + name: "go" args: [package] flags: { test: true diff --git a/pkg/universe.dagger.io/go/test/container.cue b/pkg/universe.dagger.io/go/test/container.cue index 82aad0c5..4966a1a1 100644 --- a/pkg/universe.dagger.io/go/test/container.cue +++ b/pkg/universe.dagger.io/go/test/container.cue @@ -12,7 +12,10 @@ dagger.#Plan & { simple: go.#Container & { source: _source - command: args: ["version"] + command: { + name: "go" + args: ["version"] + } } override: { @@ -23,7 +26,10 @@ dagger.#Plan & { command: go.#Container & { input: base.output source: _source - command: args: ["version"] + command: { + name: "go" + args: ["version"] + } } } } From 0a6fa03c162d9d863bbbe8f039bc509efbd6e742 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 31 Mar 2022 19:20:19 -0700 Subject: [PATCH 03/10] client filesystem: remove .dagger from default exclusion Signed-off-by: Andrea Luzzardi --- plan/task/clientfilesystemread.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plan/task/clientfilesystemread.go b/plan/task/clientfilesystemread.go index 3dc6a5e3..733c53ae 100644 --- a/plan/task/clientfilesystemread.go +++ b/plan/task/clientfilesystemread.go @@ -125,12 +125,9 @@ func (t clientFilesystemReadTask) readFS(ctx context.Context, pctx *plancontext. opts = append(opts, llb.IncludePatterns(dir.Include)) } - // Excludes .dagger directory by default - excludePatterns := []string{"**/.dagger/"} if len(dir.Exclude) > 0 { - excludePatterns = dir.Exclude + opts = append(opts, llb.ExcludePatterns(dir.Exclude)) } - opts = append(opts, llb.ExcludePatterns(excludePatterns)) // FIXME: Remove the `Copy` and use `Local` directly. // From cf3993a2350ec9e6477a58b680eca294c2f03b82 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 31 Mar 2022 19:20:36 -0700 Subject: [PATCH 04/10] task: source: fix vertex name Signed-off-by: Andrea Luzzardi --- plan/task/source.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plan/task/source.go b/plan/task/source.go index 19556b39..816cd994 100644 --- a/plan/task/source.go +++ b/plan/task/source.go @@ -69,7 +69,7 @@ func (c *sourceTask) Run(ctx context.Context, pctx *plancontext.Context, s *solv lg.Debug().Str("path", path).Msg("loading local directory") opts := []llb.LocalOption{ - withCustomName(v, "Embed %s", path), + withCustomName(v, "Source %s", path), llb.IncludePatterns(source.Include), llb.ExcludePatterns(source.Exclude), // Without hint, multiple `llb.Local` operations on the From b989c5d6615db19e1713b3def9c95b75748aef54 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 31 Mar 2022 19:21:43 -0700 Subject: [PATCH 05/10] universe: go: add golangci-lint support Signed-off-by: Andrea Luzzardi --- pkg/universe.dagger.io/go/golangci/lint.cue | 37 +++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 pkg/universe.dagger.io/go/golangci/lint.cue diff --git a/pkg/universe.dagger.io/go/golangci/lint.cue b/pkg/universe.dagger.io/go/golangci/lint.cue new file mode 100644 index 00000000..32008ff5 --- /dev/null +++ b/pkg/universe.dagger.io/go/golangci/lint.cue @@ -0,0 +1,37 @@ +package golangci + +import ( + "dagger.io/dagger" + + "universe.dagger.io/docker" + "universe.dagger.io/go" +) + +// Lint using golangci-lint +#Lint: { + // Source code + source: dagger.#FS + + // golangci-lint version + version: *"1.45" | string + + // timeout + timeout: *"5m" | string + + _image: docker.#Pull & { + source: "golangci/golangci-lint:v\(version)" + } + + container: go.#Container & { + "source": source + input: _image.output + command: { + name: "golangci-lint" + flags: { + run: true + "-v": true + "--timeout": timeout + } + } + } +} From 8fe29cdc76480adc79701e4c492ff1e87566f569 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 31 Mar 2022 19:33:07 -0700 Subject: [PATCH 06/10] ci: use dagger from source Signed-off-by: Andrea Luzzardi --- .github/workflows/dagger-ci.yml | 92 ++++++++++++++++++++++++--------- 1 file changed, 68 insertions(+), 24 deletions(-) diff --git a/.github/workflows/dagger-ci.yml b/.github/workflows/dagger-ci.yml index 1492b19e..98622eee 100644 --- a/.github/workflows/dagger-ci.yml +++ b/.github/workflows/dagger-ci.yml @@ -2,42 +2,86 @@ name: "Dagger CI" on: push: - branches: [ main ] + branches: [main] paths: - - '**.sh' - - '**.bash' - - '**.go' - - '**.cue' - - '**.bats' - - 'Makefile' - - 'go.mod' - - 'go.sum' - - '.github/workflows/dagger-ci.yml' + - "**.sh" + - "**.bash" + - "**.go" + - "**.cue" + - "**.bats" + - "Makefile" + - "go.mod" + - "go.sum" + - ".github/workflows/dagger-ci.yml" pull_request: - branches: [ main ] + branches: [main] paths: - - '**.sh' - - '**.bash' - - '**.go' - - '**.cue' - - '**.bats' - - 'Makefile' - - 'go.mod' - - 'go.sum' - - '.github/workflows/dagger-ci.yml' + - "**.sh" + - "**.bash" + - "**.go" + - "**.cue" + - "**.bats" + - "Makefile" + - "go.mod" + - "go.sum" + - ".github/workflows/dagger-ci.yml" env: DAGGER_LOG_FORMAT: plain jobs: build: + name: "Build" runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - - name: Dagger CI - uses: dagger/dagger-for-github@v2 + - name: "Setup Go" + uses: actions/setup-go@v1 with: - workdir: ci - args: do build + go-version: 1.16 + + - name: "Expose GitHub Runtime" + uses: crazy-max/ghaction-github-runtime@v1 + + - name: Prepare dagger + run: | + make dagger + cp ./cmd/dagger/dagger /usr/local/bin + + - name: Build + env: + DAGGER_CACHE_TO: "type=gha,mode=max,scope=dagger-ci-build" + DAGGER_CACHE_FROM: "type=gha,scope=dagger-ci-build" + run: | + cd ci + dagger do build + + lint: + name: "Lint" + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: "Setup Go" + uses: actions/setup-go@v1 + with: + go-version: 1.16 + + - name: "Expose GitHub Runtime" + uses: crazy-max/ghaction-github-runtime@v1 + + - name: Prepare dagger + run: | + make dagger + cp ./cmd/dagger/dagger /usr/local/bin + + - name: Lint + env: + DAGGER_CACHE_TO: "type=gha,mode=max,scope=dagger-ci-lint" + DAGGER_CACHE_FROM: "type=gha,scope=dagger-ci-lint" + run: | + cd ci + dagger do lint From 31daeb05edf2f8f50af1f27e5281f4dde1216b84 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 31 Mar 2022 19:21:54 -0700 Subject: [PATCH 07/10] ci: improve dogfood configuration - Use official Go package - Use golangci-lint package - Fix node_modules exclusion for local source - Improve CUE performance by optimizing cache hits Signed-off-by: Andrea Luzzardi --- ci/images.cue | 80 ------------------------- ci/main.cue | 160 +++++++++++++++++++++++++++++++------------------- source.cue | 15 ----- 3 files changed, 99 insertions(+), 156 deletions(-) delete mode 100644 ci/images.cue delete mode 100644 source.cue diff --git a/ci/images.cue b/ci/images.cue deleted file mode 100644 index 6e2296f7..00000000 --- a/ci/images.cue +++ /dev/null @@ -1,80 +0,0 @@ -package main - -import ( - "universe.dagger.io/docker" -) - -let GoVersion = "1.17" -let GolangCILintVersion = "1.44.0" -let CUEVersion = "0.4.2" - -// Base container images used for the CI -#Images: { - - // base image to build go binaries - goBuilder: _goBuilder.output - _goBuilder: docker.#Build & { - _packages: ["bash", "git", "alpine-sdk"] - - steps: [ - docker.#Pull & { - source: "index.docker.io/golang:\(GoVersion)-alpine" - }, - for pkg in _packages { - docker.#Run & { - command: { - name: "apk" - args: ["add", pkg] - flags: { - "-U": true - "--no-cache": true - } - } - } - }, - ] - } - - // base image for the Go linter - // https://golangci-lint.run/usage/install/#docker - goLinter: _goLinter.output - _goLinter: docker.#Pull & { - source: "index.docker.io/golangci/golangci-lint:v\(GolangCILintVersion)" - } - - // base image for CUE cli + alpine distrib - cue: _cue._alpine.output - _cue: { - _cueBinary: docker.#Pull & { - source: "index.docker.io/cuelang/cue:\(CUEVersion)" - } - - _alpine: docker.#Build & { - _packages: ["bash", "git"] - - steps: [ - docker.#Pull & { - source: "index.docker.io/alpine:3" - }, - for pkg in _packages { - docker.#Run & { - command: { - name: "apk" - args: ["add", pkg] - flags: { - "-U": true - "--no-cache": true - } - } - } - }, - docker.#Copy & { - // input: _alpine.output - contents: _cueBinary.output.rootfs - source: "/usr/bin/cue" - dest: "/usr/bin/cue" - }, - ] - } - } -} diff --git a/ci/main.cue b/ci/main.cue index 6abdcaa0..2d1f0ea5 100644 --- a/ci/main.cue +++ b/ci/main.cue @@ -2,98 +2,136 @@ package main import ( "dagger.io/dagger" - "dagger.io/dagger/core" + "universe.dagger.io/bash" + "universe.dagger.io/alpine" + "universe.dagger.io/docker" + "universe.dagger.io/go" + "universe.dagger.io/go/golangci" ) dagger.#Plan & { - // FIXME: Ideally we would want to automatically set the platform's arch identical to the host // to avoid the performance hit caused by qemu (linter goes from <3s to >3m when arch is x86) // Uncomment if running locally on Mac M1 to bypass qemu // platform: "linux/aarch64" platform: "linux/amd64" - client: filesystem: "./build": write: contents: actions.build.export.directories["/build"] + client: filesystem: "../": read: exclude: [ + "ci", + "**/node_modules", + "cmd/dagger/dagger", + "cmd/dagger/dagger-debug", + ] + client: filesystem: "./build": write: contents: actions.build.output actions: { - _mountGoCache: { - mounts: "go mod cache": { - dest: "/root/.gocache" - contents: core.#CacheDir & { - id: "go mod cache" + _source: client.filesystem["../"].read.contents + + // FIXME: this can be removed once `go` supports built-in VCS info + version: { + _image: alpine.#Build & { + packages: bash: _ + packages: curl: _ + packages: git: _ + } + + _revision: bash.#Run & { + input: _image.output + workdir: "/src" + mounts: source: { + dest: "/src" + contents: _source } + + script: contents: #""" + printf "$(git rev-parse --short HEAD)" > /revision + """# + export: files: "/revision": string } - env: GOMODCACHE: mounts["go mod cache"].dest + + output: _revision.export.files["/revision"] } - _mountSourceCode: { - mounts: "dagger source code": { - contents: _source.output - dest: "/usr/src/dagger" - } - workdir: mounts["dagger source code"].dest - } + build: go.#Build & { + source: _source + package: "./cmd/dagger/" + os: client.platform.os + arch: client.platform.arch - _baseImages: #Images - - // Go build the dagger binary - // depends on goLint and goTest to complete successfully - build: bash.#Run & { - _mountSourceCode - _mountGoCache - - input: _baseImages.goBuilder + ldflags: "-s -w -X go.dagger.io/dagger/version.Revision=\(version.output)" env: { - GOOS: client.platform.os - GOARCH: client.platform.arch CGO_ENABLED: "0" // Makes sure the linter and unit tests complete before starting the build - "__depends_lint": "\(goLint.exit)" - "__depends_tests": "\(goTest.exit)" + // "__depends_lint": "\(goLint.exit)" + // "__depends_tests": "\(goTest.exit)" } - - script: contents: #""" - mkdir -p /build - git_revision=$(git rev-parse --short HEAD) - go build -v -o /build/dagger \ - -ldflags '-s -w -X go.dagger.io/dagger/version.Revision='${git_revision} \ - ./cmd/dagger/ - """# - - export: directories: "/build": _ } // Go unit tests - goTest: bash.#Run & { - _mountSourceCode - _mountGoCache + test: go.#Test & { + // container: image: _goImage.output + source: _source + package: "./..." - input: _baseImages.goBuilder - script: contents: "go test -race -v ./..." + // FIXME: doesn't work with CGO_ENABLED=0 + // command: flags: "-race": true + + env: { + // FIXME: removing this complains about lack of gcc + CGO_ENABLED: "0" + } } - // Go lint using golangci-lint - goLint: bash.#Run & { - _mountSourceCode - _mountGoCache + lint: { + go: golangci.#Lint & { + source: _source + version: "1.45" + } - input: _baseImages.goLinter - script: contents: "golangci-lint run -v --timeout 5m" - } + cue: docker.#Build & { + steps: [ + alpine.#Build & { + packages: bash: _ + packages: curl: _ + packages: git: _ + }, - // CUE lint - cueLint: bash.#Run & { - _mountSourceCode + docker.#Copy & { + contents: _source + source: "go.mod" + dest: "go.mod" + }, - input: _baseImages.cue - script: contents: #""" - # Format the cue code - find . -name '*.cue' -not -path '*/cue.mod/*' -print | time xargs -n 1 -P 8 cue fmt -s - # Check that all formatted files where committed - test -z $(git status -s . | grep -e '^ M' | grep .cue | cut -d ' ' -f3) - """# + // Install CUE + bash.#Run & { + script: contents: #""" + export CUE_VERSION="$(grep cue ./go.mod | cut -d' ' -f2 | head -1 | sed -E 's/\.[[:digit:]]\.[[:alnum:]]+-[[:alnum:]]+$//')" + export CUE_TARBALL="cue_${CUE_VERSION}_linux_amd64.tar.gz" + echo "Installing cue version $CUE_VERSION" + curl -L "https://github.com/cue-lang/cue/releases/download/${CUE_VERSION}/${CUE_TARBALL}" | tar zxf - -C /usr/local/bin + cue version + """# + }, + + // CACHE: copy only *.cue files + docker.#Copy & { + contents: _source + include: ["*.cue"] + dest: "/cue" + }, + + // LINT + bash.#Run & { + workdir: "/cue" + script: contents: #""" + find . -name '*.cue' -not -path '*/cue.mod/*' -print | time xargs -t -n 1 -P 8 cue fmt -s + test -z "$(git status -s . | grep -e "^ M" | grep "\.cue" | cut -d ' ' -f3 | tee /dev/stderr)" + """# + }, + ] + } } } } diff --git a/source.cue b/source.cue deleted file mode 100644 index c5213142..00000000 --- a/source.cue +++ /dev/null @@ -1,15 +0,0 @@ -package main - -import ( - "dagger.io/dagger/core" -) - -_source: core.#Source & { - path: "." - exclude: [ - "ci", - "node_modules", - "cmd/dagger/dagger", - "cmd/dagger/dagger-debug", - ] -} From 517262dfdee1fa06d8c01be35ed5e7a53f23664c Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Fri, 1 Apr 2022 11:33:18 -0700 Subject: [PATCH 08/10] ci: lint shell Signed-off-by: Andrea Luzzardi --- ci/cue.mod/module.cue | 1 + ci/cue.mod/pkg | 1 + ci/main.cue | 6 ++++++ ci/pkg/shellcheck/shellcheck.cue | 34 ++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 ci/cue.mod/module.cue create mode 120000 ci/cue.mod/pkg create mode 100644 ci/pkg/shellcheck/shellcheck.cue diff --git a/ci/cue.mod/module.cue b/ci/cue.mod/module.cue new file mode 100644 index 00000000..c511367d --- /dev/null +++ b/ci/cue.mod/module.cue @@ -0,0 +1 @@ +module: "github.com/dagger/dagger/ci" \ No newline at end of file diff --git a/ci/cue.mod/pkg b/ci/cue.mod/pkg new file mode 120000 index 00000000..b49d704a --- /dev/null +++ b/ci/cue.mod/pkg @@ -0,0 +1 @@ +../../pkg \ No newline at end of file diff --git a/ci/main.cue b/ci/main.cue index 2d1f0ea5..9f66dfab 100644 --- a/ci/main.cue +++ b/ci/main.cue @@ -8,6 +8,8 @@ import ( "universe.dagger.io/docker" "universe.dagger.io/go" "universe.dagger.io/go/golangci" + + "github.com/dagger/dagger/ci/pkg/shellcheck" ) dagger.#Plan & { @@ -90,6 +92,10 @@ dagger.#Plan & { version: "1.45" } + shell: shellcheck.#Lint & { + source: _source + } + cue: docker.#Build & { steps: [ alpine.#Build & { diff --git a/ci/pkg/shellcheck/shellcheck.cue b/ci/pkg/shellcheck/shellcheck.cue new file mode 100644 index 00000000..b11bf62c --- /dev/null +++ b/ci/pkg/shellcheck/shellcheck.cue @@ -0,0 +1,34 @@ +package shellcheck + +import ( + "dagger.io/dagger" + + "universe.dagger.io/docker" +) + +#Lint: { + // Source code + source: dagger.#FS + + // shellcheck version + version: *"0.8.0" | string + + _image: docker.#Pull & { + source: "koalaman/shellcheck-alpine:v\(version)" + } + + container: docker.#Run & { + input: _image.output + mounts: "source": { + dest: "/src" + contents: source + } + workdir: "/src" + command: { + name: "sh" + args: ["-c", #""" + shellcheck $(find . -type f \( -iname \*.bats -o -iname \*.bash -o -iname \*.sh \) -not -path "*/node_modules/*" -not -path "*/bats-*/*") + """#] + } + } +} From 50b36a50aa619d5e206255a004776300d188960e Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Fri, 1 Apr 2022 12:07:55 -0700 Subject: [PATCH 09/10] ci: lint markdown files Signed-off-by: Andrea Luzzardi --- ci/main.cue | 8 ++++- .../go => ci/pkg}/golangci/lint.cue | 0 ci/pkg/markdownlint/markdownlint.cue | 36 +++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) rename {pkg/universe.dagger.io/go => ci/pkg}/golangci/lint.cue (100%) create mode 100644 ci/pkg/markdownlint/markdownlint.cue diff --git a/ci/main.cue b/ci/main.cue index 9f66dfab..b05fedd3 100644 --- a/ci/main.cue +++ b/ci/main.cue @@ -7,9 +7,10 @@ import ( "universe.dagger.io/alpine" "universe.dagger.io/docker" "universe.dagger.io/go" - "universe.dagger.io/go/golangci" + "github.com/dagger/dagger/ci/pkg/golangci" "github.com/dagger/dagger/ci/pkg/shellcheck" + "github.com/dagger/dagger/ci/pkg/markdownlint" ) dagger.#Plan & { @@ -96,6 +97,11 @@ dagger.#Plan & { source: _source } + markdown: markdownlint.#Lint & { + source: _source + files: ["./docs", "README.md"] + } + cue: docker.#Build & { steps: [ alpine.#Build & { diff --git a/pkg/universe.dagger.io/go/golangci/lint.cue b/ci/pkg/golangci/lint.cue similarity index 100% rename from pkg/universe.dagger.io/go/golangci/lint.cue rename to ci/pkg/golangci/lint.cue diff --git a/ci/pkg/markdownlint/markdownlint.cue b/ci/pkg/markdownlint/markdownlint.cue new file mode 100644 index 00000000..02043a3b --- /dev/null +++ b/ci/pkg/markdownlint/markdownlint.cue @@ -0,0 +1,36 @@ +package markdownlint + +import ( + "dagger.io/dagger" + + "universe.dagger.io/docker" +) + +#Lint: { + // Source code + source: dagger.#FS + + // shellcheck version + version: *"0.31.1" | string + + // Files to lint + files: [...string] + + _image: docker.#Pull & { + source: "tmknom/markdownlint:\(version)" + } + + container: docker.#Run & { + input: _image.output + mounts: "source": { + dest: "/src" + contents: source + } + workdir: "/src" + command: { + // FIXME: this should not be required + name: "markdownlint" + args: files + } + } +} From 93d22240731a22d6232ee05e44dc586472811f0d Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Mon, 4 Apr 2022 17:40:16 -0700 Subject: [PATCH 10/10] ci: move ci infra top-level Signed-off-by: Andrea Luzzardi --- .github/workflows/dagger-ci.yml | 2 -- ci/main.cue => ci.cue | 15 ++++++++------- ci/.gitignore | 1 - ci/README.md | 7 ------- ci/cue.mod/module.cue | 1 - ci/cue.mod/pkg | 1 - ci/{pkg => }/golangci/lint.cue | 0 ci/{pkg => }/markdownlint/markdownlint.cue | 0 ci/{pkg => }/shellcheck/shellcheck.cue | 0 cue.mod/module.cue | 2 +- 10 files changed, 9 insertions(+), 20 deletions(-) rename ci/main.cue => ci.cue (90%) delete mode 100644 ci/.gitignore delete mode 100644 ci/README.md delete mode 100644 ci/cue.mod/module.cue delete mode 120000 ci/cue.mod/pkg rename ci/{pkg => }/golangci/lint.cue (100%) rename ci/{pkg => }/markdownlint/markdownlint.cue (100%) rename ci/{pkg => }/shellcheck/shellcheck.cue (100%) diff --git a/.github/workflows/dagger-ci.yml b/.github/workflows/dagger-ci.yml index 98622eee..95e0c2b3 100644 --- a/.github/workflows/dagger-ci.yml +++ b/.github/workflows/dagger-ci.yml @@ -55,7 +55,6 @@ jobs: DAGGER_CACHE_TO: "type=gha,mode=max,scope=dagger-ci-build" DAGGER_CACHE_FROM: "type=gha,scope=dagger-ci-build" run: | - cd ci dagger do build lint: @@ -83,5 +82,4 @@ jobs: DAGGER_CACHE_TO: "type=gha,mode=max,scope=dagger-ci-lint" DAGGER_CACHE_FROM: "type=gha,scope=dagger-ci-lint" run: | - cd ci dagger do lint diff --git a/ci/main.cue b/ci.cue similarity index 90% rename from ci/main.cue rename to ci.cue index b05fedd3..310f4b18 100644 --- a/ci/main.cue +++ b/ci.cue @@ -8,9 +8,9 @@ import ( "universe.dagger.io/docker" "universe.dagger.io/go" - "github.com/dagger/dagger/ci/pkg/golangci" - "github.com/dagger/dagger/ci/pkg/shellcheck" - "github.com/dagger/dagger/ci/pkg/markdownlint" + "github.com/dagger/dagger/ci/golangci" + "github.com/dagger/dagger/ci/shellcheck" + "github.com/dagger/dagger/ci/markdownlint" ) dagger.#Plan & { @@ -20,16 +20,16 @@ dagger.#Plan & { // platform: "linux/aarch64" platform: "linux/amd64" - client: filesystem: "../": read: exclude: [ - "ci", + client: filesystem: ".": read: exclude: [ + "bin", "**/node_modules", "cmd/dagger/dagger", "cmd/dagger/dagger-debug", ] - client: filesystem: "./build": write: contents: actions.build.output + client: filesystem: "./bin": write: contents: actions.build.output actions: { - _source: client.filesystem["../"].read.contents + _source: client.filesystem["."].read.contents // FIXME: this can be removed once `go` supports built-in VCS info version: { @@ -103,6 +103,7 @@ dagger.#Plan & { } cue: docker.#Build & { + // FIXME: spin off into its own package? steps: [ alpine.#Build & { packages: bash: _ diff --git a/ci/.gitignore b/ci/.gitignore deleted file mode 100644 index a007feab..00000000 --- a/ci/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build/* diff --git a/ci/README.md b/ci/README.md deleted file mode 100644 index 0ad8a3d7..00000000 --- a/ci/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Dagger CI - -WORK IN PROGRESS - -This is the home of the new CI - -Reference: https://github.com/dagger/dagger/issues/1549 diff --git a/ci/cue.mod/module.cue b/ci/cue.mod/module.cue deleted file mode 100644 index c511367d..00000000 --- a/ci/cue.mod/module.cue +++ /dev/null @@ -1 +0,0 @@ -module: "github.com/dagger/dagger/ci" \ No newline at end of file diff --git a/ci/cue.mod/pkg b/ci/cue.mod/pkg deleted file mode 120000 index b49d704a..00000000 --- a/ci/cue.mod/pkg +++ /dev/null @@ -1 +0,0 @@ -../../pkg \ No newline at end of file diff --git a/ci/pkg/golangci/lint.cue b/ci/golangci/lint.cue similarity index 100% rename from ci/pkg/golangci/lint.cue rename to ci/golangci/lint.cue diff --git a/ci/pkg/markdownlint/markdownlint.cue b/ci/markdownlint/markdownlint.cue similarity index 100% rename from ci/pkg/markdownlint/markdownlint.cue rename to ci/markdownlint/markdownlint.cue diff --git a/ci/pkg/shellcheck/shellcheck.cue b/ci/shellcheck/shellcheck.cue similarity index 100% rename from ci/pkg/shellcheck/shellcheck.cue rename to ci/shellcheck/shellcheck.cue diff --git a/cue.mod/module.cue b/cue.mod/module.cue index b57d0104..dc80073f 100644 --- a/cue.mod/module.cue +++ b/cue.mod/module.cue @@ -1 +1 @@ -module: "" \ No newline at end of file +module: "github.com/dagger/dagger"