diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index 530dab46..75d008f9 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -6,17 +6,18 @@ on: - main jobs: - call-function: - name: Call function + run-workflow: + name: Run Workflow runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Dagger - uses: dagger/dagger-for-github@v7 + uses: dagger/dagger-for-github@8.0.0 with: + version: 0.18.9 verb: functions - workdir: ./etc/runner + workdir: ./etc/workflow-runtime - name: Setup Node.js uses: actions/setup-node@v4 @@ -26,8 +27,8 @@ jobs: - name: Install dependencies run: yarn install - - name: Call script - working-directory: ./etc/scripts/pipelines + - name: Run workflow + working-directory: ./etc/scripts/workflows run: ./release.ts env: MODE: dev diff --git a/.github/workflows/release-prod.yml b/.github/workflows/release-prod.yml index 129c25ac..05b869ef 100644 --- a/.github/workflows/release-prod.yml +++ b/.github/workflows/release-prod.yml @@ -6,17 +6,18 @@ on: - v*.*.* jobs: - call-function: - name: Call function + run-workflow: + name: Run Workflow runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Dagger - uses: dagger/dagger-for-github@v7 + uses: dagger/dagger-for-github@8.0.0 with: + version: 0.18.9 verb: functions - workdir: ./etc/runner + workdir: ./etc/workflow-runtime - name: Setup Node.js uses: actions/setup-node@v4 @@ -26,8 +27,8 @@ jobs: - name: Install dependencies run: yarn install - - name: Call script - working-directory: ./etc/scripts/pipelines + - name: Run workflow + working-directory: ./etc/scripts/workflows run: ./release.ts env: MODE: prod diff --git a/.github/workflows/release-stg.yml b/.github/workflows/release-stg.yml index c3c23822..dfeb38a4 100644 --- a/.github/workflows/release-stg.yml +++ b/.github/workflows/release-stg.yml @@ -6,17 +6,18 @@ on: - release-* jobs: - call-function: - name: Call function + run-workflow: + name: Run Workflow runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Dagger - uses: dagger/dagger-for-github@v7 + uses: dagger/dagger-for-github@8.0.0 with: + version: 0.18.9 verb: functions - workdir: ./etc/runner + workdir: ./etc/workflow-runtime - name: Setup Node.js uses: actions/setup-node@v4 @@ -26,8 +27,8 @@ jobs: - name: Install dependencies run: yarn install - - name: Call script - working-directory: ./etc/scripts/pipelines + - name: Run workflow + working-directory: ./etc/scripts/workflows run: ./release.ts env: MODE: stg diff --git a/.github/workflows/validate-pr.yml b/.github/workflows/validate-pr.yml index c5c5eb4c..b49abe51 100644 --- a/.github/workflows/validate-pr.yml +++ b/.github/workflows/validate-pr.yml @@ -6,17 +6,18 @@ on: - main jobs: - call-function: - name: Call function + run-workflow: + name: Run Workflow runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Dagger - uses: dagger/dagger-for-github@v7 + uses: dagger/dagger-for-github@8.0.0 with: + version: 0.18.9 verb: functions - workdir: ./etc/runner + workdir: ./etc/workflow-runtime - name: Setup Node.js uses: actions/setup-node@v4 @@ -26,6 +27,6 @@ jobs: - name: Install dependencies run: yarn install - - name: Call script - working-directory: ./etc/scripts/pipelines + - name: Run workflow + working-directory: ./etc/scripts/workflows run: ./validate-pr.ts diff --git a/.gitignore b/.gitignore index 0e1f8cb7..1334c88c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,15 @@ -node_modules/ +# General .cache/ +.tmp/ +*.local.* + +# OS .DS_Store -# Yarn +# Node.js +node_modules/ + +## Yarn .yarn/* !.yarn/cache !.yarn/patches @@ -10,12 +17,12 @@ node_modules/ !.yarn/releases !.yarn/sdks !.yarn/versions + # moon .moon/cache .moon/docker +# Repo specific public/ - target/ - dist/ \ No newline at end of file diff --git a/.moon/workspace.yml b/.moon/workspace.yml index c744e845..d07c3b54 100644 --- a/.moon/workspace.yml +++ b/.moon/workspace.yml @@ -28,3 +28,7 @@ vcs: # local branch against. For git, this is is typically "master" or "main", # and must include the remote prefix (before /). defaultBranch: main + +generator: + templates: + - ./etc/templates diff --git a/.prototools b/.prototools index 0c5081d4..4f6658f4 100644 --- a/.prototools +++ b/.prototools @@ -1,9 +1,9 @@ -dagger = "^0.15.1" -go = "^1.23.4" -moon = "^1.31.1" -node = "^22.13.0" -yarn = "^4.6.0" -rust = "^1.81.0" +dagger = "^0" +go = "^1" +moon = "^1" +node = "^22" +yarn = "^4" +rust = "^1" [plugins] dagger = "source:https://raw.githubusercontent.com/Phault/proto-toml-plugins/main/dagger/plugin.toml" diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz index 8efa9c45..bbfe8259 100644 Binary files a/.yarn/install-state.gz and b/.yarn/install-state.gz differ diff --git a/README.md b/README.md index 0f63cc47..5b450f0d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +[![Release Dev](https://github.com/ndthanhdev/ndthanhdev.github.io/actions/workflows/release-dev.yml/badge.svg)](https://github.com/ndthanhdev/ndthanhdev.github.io/actions/workflows/release-dev.yml) +[![Release Stg](https://github.com/ndthanhdev/ndthanhdev.github.io/actions/workflows/release-stg.yml/badge.svg)](https://github.com/ndthanhdev/ndthanhdev.github.io/actions/workflows/release-stg.yml) +[![Release Prod](https://github.com/ndthanhdev/ndthanhdev.github.io/actions/workflows/release-prod.yml/badge.svg)](https://github.com/ndthanhdev/ndthanhdev.github.io/actions/workflows/release-prod.yml) + Welcome to my personal website repository! This repository contains the source code and content for my personal website, where I share posts on tech and life and experiment with various technologies. - [Website URL](#website-url) diff --git a/apps/app/content/posts/personal-website/dagger-io/dagger-io.mdx b/apps/app/content/posts/personal-website/dagger-io/dagger-io.mdx index 00c6ec4f..c5ee782d 100644 --- a/apps/app/content/posts/personal-website/dagger-io/dagger-io.mdx +++ b/apps/app/content/posts/personal-website/dagger-io/dagger-io.mdx @@ -70,8 +70,8 @@ func (m *NdthanhdevGithubIo) Init(ctx context.Context, dir *Directory) *Containe Container(). From("node:lts"). WithExec([]string{"yarn", "global", "add", "tsx"}). - WithMountedDirectory("/mnt", source). - WithWorkdir("/mnt"). + WithMountedDirectory("/workspace", source). + WithWorkdir("/workspace"). WithExec([]string{"yarn", "install", "--immutable"}) } ``` diff --git a/docs/guidelines.md b/docs/guidelines.md index 57377a9a..22f30b13 100644 --- a/docs/guidelines.md +++ b/docs/guidelines.md @@ -4,8 +4,8 @@ - `app/`: My personal website. - `packages/`: Contains all the `packages` that are used in the `apps` or `packages`. - `etc/`: Contains everything else grouped by `type`. - - `runner/`: Contains `functions` that run an `pipeline` under `etc/scripts/pipelines/` inside `dagger` container. + - `workflow-runtime/`: Provide runtime and utils to run `etc/scripts/workflows/`. - `scripts/` - `utils/`: Contains utility modules for reuse in other scripts. - - `actions/`: Contains the main scripts that perform small tasks should be able to run independently. Requires `tsx` to be installed - - `pipelines/`: Contains the main scripts that run a series of `dagger functions`. Requires `dagger` && `tsx` to be installed. + - `actions/`: Contains scripts that perform small tasks should be able to run independently. Requires `tsx` to be installed + - `workflows/`: Contains scripts that run a series of `actions` inside `workflow-runtime` diff --git a/etc/runner/dagger.json b/etc/runner/dagger.json deleted file mode 100644 index a9635bbc..00000000 --- a/etc/runner/dagger.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "runner", - "engineVersion": "v0.15.1", - "sdk": "go", - "source": "src" -} diff --git a/etc/runner/src/con.go b/etc/runner/src/con.go deleted file mode 100644 index cb6b81aa..00000000 --- a/etc/runner/src/con.go +++ /dev/null @@ -1,32 +0,0 @@ -package main - -import ( - "context" - "dagger/runner/internal/dagger" - "fmt" -) - -type Con struct { - *dagger.Container -} - -func (c *Con) SetEnvs(ctx context.Context, m *Runner) *Con { - c.Container = c.Container. - WithEnvVariable("MODE", m.Mode) - - if m.GhToken != nil { - tokenString, _ := m.GhToken.Plaintext(ctx) - - c.Container = c. - WithEnvVariable("GH_TOKEN", tokenString) - } - - return c -} - -func (c *Con) WithAction(action string) *Con { - c.Container = c. - Container. - WithExec([]string{"bash", "-l", "-c", fmt.Sprintf("./etc/scripts/actions/%s.ts", action)}) - return c -} diff --git a/etc/runner/src/go.mod b/etc/runner/src/go.mod deleted file mode 100644 index 664e4413..00000000 --- a/etc/runner/src/go.mod +++ /dev/null @@ -1,51 +0,0 @@ -module dagger/runner - -go 1.23.2 - -require ( - github.com/99designs/gqlgen v0.17.57 - github.com/Khan/genqlient v0.7.0 - github.com/vektah/gqlparser/v2 v2.5.19 - go.opentelemetry.io/otel v1.27.0 - go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 - go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 - go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0 - go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 - go.opentelemetry.io/otel/log v0.3.0 - go.opentelemetry.io/otel/metric v1.27.0 - go.opentelemetry.io/otel/sdk v1.27.0 - go.opentelemetry.io/otel/sdk/log v0.3.0 - go.opentelemetry.io/otel/sdk/metric v1.27.0 - go.opentelemetry.io/otel/trace v1.27.0 - go.opentelemetry.io/proto/otlp v1.3.1 - golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa - golang.org/x/sync v0.10.0 - google.golang.org/grpc v1.68.0 -) - -require ( - github.com/cenkalti/backoff/v4 v4.3.0 // indirect - github.com/go-logr/logr v1.4.2 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect - github.com/sosodev/duration v1.3.1 // indirect - github.com/stretchr/testify v1.10.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect - golang.org/x/net v0.29.0 // indirect - golang.org/x/sys v0.28.0 // indirect - golang.org/x/text v0.21.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect - google.golang.org/protobuf v1.35.2 // indirect -) - -replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 - -replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 - -replace go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.3.0 - -replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.3.0 diff --git a/etc/runner/src/go.sum b/etc/runner/src/go.sum deleted file mode 100644 index e5668044..00000000 --- a/etc/runner/src/go.sum +++ /dev/null @@ -1,85 +0,0 @@ -github.com/99designs/gqlgen v0.17.57 h1:Ak4p60BRq6QibxY0lEc0JnQhDurfhxA67sp02lMjmPc= -github.com/99designs/gqlgen v0.17.57/go.mod h1:Jx61hzOSTcR4VJy/HFIgXiQ5rJ0Ypw8DxWLjbYDAUw0= -github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w= -github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= -github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= -github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4= -github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/vektah/gqlparser/v2 v2.5.19 h1:bhCPCX1D4WWzCDvkPl4+TP1N8/kLrWnp43egplt7iSg= -github.com/vektah/gqlparser/v2 v2.5.19/go.mod h1:y7kvl5bBlDeuWIvLtA9849ncyvx6/lj06RsMrEjVy3U= -go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= -go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= -go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 h1:oM0GTNKGlc5qHctWeIGTVyda4iFFalOzMZ3Ehj5rwB4= -go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88/go.mod h1:JGG8ebaMO5nXOPnvKEl+DiA4MGwFjCbjsxT1WHIEBPY= -go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 h1:ccBrA8nCY5mM0y5uO7FT0ze4S0TuFcWdDB2FxGMTjkI= -go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0/go.mod h1:/9pb6634zi2Lk8LYg9Q0X8Ar6jka4dkFOylBLbVQPCE= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0 h1:bFgvUr3/O4PHj3VQcFEuYKvRZJX1SJDQ+11JXuSB3/w= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0/go.mod h1:xJntEd2KL6Qdg5lwp97HMLQDVeAhrYxmzFseAMDPQ8I= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0 h1:CIHWikMsN3wO+wq1Tp5VGdVRTcON+DmOJSfDjXypKOc= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0/go.mod h1:TNupZ6cxqyFEpLXAZW7On+mLFL0/g0TE3unIYL91xWc= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 h1:R9DE4kQ4k+YtfLI2ULwX82VtNQ2J8yZmA7ZIF/D+7Mc= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0/go.mod h1:OQFyQVrDlbe+R7xrEyDr/2Wr67Ol0hRUgsfA+V5A95s= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 h1:qFffATk0X+HD+f1Z8lswGiOQYKHRlzfmdJm0wEaVrFA= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0/go.mod h1:MOiCmryaYtc+V0Ei+Tx9o5S1ZjA7kzLucuVuyzBZloQ= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 h1:QY7/0NeRPKlzusf40ZE4t1VlMKbqSNT7cJRYzWuja0s= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0/go.mod h1:HVkSiDhTM9BoUJU8qE6j2eSWLLXvi1USXjyd2BXT8PY= -go.opentelemetry.io/otel/log v0.3.0 h1:kJRFkpUFYtny37NQzL386WbznUByZx186DpEMKhEGZs= -go.opentelemetry.io/otel/log v0.3.0/go.mod h1:ziCwqZr9soYDwGNbIL+6kAvQC+ANvjgG367HVcyR/ys= -go.opentelemetry.io/otel/metric v1.27.0 h1:hvj3vdEKyeCi4YaYfNjv2NUje8FqKqUY8IlF0FxV/ik= -go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak= -go.opentelemetry.io/otel/sdk v1.27.0 h1:mlk+/Y1gLPLn84U4tI8d3GNJmGT/eXe3ZuOXN9kTWmI= -go.opentelemetry.io/otel/sdk v1.27.0/go.mod h1:Ha9vbLwJE6W86YstIywK2xFfPjbWlCuwPtMkKdz/Y4A= -go.opentelemetry.io/otel/sdk/log v0.3.0 h1:GEjJ8iftz2l+XO1GF2856r7yYVh74URiF9JMcAacr5U= -go.opentelemetry.io/otel/sdk/log v0.3.0/go.mod h1:BwCxtmux6ACLuys1wlbc0+vGBd+xytjmjajwqqIul2g= -go.opentelemetry.io/otel/sdk/metric v1.27.0 h1:5uGNOlpXi+Hbo/DRoI31BSb1v+OGcpv2NemcCrOL8gI= -go.opentelemetry.io/otel/sdk/metric v1.27.0/go.mod h1:we7jJVrYN2kh3mVBlswtPU22K0SA+769l93J6bsyvqw= -go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw= -go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4= -go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= -go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= -golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= -golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= -golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 h1:hjSy6tcFQZ171igDaN5QHOw2n6vx40juYbC/x67CEhc= -google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:qpvKtACPCQhAdu3PyQgV4l3LMXZEtft7y8QcarRsp9I= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= -google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0= -google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA= -google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= -google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/etc/runner/src/main.go b/etc/runner/src/main.go deleted file mode 100644 index 71f8f0e8..00000000 --- a/etc/runner/src/main.go +++ /dev/null @@ -1,101 +0,0 @@ -// A generated module for Runner functions -// -// This module has been generated via dagger init and serves as a reference to -// basic module structure as you get started with Dagger. -// -// Two functions have been pre-created. You can modify, delete, or add to them, -// as needed. They demonstrate usage of arguments and return types using simple -// echo and grep commands. The functions can be called from the dagger CLI or -// from one of the SDKs. -// -// The first line in this comment block is a short description line and the -// rest is a long description with more detail on the module's purpose or usage, -// if appropriate. All modules should have a short description. - -package main - -import ( - "context" - "dagger/runner/internal/dagger" -) - -type Runner struct { - Dir *dagger.Directory - Mode string - GhToken *dagger.Secret -} - -func New( - // +required - // +ignore=["node_modules/", ".moon/cache/", "app/public/", "etc/runner/"] - dir *dagger.Directory, - // +optional - // +default="dev" - mode string, - // +optional - ghToken *dagger.Secret, -) *Runner { - return &Runner{ - Dir: dir, - Mode: mode, - GhToken: ghToken, - } -} - -func (m *Runner) BuildBaseEnv(ctx context.Context) *dagger.Container { - return dag. - Container(). - From("debian:bookworm"). - // apt-get update && apt-get install -y curl git unzip gzip xz-utils - WithExec([]string{"apt-get", "update"}). - WithExec([]string{"apt-get", "install", "-y", "build-essential", "curl", "git", "unzip", "bash", "gzip", "xz-utils"}). - // curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s 0.35.3 --yes - WithExec([]string{"bash", "-l", "-c", "curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s 0.44.1 --yes"}). - WithWorkdir("/mnt"). - WithFile("/mnt/.prototools", m.Dir.File(".prototools")). - // proto use - WithExec([]string{"bash", "-l", "-c", "proto use"}). - // rm .prototools - WithoutFile("/mnt/.prototools") - // use docker scaffold to optimize build time -} - -func (m *Runner) BuildEnv(ctx context.Context) *Con { - source := dag.Directory().WithDirectory("/", m.Dir, dagger.DirectoryWithDirectoryOpts{ - Exclude: []string{"node_modules", ".cache", ".moon/cache"}, - }) - - con := m.BuildBaseEnv(ctx). - WithMountedDirectory("/mnt", source). - // // moon setup - WithExec([]string{"bash", "-l", "-c", "moon setup"}). - // yarn install --immutable - WithExec([]string{"bash", "-l", "-c", "yarn install --immutable"}) - - return (&Con{con}).SetEnvs(ctx, m) -} - -func (m *Runner) WithAction(ctx context.Context, command string) *dagger.Container { - return m. - BuildEnv(ctx). - WithAction(command). - Container -} - -func (m *Runner) Test(ctx context.Context) (string, error) { - return m. - WithAction(ctx, "test"). - Stdout(ctx) -} - -func (m *Runner) Build(ctx context.Context) *dagger.Directory { - return m. - WithAction(ctx, "build"). - Directory("/mnt/apps/app/public") -} - -func (m *Runner) Publish(ctx context.Context) (string, error) { - return m. - WithAction(ctx, "publish"). - Stdout(ctx) -} diff --git a/etc/scripts/pipelines/release.ts b/etc/scripts/pipelines/release.ts deleted file mode 100755 index 1d6225c1..00000000 --- a/etc/scripts/pipelines/release.ts +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env -S yarn dlx tsx -import "zx/globals"; -import { cleanBuild } from "@n8v/scripts/utils/clean-build"; -import { workDirs } from "@n8v/scripts/utils/work-dir"; - -$.verbose = true; - -await cleanBuild(); - -cd(workDirs.etc.runner.path); - -await $`dagger call \ ---dir ${workDirs.path} \ ---mode ${$.env.MODE ?? "dev"} \ -build \ -export --path ${workDirs.apps.app.public.path} \ -`; - -await $`dagger call \ ---dir ${workDirs.path} \ ---mode ${$.env.MODE ?? "dev"} \ ---gh-token env:GH_TOKEN \ -publish \ -`; diff --git a/etc/scripts/utils/work-dir.ts b/etc/scripts/utils/work-dir.ts index eaae76cb..82cd056a 100755 --- a/etc/scripts/utils/work-dir.ts +++ b/etc/scripts/utils/work-dir.ts @@ -9,7 +9,7 @@ const apps = path.resolve(root, "apps"); const etc = path.resolve(root, "etc"); const app = path.resolve(apps, "app"); const counter = path.resolve(apps, "counter"); -const runner = path.resolve(etc, "runner"); +const workflowRuntime = path.resolve(etc, "workflow-runtime"); const scripts = path.resolve(etc, "scripts"); // eslint-disable-next-line unicorn/prevent-abbreviations @@ -38,12 +38,12 @@ export const workDirs = { etc: { path: etc, - runner: { - path: runner, - }, scripts: { path: scripts, }, + workflowRuntime: { + path: workflowRuntime, + }, }, path: root, }; diff --git a/etc/scripts/workflows/release.ts b/etc/scripts/workflows/release.ts new file mode 100755 index 00000000..918a4d98 --- /dev/null +++ b/etc/scripts/workflows/release.ts @@ -0,0 +1,31 @@ +#!/usr/bin/env -S yarn dlx tsx +import "zx/globals"; +import { cleanBuild } from "@n8v/scripts/utils/clean-build"; +import { workDirs } from "@n8v/scripts/utils/work-dir"; + +$.verbose = true; + +await cleanBuild(); + +cd(workDirs.etc.workflowRuntime.path); + +await $`${[ + "dagger", + "call", + "--dir", + workDirs.path, + "--mode", + $.env.MODE ?? "dev", + "--gh-token", + "env:GH_TOKEN", + "with-action", + "--action", + "build", + "with-action", + "publish", + "container", + "directory", + "export", + "--path", + workDirs.apps.app.public.path, +]}`; diff --git a/etc/scripts/pipelines/validate-pr.ts b/etc/scripts/workflows/validate-pr.ts similarity index 50% rename from etc/scripts/pipelines/validate-pr.ts rename to etc/scripts/workflows/validate-pr.ts index bc26a6c2..3a382d33 100755 --- a/etc/scripts/pipelines/validate-pr.ts +++ b/etc/scripts/workflows/validate-pr.ts @@ -7,8 +7,19 @@ $.verbose = true; await cleanBuild(); -cd(workDirs.etc.runner.path); +cd(workDirs.etc.workflowRuntime.path); -await $`dagger call --dir ${workDirs.path} test`; - -await $`dagger call --dir ${workDirs.path} build`; +await $`${[ + "dagger", + "call", + "--dir", + workDirs.path, + "build-env", + "with-action", + "--action", + "test", + "with-action", + "--action", + "build", + "stdout", +]}`; diff --git a/etc/templates/skeleton/etc/workflow-runtime/dagger.json b/etc/templates/skeleton/etc/workflow-runtime/dagger.json new file mode 100644 index 00000000..be3ca08f --- /dev/null +++ b/etc/templates/skeleton/etc/workflow-runtime/dagger.json @@ -0,0 +1,8 @@ +{ + "name": "workflow-runtime", + "engineVersion": "v0.18.9", + "sdk": { + "source": "go" + }, + "source": "src" +} diff --git a/etc/runner/moon.yml b/etc/templates/skeleton/etc/workflow-runtime/moon.yml similarity index 80% rename from etc/runner/moon.yml rename to etc/templates/skeleton/etc/workflow-runtime/moon.yml index fa7e3bb1..acf9ee99 100644 --- a/etc/runner/moon.yml +++ b/etc/templates/skeleton/etc/workflow-runtime/moon.yml @@ -1,2 +1,3 @@ # yaml-language-server: $schema: 'https://moonrepo.dev/schemas/project.json' type: tool +id: workflow-runtime diff --git a/etc/templates/skeleton/etc/workflow-runtime/src/go.mod b/etc/templates/skeleton/etc/workflow-runtime/src/go.mod new file mode 100644 index 00000000..f182fa95 --- /dev/null +++ b/etc/templates/skeleton/etc/workflow-runtime/src/go.mod @@ -0,0 +1,50 @@ +module dagger/workflow_runtime + +go 1.24.3 + +require ( + github.com/99designs/gqlgen v0.17.73 + github.com/Khan/genqlient v0.8.1 + github.com/vektah/gqlparser/v2 v2.5.27 + go.opentelemetry.io/otel v1.34.0 + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0 + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.8.0 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.32.0 + go.opentelemetry.io/otel/log v0.8.0 + go.opentelemetry.io/otel/metric v1.34.0 + go.opentelemetry.io/otel/sdk v1.34.0 + go.opentelemetry.io/otel/sdk/log v0.8.0 + go.opentelemetry.io/otel/sdk/metric v1.34.0 + go.opentelemetry.io/otel/trace v1.34.0 + go.opentelemetry.io/proto/otlp v1.3.1 + golang.org/x/sync v0.14.0 + google.golang.org/grpc v1.72.1 +) + +require ( + github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect + github.com/sosodev/duration v1.3.1 // indirect + go.opentelemetry.io/auto/sdk v1.1.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 // indirect + golang.org/x/net v0.40.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/text v0.25.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect + google.golang.org/protobuf v1.36.6 // indirect +) + +replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0 + +replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.8.0 + +replace go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.8.0 + +replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.8.0 diff --git a/etc/templates/skeleton/etc/workflow-runtime/src/go.sum b/etc/templates/skeleton/etc/workflow-runtime/src/go.sum new file mode 100644 index 00000000..73a28981 --- /dev/null +++ b/etc/templates/skeleton/etc/workflow-runtime/src/go.sum @@ -0,0 +1,85 @@ +github.com/99designs/gqlgen v0.17.73 h1:A3Ki+rHWqKbAOlg5fxiZBnz6OjW3nwupDHEG15gEsrg= +github.com/99designs/gqlgen v0.17.73/go.mod h1:2RyGWjy2k7W9jxrs8MOQthXGkD3L3oGr0jXW3Pu8lGg= +github.com/Khan/genqlient v0.8.1 h1:wtOCc8N9rNynRLXN3k3CnfzheCUNKBcvXmVv5zt6WCs= +github.com/Khan/genqlient v0.8.1/go.mod h1:R2G6DzjBvCbhjsEajfRjbWdVglSH/73kSivC9TLWVjU= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 h1:ad0vkEBuk23VJzZR9nkLVG0YAoN9coASF1GusYX6AlU= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0/go.mod h1:igFoXX2ELCW06bol23DWPB5BEWfZISOzSP5K2sbLea0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4= +github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/vektah/gqlparser/v2 v2.5.27 h1:RHPD3JOplpk5mP5JGX8RKZkt2/Vwj/PZv0HxTdwFp0s= +github.com/vektah/gqlparser/v2 v2.5.27/go.mod h1:D1/VCZtV3LPnQrcPBeR/q5jkSQIPti0uYCP/RI0gIeo= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= +go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0 h1:WzNab7hOOLzdDF/EoWCt4glhrbMPVMOO5JYTmpz36Ls= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0/go.mod h1:hKvJwTzJdp90Vh7p6q/9PAOd55dI6WA6sWj62a/JvSs= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.8.0 h1:S+LdBGiQXtJdowoJoQPEtI52syEP/JYBUpjO49EQhV8= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.8.0/go.mod h1:5KXybFvPGds3QinJWQT7pmXf+TN5YIa7CNYObWRkj50= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0 h1:j7ZSD+5yn+lo3sGV69nW04rRR0jhYnBwjuX3r0HvnK0= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0/go.mod h1:WXbYJTUaZXAbYd8lbgGuvih0yuCfOFC5RJoYnoLcGz8= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0 h1:t/Qur3vKSkUCcDVaSumWF2PKHt85pc7fRvFuoVT8qFU= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0/go.mod h1:Rl61tySSdcOJWoEgYZVtmnKdA0GeKrSqkHC1t+91CH8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 h1:IJFEoHiytixx8cMiVAO+GmHR6Frwu+u5Ur8njpFO6Ac= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0/go.mod h1:3rHrKNtLIoS0oZwkY2vxi+oJcwFRWdtUyRII+so45p8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0 h1:9kV11HXBHZAvuPUZxmMWrH8hZn/6UnHX4K0mu36vNsU= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0/go.mod h1:JyA0FHXe22E1NeNiHmVp7kFHglnexDQ7uRWDiiJ1hKQ= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.32.0 h1:cMyu9O88joYEaI47CnQkxO1XZdpoTF9fEnW2duIddhw= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.32.0/go.mod h1:6Am3rn7P9TVVeXYG+wtcGE7IE1tsQ+bP3AuWcKt/gOI= +go.opentelemetry.io/otel/log v0.8.0 h1:egZ8vV5atrUWUbnSsHn6vB8R21G2wrKqNiDt3iWertk= +go.opentelemetry.io/otel/log v0.8.0/go.mod h1:M9qvDdUTRCopJcGRKg57+JSQ9LgLBrwwfC32epk5NX8= +go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= +go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= +go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A= +go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= +go.opentelemetry.io/otel/sdk/log v0.8.0 h1:zg7GUYXqxk1jnGF/dTdLPrK06xJdrXgqgFLnI4Crxvs= +go.opentelemetry.io/otel/sdk/log v0.8.0/go.mod h1:50iXr0UVwQrYS45KbruFrEt4LvAdCaWWgIrsN3ZQggo= +go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= +go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= +go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= +go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= +go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= +go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= +golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= +google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a h1:nwKuGPlUAt+aR+pcrkfFRrTU1BVrSmYyYMxYbUIVHr0= +google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a/go.mod h1:3kWAYMk1I75K4vykHtKt2ycnOgpA6974V7bREqbsenU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ= +google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA= +google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= +google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= +google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/etc/templates/skeleton/etc/workflow-runtime/src/main.go b/etc/templates/skeleton/etc/workflow-runtime/src/main.go new file mode 100644 index 00000000..da067398 --- /dev/null +++ b/etc/templates/skeleton/etc/workflow-runtime/src/main.go @@ -0,0 +1,110 @@ +// A generated module for WorkflowRuntime functions +// +// This module has been generated via dagger init and serves as a reference to +// basic module structure as you get started with Dagger. +// +// Two functions have been pre-created. You can modify, delete, or add to them, +// as needed. They demonstrate usage of arguments and return types using simple +// echo and grep commands. The functions can be called from the dagger CLI or +// from one of the SDKs. +// +// The first line in this comment block is a short description line and the +// rest is a long description with more detail on the module's purpose or usage, +// if appropriate. All modules should have a short description. + +package main + +import ( + "context" + "dagger/workflow_runtime/internal/dagger" + "fmt" +) + +func New( + // +required + // +ignore=["node_modules/", ".moon/cache/", ".cache/"] + dir *dagger.Directory, + // +optional + // +default="dev" + mode string, + // +optional + ghToken *dagger.Secret, +) *WorkflowRuntime { + return &WorkflowRuntime{ + Dir: dir, + Mode: mode, + GhToken: ghToken, + } +} + +// Setup Proto +func (m *WorkflowRuntime) BuildBaseEnv(ctx context.Context) *WorkflowRuntime { + m.Con = dag. + Container(). + From("ubuntu:plucky"). + // apt-get update && apt-get install -y curl git unzip gzip xz-utils + WithExec([]string{"apt-get", "update"}). + WithExec([]string{"apt-get", "install", "-y", "build-essential", "curl", "git", "unzip", "bash", "gzip", "xz-utils"}). + // curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s 0.35.3 --yes + WithExec([]string{"bash", "-l", "-c", "curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s 0.44.1 --yes"}). + WithEnvVariable("PROTO_HOME", "/root/.proto", dagger.ContainerWithEnvVariableOpts{Expand: true}). + WithEnvVariable("PATH", "$PATH:$PROTO_HOME/shims:$PROTO_HOME/bin", dagger.ContainerWithEnvVariableOpts{Expand: true}) + + return m +} + +func (m *WorkflowRuntime) BuildEnv(ctx context.Context) *WorkflowRuntime { + source := dag.Directory().WithDirectory("/", m.Dir, dagger.DirectoryWithDirectoryOpts{ + Exclude: []string{"node_modules", ".cache", ".moon/cache"}, + }) + + m.Con = m.BuildBaseEnv(ctx). + Con. + WithWorkdir("/workspace"). + WithFile("/workspace/.prototools", m.Dir.File(".prototools")). + // proto use + WithExec([]string{"proto", "use"}). + // rm .prototools + WithoutFile("/workspace/.prototools"). + WithMountedDirectory("/workspace", source). + // moon setup + WithExec([]string{"moon", "setup"}). + // yarn install --immutable + WithExec([]string{"yarn", "install", "--immutable"}) + + m = m.setEnvs(ctx) + + return m +} + +func (m *WorkflowRuntime) WithAction(ctx context.Context, action string) *WorkflowRuntime { + m.Con = m.Con.WithExec([]string{"bash", "-l", "-c", fmt.Sprintf("./etc/scripts/actions/%s.ts", action)}) + + return m +} + +func (m *WorkflowRuntime) Container(ctx context.Context) *dagger.Container { + return m.Con +} + +func (m *WorkflowRuntime) Stdout(ctx context.Context) (string, error) { + stdout, err := m.Con.Stdout(ctx) + if err != nil { + return "", fmt.Errorf("failed to get stdout: %w", err) + } + return stdout, nil +} + +func (m *WorkflowRuntime) setEnvs(ctx context.Context) *WorkflowRuntime { + m.Con = m.Con. + WithEnvVariable("MODE", m.Mode) + + if m.GhToken != nil { + tokenString, _ := m.GhToken.Plaintext(ctx) + + m.Con = m.Con. + WithEnvVariable("GH_TOKEN", tokenString) + } + + return m +} diff --git a/etc/templates/skeleton/etc/workflow-runtime/src/workflow_runtime.go b/etc/templates/skeleton/etc/workflow-runtime/src/workflow_runtime.go new file mode 100644 index 00000000..68bbf71f --- /dev/null +++ b/etc/templates/skeleton/etc/workflow-runtime/src/workflow_runtime.go @@ -0,0 +1,10 @@ +package main + +import "dagger/workflow_runtime/internal/dagger" + +type WorkflowRuntime struct { + Dir *dagger.Directory + Mode string + GhToken *dagger.Secret + Con *dagger.Container +} diff --git a/etc/templates/skeleton/template.yml b/etc/templates/skeleton/template.yml new file mode 100644 index 00000000..ccd55385 --- /dev/null +++ b/etc/templates/skeleton/template.yml @@ -0,0 +1,7 @@ +$schema: "https://moonrepo.dev/schemas/template.json" + +id: skeleton +title: Monorepo Skeleton Template +description: | + This is a skeleton template for Moon monorepos. + It can be used as a starting point for new projects. diff --git a/etc/workflow-runtime/dagger.json b/etc/workflow-runtime/dagger.json new file mode 100644 index 00000000..be3ca08f --- /dev/null +++ b/etc/workflow-runtime/dagger.json @@ -0,0 +1,8 @@ +{ + "name": "workflow-runtime", + "engineVersion": "v0.18.9", + "sdk": { + "source": "go" + }, + "source": "src" +} diff --git a/etc/workflow-runtime/moon.yml b/etc/workflow-runtime/moon.yml new file mode 100644 index 00000000..acf9ee99 --- /dev/null +++ b/etc/workflow-runtime/moon.yml @@ -0,0 +1,3 @@ +# yaml-language-server: $schema: 'https://moonrepo.dev/schemas/project.json' +type: tool +id: workflow-runtime diff --git a/etc/runner/src/.gitattributes b/etc/workflow-runtime/src/.gitattributes similarity index 100% rename from etc/runner/src/.gitattributes rename to etc/workflow-runtime/src/.gitattributes diff --git a/etc/runner/src/.gitignore b/etc/workflow-runtime/src/.gitignore similarity index 100% rename from etc/runner/src/.gitignore rename to etc/workflow-runtime/src/.gitignore diff --git a/etc/workflow-runtime/src/go.mod b/etc/workflow-runtime/src/go.mod new file mode 100644 index 00000000..f182fa95 --- /dev/null +++ b/etc/workflow-runtime/src/go.mod @@ -0,0 +1,50 @@ +module dagger/workflow_runtime + +go 1.24.3 + +require ( + github.com/99designs/gqlgen v0.17.73 + github.com/Khan/genqlient v0.8.1 + github.com/vektah/gqlparser/v2 v2.5.27 + go.opentelemetry.io/otel v1.34.0 + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0 + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.8.0 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.32.0 + go.opentelemetry.io/otel/log v0.8.0 + go.opentelemetry.io/otel/metric v1.34.0 + go.opentelemetry.io/otel/sdk v1.34.0 + go.opentelemetry.io/otel/sdk/log v0.8.0 + go.opentelemetry.io/otel/sdk/metric v1.34.0 + go.opentelemetry.io/otel/trace v1.34.0 + go.opentelemetry.io/proto/otlp v1.3.1 + golang.org/x/sync v0.14.0 + google.golang.org/grpc v1.72.1 +) + +require ( + github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect + github.com/sosodev/duration v1.3.1 // indirect + go.opentelemetry.io/auto/sdk v1.1.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 // indirect + golang.org/x/net v0.40.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/text v0.25.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect + google.golang.org/protobuf v1.36.6 // indirect +) + +replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0 + +replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.8.0 + +replace go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.8.0 + +replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.8.0 diff --git a/etc/workflow-runtime/src/go.sum b/etc/workflow-runtime/src/go.sum new file mode 100644 index 00000000..73a28981 --- /dev/null +++ b/etc/workflow-runtime/src/go.sum @@ -0,0 +1,85 @@ +github.com/99designs/gqlgen v0.17.73 h1:A3Ki+rHWqKbAOlg5fxiZBnz6OjW3nwupDHEG15gEsrg= +github.com/99designs/gqlgen v0.17.73/go.mod h1:2RyGWjy2k7W9jxrs8MOQthXGkD3L3oGr0jXW3Pu8lGg= +github.com/Khan/genqlient v0.8.1 h1:wtOCc8N9rNynRLXN3k3CnfzheCUNKBcvXmVv5zt6WCs= +github.com/Khan/genqlient v0.8.1/go.mod h1:R2G6DzjBvCbhjsEajfRjbWdVglSH/73kSivC9TLWVjU= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 h1:ad0vkEBuk23VJzZR9nkLVG0YAoN9coASF1GusYX6AlU= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0/go.mod h1:igFoXX2ELCW06bol23DWPB5BEWfZISOzSP5K2sbLea0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4= +github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/vektah/gqlparser/v2 v2.5.27 h1:RHPD3JOplpk5mP5JGX8RKZkt2/Vwj/PZv0HxTdwFp0s= +github.com/vektah/gqlparser/v2 v2.5.27/go.mod h1:D1/VCZtV3LPnQrcPBeR/q5jkSQIPti0uYCP/RI0gIeo= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= +go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0 h1:WzNab7hOOLzdDF/EoWCt4glhrbMPVMOO5JYTmpz36Ls= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0/go.mod h1:hKvJwTzJdp90Vh7p6q/9PAOd55dI6WA6sWj62a/JvSs= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.8.0 h1:S+LdBGiQXtJdowoJoQPEtI52syEP/JYBUpjO49EQhV8= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.8.0/go.mod h1:5KXybFvPGds3QinJWQT7pmXf+TN5YIa7CNYObWRkj50= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0 h1:j7ZSD+5yn+lo3sGV69nW04rRR0jhYnBwjuX3r0HvnK0= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0/go.mod h1:WXbYJTUaZXAbYd8lbgGuvih0yuCfOFC5RJoYnoLcGz8= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0 h1:t/Qur3vKSkUCcDVaSumWF2PKHt85pc7fRvFuoVT8qFU= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.32.0/go.mod h1:Rl61tySSdcOJWoEgYZVtmnKdA0GeKrSqkHC1t+91CH8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 h1:IJFEoHiytixx8cMiVAO+GmHR6Frwu+u5Ur8njpFO6Ac= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0/go.mod h1:3rHrKNtLIoS0oZwkY2vxi+oJcwFRWdtUyRII+so45p8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0 h1:9kV11HXBHZAvuPUZxmMWrH8hZn/6UnHX4K0mu36vNsU= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0/go.mod h1:JyA0FHXe22E1NeNiHmVp7kFHglnexDQ7uRWDiiJ1hKQ= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.32.0 h1:cMyu9O88joYEaI47CnQkxO1XZdpoTF9fEnW2duIddhw= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.32.0/go.mod h1:6Am3rn7P9TVVeXYG+wtcGE7IE1tsQ+bP3AuWcKt/gOI= +go.opentelemetry.io/otel/log v0.8.0 h1:egZ8vV5atrUWUbnSsHn6vB8R21G2wrKqNiDt3iWertk= +go.opentelemetry.io/otel/log v0.8.0/go.mod h1:M9qvDdUTRCopJcGRKg57+JSQ9LgLBrwwfC32epk5NX8= +go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= +go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= +go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A= +go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= +go.opentelemetry.io/otel/sdk/log v0.8.0 h1:zg7GUYXqxk1jnGF/dTdLPrK06xJdrXgqgFLnI4Crxvs= +go.opentelemetry.io/otel/sdk/log v0.8.0/go.mod h1:50iXr0UVwQrYS45KbruFrEt4LvAdCaWWgIrsN3ZQggo= +go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= +go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= +go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= +go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= +go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= +go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= +golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= +google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a h1:nwKuGPlUAt+aR+pcrkfFRrTU1BVrSmYyYMxYbUIVHr0= +google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a/go.mod h1:3kWAYMk1I75K4vykHtKt2ycnOgpA6974V7bREqbsenU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ= +google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA= +google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= +google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= +google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/etc/workflow-runtime/src/main.go b/etc/workflow-runtime/src/main.go new file mode 100644 index 00000000..da067398 --- /dev/null +++ b/etc/workflow-runtime/src/main.go @@ -0,0 +1,110 @@ +// A generated module for WorkflowRuntime functions +// +// This module has been generated via dagger init and serves as a reference to +// basic module structure as you get started with Dagger. +// +// Two functions have been pre-created. You can modify, delete, or add to them, +// as needed. They demonstrate usage of arguments and return types using simple +// echo and grep commands. The functions can be called from the dagger CLI or +// from one of the SDKs. +// +// The first line in this comment block is a short description line and the +// rest is a long description with more detail on the module's purpose or usage, +// if appropriate. All modules should have a short description. + +package main + +import ( + "context" + "dagger/workflow_runtime/internal/dagger" + "fmt" +) + +func New( + // +required + // +ignore=["node_modules/", ".moon/cache/", ".cache/"] + dir *dagger.Directory, + // +optional + // +default="dev" + mode string, + // +optional + ghToken *dagger.Secret, +) *WorkflowRuntime { + return &WorkflowRuntime{ + Dir: dir, + Mode: mode, + GhToken: ghToken, + } +} + +// Setup Proto +func (m *WorkflowRuntime) BuildBaseEnv(ctx context.Context) *WorkflowRuntime { + m.Con = dag. + Container(). + From("ubuntu:plucky"). + // apt-get update && apt-get install -y curl git unzip gzip xz-utils + WithExec([]string{"apt-get", "update"}). + WithExec([]string{"apt-get", "install", "-y", "build-essential", "curl", "git", "unzip", "bash", "gzip", "xz-utils"}). + // curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s 0.35.3 --yes + WithExec([]string{"bash", "-l", "-c", "curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s 0.44.1 --yes"}). + WithEnvVariable("PROTO_HOME", "/root/.proto", dagger.ContainerWithEnvVariableOpts{Expand: true}). + WithEnvVariable("PATH", "$PATH:$PROTO_HOME/shims:$PROTO_HOME/bin", dagger.ContainerWithEnvVariableOpts{Expand: true}) + + return m +} + +func (m *WorkflowRuntime) BuildEnv(ctx context.Context) *WorkflowRuntime { + source := dag.Directory().WithDirectory("/", m.Dir, dagger.DirectoryWithDirectoryOpts{ + Exclude: []string{"node_modules", ".cache", ".moon/cache"}, + }) + + m.Con = m.BuildBaseEnv(ctx). + Con. + WithWorkdir("/workspace"). + WithFile("/workspace/.prototools", m.Dir.File(".prototools")). + // proto use + WithExec([]string{"proto", "use"}). + // rm .prototools + WithoutFile("/workspace/.prototools"). + WithMountedDirectory("/workspace", source). + // moon setup + WithExec([]string{"moon", "setup"}). + // yarn install --immutable + WithExec([]string{"yarn", "install", "--immutable"}) + + m = m.setEnvs(ctx) + + return m +} + +func (m *WorkflowRuntime) WithAction(ctx context.Context, action string) *WorkflowRuntime { + m.Con = m.Con.WithExec([]string{"bash", "-l", "-c", fmt.Sprintf("./etc/scripts/actions/%s.ts", action)}) + + return m +} + +func (m *WorkflowRuntime) Container(ctx context.Context) *dagger.Container { + return m.Con +} + +func (m *WorkflowRuntime) Stdout(ctx context.Context) (string, error) { + stdout, err := m.Con.Stdout(ctx) + if err != nil { + return "", fmt.Errorf("failed to get stdout: %w", err) + } + return stdout, nil +} + +func (m *WorkflowRuntime) setEnvs(ctx context.Context) *WorkflowRuntime { + m.Con = m.Con. + WithEnvVariable("MODE", m.Mode) + + if m.GhToken != nil { + tokenString, _ := m.GhToken.Plaintext(ctx) + + m.Con = m.Con. + WithEnvVariable("GH_TOKEN", tokenString) + } + + return m +} diff --git a/etc/workflow-runtime/src/workflow_runtime.go b/etc/workflow-runtime/src/workflow_runtime.go new file mode 100644 index 00000000..68bbf71f --- /dev/null +++ b/etc/workflow-runtime/src/workflow_runtime.go @@ -0,0 +1,10 @@ +package main + +import "dagger/workflow_runtime/internal/dagger" + +type WorkflowRuntime struct { + Dir *dagger.Directory + Mode string + GhToken *dagger.Secret + Con *dagger.Container +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 0193dee3..292fe499 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.83.0" +channel = "stable"