Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ekinbarut committed Apr 4, 2022
2 parents 2ed9475 + cd948f3 commit 12c7a41
Show file tree
Hide file tree
Showing 63 changed files with 759 additions and 720 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/dagger-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Dagger CI"

on:
push:
branches: [main]
branches: [ main ]
paths:
- '**.sh'
- '**.bash'
Expand All @@ -14,7 +14,7 @@ on:
- 'go.sum'
- '.github/workflows/dagger-ci.yml'
pull_request:
branches: [main]
branches: [ main ]
paths:
- '**.sh'
- '**.bash'
Expand All @@ -33,11 +33,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v2
-
name: Dagger CI

- name: Dagger CI
uses: dagger/dagger-for-github@v2
with:
workdir: ci
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Test Integration"

on:
push:
branches: [main]
branches: [ main ]
paths:
- "**.sh"
- "**.bash"
Expand All @@ -16,7 +16,7 @@ on:
- "!docs/**"

pull_request:
branches: [main]
branches: [ main ]
paths:
- "**.sh"
- "**.bash"
Expand Down Expand Up @@ -67,9 +67,6 @@ jobs:
- name: Test
env:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
# TODO: https://github.com/dagger/dagger/pull/1341
# DAGGER_CACHE_TO: "type=gha,mode=max,scope=test-integration"
# DAGGER_CACHE_FROM: "type=gha,mode=max,scope=test-integration"
run: |
env
make core-integration
make core-integration
3 changes: 0 additions & 3 deletions .github/workflows/test-universe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,5 @@ jobs:
uses: crazy-max/ghaction-github-runtime@v1

- name: Test
env:
DAGGER_CACHE_TO: "type=gha,mode=max,scope=test-universe"
DAGGER_CACHE_FROM: "type=gha,mode=max,scope=test-universe"
run: |
make universe-test
29 changes: 29 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# CODEOWNERS is a tool to encode PR approval rules.
#
# When a PR is opened, at least one code owner is required to approve it
# before being merged.
#
# It does **not**:
#
# - Limit reviewers: Everyone is welcome and encouraged to review any PR.
# But at least one CODEOWNER must approve before merging.
#
# - Limit contributions or ownership: Every maintainer is responsible for
# the entire project. CODEOWNERs are there to review PRs for
# consistency.
#
# By default, any maintainer can approve any PR. There's a couple of
# exceptions for consistency/specialty.

# Default owners for everything in the repo
# Later matches takes precedence
* @dagger/maintainers

# Core CUE API
/pkg/dagger.io/ @helderco @shykes

# Universe
/pkg/universe.dagger.io/ @helderco @shykes

# Documentation website
/website/ @slumbering
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ web: # Run the website locally

.PHONY: todo
todo: # Find all TODO items
grep -r -A 1 "TODO:" $(CURDIR)
grep -r -A 1 "TODO:" $(CURDIR)
44 changes: 29 additions & 15 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"sync"

"github.com/containerd/containerd/platforms"
"github.com/google/uuid"
"go.opentelemetry.io/otel/trace"
"golang.org/x/sync/errgroup"

Expand All @@ -18,7 +18,6 @@ import (
// buildkit
bk "github.com/moby/buildkit/client"
_ "github.com/moby/buildkit/client/connhelper/dockercontainer" // import the container connection driver
"github.com/moby/buildkit/client/llb"
bkgw "github.com/moby/buildkit/frontend/gateway/client"
"github.com/moby/buildkit/session"

Expand Down Expand Up @@ -72,7 +71,7 @@ func New(ctx context.Context, host string, cfg Config) (*Client, error) {
}, nil
}

type DoFunc func(context.Context, solver.Solver) error
type DoFunc func(context.Context, *solver.Solver) error

// FIXME: return completed *Route, instead of *compiler.Value
func (c *Client) Do(ctx context.Context, pctx *plancontext.Context, fn DoFunc) error {
Expand All @@ -96,6 +95,19 @@ func (c *Client) Do(ctx context.Context, pctx *plancontext.Context, fn DoFunc) e
return eg.Wait()
}

func convertCacheOptionEntries(ims []bk.CacheOptionsEntry) []bkgw.CacheOptionsEntry {
convertIms := []bkgw.CacheOptionsEntry{}

for _, im := range ims {
convertIm := bkgw.CacheOptionsEntry{
Type: im.Type,
Attrs: im.Attrs,
}
convertIms = append(convertIms, convertIm)
}
return convertIms
}

func (c *Client) buildfn(ctx context.Context, pctx *plancontext.Context, fn DoFunc, ch chan *bk.SolveStatus) error {
wg := sync.WaitGroup{}

Expand Down Expand Up @@ -156,29 +168,31 @@ func (c *Client) buildfn(ctx context.Context, pctx *plancontext.Context, fn DoFu

resp, err := c.c.Build(ctx, opts, "", func(ctx context.Context, gw bkgw.Client) (*bkgw.Result, error) {
s := solver.New(solver.Opts{
Control: c.c,
Gateway: gw,
Events: eventsCh,
Auth: auth,
NoCache: c.cfg.NoCache,
Control: c.c,
Gateway: gw,
Events: eventsCh,
Auth: auth,
NoCache: c.cfg.NoCache,
CacheImports: convertCacheOptionEntries(opts.CacheImports),
})

// Close events channel
defer s.Stop()

// Compute output overlay
res := bkgw.NewResult()
if fn != nil {
if err := fn(ctx, s); err != nil {
err := fn(ctx, s)
if err != nil {
return nil, compiler.Err(err)
}
}

ref, err := s.Solve(ctx, llb.Scratch(), platforms.DefaultSpec())
if err != nil {
return nil, err
refs := s.References()
// Add functions layers
for _, ref := range refs {
res.AddRef(uuid.New().String(), ref)
}
}
res := bkgw.NewResult()
res.SetRef(ref)
return res, nil
}, buildCh)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/dagger/cmd/do.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var doCmd = &cobra.Command{
Value: target.String(),
})

err = cl.Do(ctx, p.Context(), func(ctx context.Context, s solver.Solver) error {
err = cl.Do(ctx, p.Context(), func(ctx context.Context, s *solver.Solver) error {
return p.Do(ctx, target, s)
})

Expand Down
6 changes: 3 additions & 3 deletions docs/1001-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ slug: /1001/install/

:::

## Option 1: Use Homebrew (Mac OS only)
## Option 1 (Mac OS and Linux): Use Homebrew

From your Mac OS terminal, run the following command:
From a terminal, run the following command:

```shell
brew install dagger/tap/dagger
Expand All @@ -25,7 +25,7 @@ brew update
brew upgrade dagger
```

## Option 2: Run a shell script
## Option 2 (Mac OS and Linux): Run a shell script

From a terminal, run the following command:

Expand Down
9 changes: 3 additions & 6 deletions docs/getting-started/1200-local-dev.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
slug: /
slug: /1200/local-dev
displayed_sidebar: europa
---

Expand Down Expand Up @@ -209,13 +209,10 @@ It becomes even more obvious when the change is not as straightforward as knowin

<TabItem value="windows">

We assume that you have [curl](https://curl.se/windows/) installed.
If you do, you can install `dagger` with a few commands. From a powershell terminal, run:
From a powershell terminal, run:

```shell
curl https://dl.dagger.io/dagger/install.ps1 -OutFile install.ps1
./install.ps1
rm install.ps1
Invoke-WebRequest -UseBasicParsing -Uri https://dl.dagger.io/dagger/install.ps1 | Invoke-Expression
```

We try to move the dagger binary under `C:\Windows\System32` but
Expand Down
47 changes: 47 additions & 0 deletions docs/getting-started/1220-vs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
slug: /1220/vs
displayed_sidebar: europa
---

# Dagger vs. Other Software

## Dagger vs. CI (Github Actions, Gitlab, CircleCI, Jenkins, etc.)

Dagger does not replace your CI: it improves it by adding a portable development layer on top of it.

* Dagger runs on all major CI products. This *reduces CI lock-in*: you can change CI without rewriting all your pipelines.
* Dagger also runs on your dev machine. This allows *dev/CI parity*: the same pipelines can be used in CI and development.

## Dagger vs. PaaS (Heroku, Firebase, etc.)

Dagger is not a PaaS, but you can use it to add PaaS-like features to your CICD pipelines:

* A simple deployment abstraction for the developer
* A catalog of possible customizations, managed by the platform team
* On-demand staging or development environments

Using Dagger is a good way to get many of the benefits of a PaaS (developer productivity and peace of mind),
without giving up the benefits of custom CICD pipelines (full control over your infrastructure and tooling).

## Dagger vs. artisanal deploy scripts

Most applications have a custom deploy script that usually gets the job done, but is painful to change and troubleshoot.

Using Dagger, you have two options:

1. You can *replace* your script with a DAG that is better in every way: more features, more reliable, faster, easier to read, improve, and debug.
2. You can *extend* your script by wrapping it, as-is, into a DAG. This allows you to start using Dagger right away, and worry about rewrites later.

## Dagger vs. Infrastructure as Code (Terraform, Pulumi, Cloudformation, CDK)

Dagger is the perfect complement to an IaC tool.

* IaC tools help infrastructure teams answer questions like: what is the current state of my infrastructure? What is its desired state? And how do I get there?
* Dagger helps CICD teams answer question like: what work needs to be done to deliver my application, in what order, and how do I orchestrate it?

It is very common for a Dagger configuration to integrate with at least one IaC tool.

## Dagger vs. Build Systems (Make, Maven, Bazel, Npm/Yarn, Docker Build, etc.)

Dagger is complementary to build systems. Most Dagger configurations involve integrating with at least one specialized build.
If several build systems are involved, Dagger helps integrate them into a unified graph.
15 changes: 15 additions & 0 deletions docs/getting-started/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
slug: /
displayed_sidebar: europa
---

# Getting Started

```mdx-code-block
import DocCardList from '@theme/DocCardList';
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
Run your CI/CD pipelines locally, then easily integrate them with any CI environment.
<DocCardList items={useCurrentSidebarCategory().items}/>
```
6 changes: 6 additions & 0 deletions docs/learn/tests/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ common_setup() {
export DAGGER_SANDBOX
dagger init --project "$DAGGER_SANDBOX"

if [ -n "$GITHUB_ACTIONS" ];
then
export DAGGER_CACHE_TO="type=gha,mode=max,scope=docs-tests-$BATS_TEST_NAME"
export DAGGER_CACHE_FROM="type=gha,scope=docs-tests-$BATS_TEST_NAME"
fi

# allows the use of `sops`
SOPS_AGE_KEY_FILE=~/.config/dagger/keys.txt
export SOPS_AGE_KEY_FILE
Expand Down
2 changes: 1 addition & 1 deletion docs/tests/core-concepts/plan/structure.cue.fragment
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ...
// A plan has pre-requisited that we cover below.
// A plan has pre-requisites that we cover below.
// For now we focus on the dagger.#Plan structure.
// ...

Expand Down

0 comments on commit 12c7a41

Please sign in to comment.