Skip to content

Commit

Permalink
Merge pull request #30 from aluzzardi/europa-update
Browse files Browse the repository at this point in the history
update action to dagger 0.2
  • Loading branch information
aluzzardi authored Mar 9, 2022
2 parents 64f8bd9 + 24d6bfd commit d384192
Show file tree
Hide file tree
Showing 96 changed files with 15,028 additions and 70 deletions.
35 changes: 5 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,25 @@ on:
pull_request:

jobs:
version:
do:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version:
- latest
- 0.1.0-alpha.31
- 0.2.0-beta.1
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Init env
run: |
mkdir -p ~/.config/dagger
cp ./test/keys.txt ~/.config/dagger/
-
name: Dagger
uses: ./
with:
version: ${{ matrix.version }}
args: up --no-cache
workdir: ./test

age-secret:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Dagger
uses: ./
with:
age-key: ${{ secrets.DAGGER_AGE_KEY_TEST }}
args: up --no-cache
workdir: ./test
args: do test
workdir: ./test/ci

install-only:
runs-on: ubuntu-latest
Expand All @@ -59,16 +39,11 @@ jobs:
matrix:
version:
- latest
- 0.1.0-alpha.17
- 0.2.0-beta.1
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Init env
run: |
mkdir ~/.config/dagger
cp ./test/keys.txt ~/.config/dagger/
-
name: Dagger
uses: ./
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ jobs:
name: Dagger
uses: dagger/dagger-for-github@v1
with:
age-key: ${{ secrets.DAGGER_AGE_KEY }}
args: up
args: do test
```
### Install Only
Expand All @@ -70,7 +69,6 @@ Following inputs can be used as `step.with` keys
| Name | Type | Default | Description |
|------------------|---------|--------------|------------------------------------------------------------------|
| `version` | String | `latest` | Dagger version |
| `age-key` | String | | Dagger private key |
| `args` | String | | Arguments to pass to Dagger |
| `workdir` | String | `.` | Working directory (below repository root) |
| `install-only` | Bool | `false` | Just install Dagger |
Expand Down
3 changes: 0 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ inputs:
description: 'Dagger version'
default: 'latest'
required: false
age-key:
description: 'Dagger private key'
required: false
args:
description: 'Arguments to pass to Dagger'
required: false
Expand Down
9 changes: 0 additions & 9 deletions dist/index.js

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

2 changes: 0 additions & 2 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as core from '@actions/core';

export interface Inputs {
version: string;
ageKey: string;
workdir: string;
args: string;
installOnly: boolean;
Expand All @@ -12,7 +11,6 @@ export interface Inputs {
export async function getInputs(): Promise<Inputs> {
return {
version: core.getInput('version') || 'latest',
ageKey: core.getInput('age-key'),
workdir: core.getInput('workdir') || '.',
args: core.getInput('args'),
installOnly: core.getBooleanInput('install-only'),
Expand Down
9 changes: 0 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ async function run(): Promise<void> {
throw new Error('args input required');
}

if (inputs.ageKey) {
await core.group(`Import Dagger private key`, async () => {
if (!fs.existsSync(path.join(os.homedir(), '.config', 'dagger'))) {
fs.mkdirSync(path.join(os.homedir(), '.config', 'dagger'), {recursive: true});
}
await fs.writeFileSync(path.join(os.homedir(), '.config', 'dagger', 'keys.txt'), inputs.ageKey);
});
}

if (inputs.workdir && inputs.workdir !== '.') {
core.info(`Using ${inputs.workdir} as working directory`);
process.chdir(inputs.workdir);
Expand Down
21 changes: 14 additions & 7 deletions test/ci/main.cue
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
package main

import (
"alpha.dagger.io/docker"
"alpha.dagger.io/git"
"dagger.io/dagger"

"universe.dagger.io/alpine"
"universe.dagger.io/bash"
)

ctr: docker.#Build & {
source: git.#Repository & {
remote: "https://github.com/crazy-max/docker-fail2ban.git"
ref: "refs/tags/0.11.2-r3"
keepGitDir: true
dagger.#Plan & {
actions: test: {
image: alpine.#Build & {
packages: bash: {}
}

bash.#Run & {
input: image.output
script: contents: "echo Hello World!"
}
}
}
1 change: 1 addition & 0 deletions test/cue.mod/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkg/** linguist-vendored
2 changes: 1 addition & 1 deletion test/cue.mod/module.cue
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module: ""
module: ""
3 changes: 0 additions & 3 deletions test/cue.mod/pkg/.gitignore

This file was deleted.

1 change: 1 addition & 0 deletions test/cue.mod/pkg/dagger.io/cue.mod/module.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module: "dagger.io"
81 changes: 81 additions & 0 deletions test/cue.mod/pkg/dagger.io/dagger/exec.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package dagger

// Execute a command in a container
#Exec: {
$dagger: task: _name: "Exec"

// Container filesystem
input: #FS

// Transient filesystem mounts
// Key is an arbitrary name, for example "app source code"
// Value is mount configuration
mounts: [name=string]: #Mount

// Command to execute
// Example: ["echo", "hello, world!"]
args: [...string]

// Environment variables
env: [key=string]: string | #Secret

// Working directory
workdir: string | *"/"

// User ID or name
user: string | *"root"

// If set, always execute even if the operation could be cached
always: true | *false

// Inject hostname resolution into the container
// key is hostname, value is IP
hosts: [hostname=string]: string

// Modified filesystem
output: #FS

// Command exit code
// Currently this field can only ever be zero.
// If the command fails, DAG execution is immediately terminated.
// FIXME: expand API to allow custom handling of failed commands
exit: int & 0
}

// A transient filesystem mount.
#Mount: {
dest: string
type: string
{
type: "cache"
contents: #CacheDir
} | {
type: "tmp"
contents: #TempDir
} | {
type: "service"
contents: #Service
} | {
type: "fs"
contents: #FS
source?: string
ro?: true | *false
} | {
type: "secret"
contents: #Secret
uid: int | *0
gid: int | *0
mask: int | *0o400
}
}

// A (best effort) persistent cache dir
#CacheDir: {
id: string
concurrency: *"shared" | "private" | "locked"
}

// A temporary directory for command execution
#TempDir: {
size: int64 | *0
}
118 changes: 118 additions & 0 deletions test/cue.mod/pkg/dagger.io/dagger/fs.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package dagger

// Access the source directory for the current CUE package
// This may safely be called from any package
#Source: {
$dagger: task: _name: "Source"

// Relative path to source.
path: string
// Optionally exclude certain files
include: [...string]
// Optionally include certain files
exclude: [...string]

output: #FS
}

// Create one or multiple directory in a container
#Mkdir: {
$dagger: task: _name: "Mkdir"

// Container filesystem
input: #FS

// Path of the directory to create
// It can be nested (e.g : "/foo" or "/foo/bar")
path: string

// Permissions of the directory
permissions: *0o755 | int

// If set, it creates parents' directory if they do not exist
parents: *true | false

// Modified filesystem
output: #FS
}

#ReadFile: {
$dagger: task: _name: "ReadFile"

// Filesystem tree holding the file
input: #FS
// Path of the file to read
path: string
// Contents of the file
contents: string
}

// Write a file to a filesystem tree, creating it if needed
#WriteFile: {
$dagger: task: _name: "WriteFile"

// Input filesystem tree
input: #FS
// Path of the file to write
path: string
// Contents to write
contents: string
// Permissions of the file
permissions: *0o600 | int
// Output filesystem tree
output: #FS
}

// Copy files from one FS tree to another
#Copy: {
$dagger: task: _name: "Copy"
// Input of the operation
input: #FS
// Contents to copy
contents: #FS
// Source path (optional)
source: string | *"/"
// Destination path (optional)
dest: string | *"/"
// Output of the operation
output: #FS
}

#CopyInfo: {
source: {
root: #FS
path: string | *"/"
}
dest: string
}

// Merge multiple FS trees into one
#Merge: {
@dagger(notimplemented)
$dagger: task: _name: "Merge"

input: #FS
layers: [...#CopyInfo]
output: #FS
}

// Select a subdirectory from a filesystem tree
#Subdir: {
// Input tree
input: #FS

// Path of the subdirectory
// Example: "/build"
path: string

// Copy action
_copy: #Copy & {
"input": #Scratch
contents: input
source: path
dest: "/"
}

// Subdirectory tree
output: #FS & _copy.output
}
Loading

0 comments on commit d384192

Please sign in to comment.