Skip to content

Commit 1dc7eaf

Browse files
committed
Merge branch 'main' into metabase
2 parents b1673ea + 65ce780 commit 1dc7eaf

File tree

652 files changed

+53990
-5951
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

652 files changed

+53990
-5951
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Trigger Docs Samples Rebuild
2+
3+
on:
4+
push:
5+
branches: main
6+
paths:
7+
- 'samples/**'
8+
9+
jobs:
10+
build-json:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Trigger CLI Autodoc
14+
uses: peter-evans/repository-dispatch@v1
15+
with:
16+
token: ${{ secrets.DOCS_ACTION_TRIGGER_TOKEN }}
17+
repository: defang-io/defang-docs
18+
event-type: sample-update

.github/workflows/check-sample.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Check Samples
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'samples/**'
7+
8+
jobs:
9+
check_samples:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
15+
- name: Check for required files
16+
run: |
17+
for changed_file in $(git diff --name-only HEAD^); do
18+
if [[ $changed_file == samples/* ]]; then
19+
sample_dir=$(dirname $changed_file)
20+
if [[ ! -f $sample_dir/README.md || ! -f $sample_dir/compose.yml ]]; then
21+
echo "Missing README.md or compose.yml in $sample_dir"
22+
exit 1
23+
fi
24+
fi
25+
done
26+
27+
- name: Add checklist to PR description
28+
uses: actions/github-script@v5
29+
with:
30+
script: |
31+
const pr_number = context.issue.number;
32+
const checklist = `
33+
- [ ] I have tested that the sample runs locally
34+
- [ ] I have tested that the sample runs in Defang Playground
35+
- [ ] I have tested that the sample runs in BYOC
36+
- [ ] I have documented any required config in the readme
37+
- [ ] I have documented how to provision any third-party services in the readme
38+
- [ ] I have documented how to run the sample in the readme (locally and with Defang)
39+
`;
40+
41+
// Get the current PR
42+
const { data: pullRequest } = await github.rest.pulls.get({
43+
owner: context.repo.owner,
44+
repo: context.repo.repo,
45+
pull_number: pr_number
46+
});
47+
48+
// Check if the checklist already exists in the PR description
49+
if (!pullRequest.body.includes(checklist)) {
50+
// Update the PR description with the checklist
51+
await github.rest.pulls.update({
52+
owner: context.repo.owner,
53+
repo: context.repo.repo,
54+
pull_number: pr_number,
55+
body: pullRequest.body + "\n" + checklist
56+
});
57+
}

.github/workflows/go.yml

Lines changed: 137 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ name: Go package
33
on:
44
push:
55
tags:
6-
- 'v*' # push events to tagged commits
6+
- "v*" # push events to tagged commits
77
branches:
8-
- '**'
9-
paths:
10-
- '.github/workflows/go.yml'
11-
- 'src/**'
8+
- "**"
9+
10+
permissions:
11+
contents: read
12+
id-token: write # for GitHub id-token auth
1213

1314
jobs:
1415
go-test:
@@ -22,17 +23,88 @@ jobs:
2223
go-version-file: src/go.mod
2324
cache-dependency-path: src/go.sum
2425

25-
- name: Download Go dependencies
26-
run: go mod download
27-
working-directory: src
28-
2926
- name: Run Go unit tests
3027
run: go test -test.short -v ./...
3128
working-directory: src
3229

30+
- name: Verify Go modules
31+
working-directory: src
32+
run: |
33+
go mod tidy
34+
git diff --exit-code go.mod go.sum || { echo "Go modules are not up to date"; exit 1; }
35+
36+
nix-shell-test:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Install Nix
42+
uses: cachix/install-nix-action@v26
43+
with:
44+
nix_path: nixpkgs=channel:nixos-unstable
45+
46+
- name: Check nix-shell default.nix
47+
run: |
48+
set -o pipefail
49+
nix-shell --pure -E 'with import <nixpkgs> {}; mkShell { buildInputs = [ (import ./default.nix {}) ]; }' --run defang 2>&1 | sed -u 's|\s\+got:|::error file=pkgs/defang/cli.nix,line=6::Replace the vendorHash with the correct value:|'
50+
51+
# go-byoc-test:
52+
# runs-on: ubuntu-latest
53+
# steps:
54+
# - name: Configure AWS Credentials for CI
55+
# uses: aws-actions/configure-aws-credentials@v4
56+
# with:
57+
# aws-region: us-west-2
58+
# output-credentials: true
59+
# role-to-assume: arn:aws:iam::488659951590:role/ci-role-d4fe904 # ciRoleArn from defang-io/infrastructure stack
60+
61+
# - name: Configure AWS Credentials for Staging
62+
# uses: aws-actions/configure-aws-credentials@v4
63+
# with:
64+
# aws-region: us-west-2
65+
# role-duration-seconds: 1200
66+
# role-chaining: true
67+
# role-to-assume: arn:aws:iam::426819183542:role/admin # adminUserRoleArn from defang-io/bootstrap stack
68+
69+
# - uses: actions/checkout@v4
70+
71+
# - name: Set up Go
72+
# uses: actions/setup-go@v5
73+
# with:
74+
# go-version-file: src/go.mod
75+
# cache-dependency-path: src/go.sum
76+
77+
# - name: Run sanity tests
78+
# run: go run ./cmd/cli compose up -f tests/compose.yaml
79+
# working-directory: src
80+
81+
go-playground-test:
82+
runs-on: ubuntu-latest
83+
needs: go-test
84+
steps:
85+
- uses: actions/checkout@v4
86+
87+
- name: Set up Go
88+
uses: actions/setup-go@v5
89+
with:
90+
go-version-file: src/go.mod
91+
cache-dependency-path: src/go.sum
92+
93+
- name: Login using GitHub token
94+
run: go run ./cmd/cli login --debug
95+
working-directory: src
96+
97+
- name: Add dummy secret
98+
run: echo blah | go run ./cmd/cli secret set -n dummy --debug
99+
working-directory: src
100+
101+
- name: Run sanity tests
102+
run: go run ./cmd/cli compose start -f tests/testproj/compose.yaml --debug
103+
working-directory: src
104+
33105
go-release:
34106
if: startsWith(github.ref, 'refs/tags/v') # only run this step on tagged commits
35-
# needs: go-test
107+
needs: go-test
36108
runs-on: macos-latest
37109
permissions:
38110
contents: write # to upload archives as GitHub Releases
@@ -52,7 +124,7 @@ jobs:
52124
working-directory: src
53125

54126
- name: Install Nix (for nix-prefetch-url)
55-
uses: cachix/install-nix-action@v23
127+
uses: cachix/install-nix-action@v26
56128

57129
- name: Run GoReleaser
58130
uses: goreleaser/goreleaser-action@v5
@@ -76,3 +148,57 @@ jobs:
76148
MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID }}
77149
MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.MACOS_NOTARIZATION_TEAM_ID }}
78150
MACOS_NOTARIZATION_APP_PW: ${{ secrets.MACOS_NOTARIZATION_APP_PW }}
151+
152+
- name: Trigger CLI Autodoc
153+
uses: peter-evans/repository-dispatch@v1
154+
with:
155+
token: ${{ secrets.DOCS_ACTION_TRIGGER_TOKEN }}
156+
repository: defang-io/defang-docs
157+
event-type: cli-autodoc
158+
client-payload: '{"version": "${{ github.ref_name }}"}'
159+
160+
publish-npm-binaries:
161+
runs-on: ubuntu-latest
162+
needs: go-release
163+
164+
env:
165+
NODE_VERSION: "21"
166+
NPM_REGISTRY_URL: "https://registry.npmjs.org"
167+
168+
defaults:
169+
run:
170+
shell: bash
171+
working-directory: ./pkgs/npm
172+
173+
steps:
174+
- name: Checkout tag
175+
uses: actions/checkout@v4
176+
177+
- name: Install node
178+
uses: actions/setup-node@v4
179+
with:
180+
node-version: ${{ env.NODE_VERSION }}
181+
registry-url: ${{ env.NPM_REGISTRY_URL }}
182+
183+
- name: Publish to NPM
184+
run: |
185+
# Get version number without the 'v'
186+
export version_number=`echo "${{ github.ref_name }}" | cut -c2- `
187+
188+
echo "Setting version number to ${version_number}"
189+
# update version placeholder in package.json with version matching binary.
190+
npm version ${version_number}
191+
192+
# install dependencies
193+
npm ci --ignore-scripts
194+
195+
#b uild
196+
npm run build
197+
198+
# make the cli.js executable
199+
chmod u+x ./bin/cli.js
200+
201+
# publish the package
202+
npm publish --access public
203+
env:
204+
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_AUTH_TOKEN }}

.github/workflows/install.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Install script
2+
3+
on:
4+
release:
5+
types: [published]
6+
push:
7+
branches:
8+
- main
9+
paths:
10+
- '.github/workflows/install.yml'
11+
- 'src/bin/install'
12+
13+
jobs:
14+
install:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Install defang
19+
run: . <(curl -Ls https://s.defang.io/install)
20+
21+
- name: Sanity check
22+
run: defang --version

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ node_modules/
33
.direnv/
44
.DS_Store
55
/result
6+
7+
8+
.log
9+
.gitignore

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"github.vscode-pull-request-github"
4+
]
5+
}

README.md

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,45 @@
11
[![Go package](https://github.com/defang-io/defang/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/defang-io/defang/actions/workflows/go.yml)
22

3-
# defang
4-
The Defang Opinionated Platform (DOP) is a radically simpler way to build, deploy, and optimize production-ready cloud apps.
3+
# Defang
4+
Defang is a radically simpler way for developers to create, deploy, and manage cloud applications.
5+
56
This repo includes:
67
* Public releases of the Defang CLI; [click here](https://github.com/defang-io/defang/releases/latest/) for the latest version
78
* Samples in Golang, Python, and Node.js that show how to accomplish various tasks and deploy them to the DOP using a Docker Compose file using the Defang CLI.
89
* Samples that show how to deploy an app using the [Defang Pulumi Provider](https://github.com/defang-io/pulumi-defang).
910

1011
## Getting started
11-
* Read our [Terms of Service](https://defang.io/terms-service.html)
12-
* Install the Defang CLI from one of the following sources:
13-
* Using the [Homebrew package manager](https://brew.sh): `brew install defang-io/defang/defang`
14-
* Using [Go](https://go.dev): `go install github.com/defang-io/defang/src/cmd/cli@latest`
15-
* Using the [Nix package manager](https://nixos.org):
16-
* with Nix-Env: `nix-env -if https://github.com/defang-io/defang/archive/main.tar.gz`
17-
* or with Flakes: `nix profile install github:defang-io/defang#defang-bin --refresh`
18-
* Download the [latest binary](https://github.com/defang-io/defang/releases/latest/) of the Defang CLI. For this beta, MacOS users will have to explicitly allow running of downloaded programs in the OS security settings.
12+
* Read our [Getting Started](https://docs.defang.io/docs/getting-started) page
13+
* Follow the installation instructions from the [Installing](https://docs.defang.io/docs/getting-started/installing) page
1914
* Take a look at our [Samples folder](https://github.com/defang-io/defang/tree/main/samples) for example projects in various programming languages.
2015
* Try the AI integration by running `defang generate`
2116
* Start your new service with `defang compose up`
2217

18+
## Installing
19+
Install the Defang CLI from one of the following sources:
20+
* Using the [Homebrew](https://brew.sh) package manager [defang-io/defang tap](https://github.com/defang-io/homebrew-defang):
21+
```
22+
brew install defang-io/defang/defang
23+
```
24+
* Using a shell script:
25+
```
26+
. <(curl -Ls https://s.defang.io/install)
27+
```
28+
* Using [Go](https://go.dev):
29+
```
30+
go install github.com/defang-io/defang/src/cmd/cli@latest
31+
```
32+
* Using the [Nix package manager](https://nixos.org):
33+
* with Nix-Env:
34+
```
35+
nix-env -if https://github.com/defang-io/defang/archive/main.tar.gz
36+
```
37+
* or with Flakes:
38+
```
39+
nix profile install github:defang-io/defang#defang-bin --refresh
40+
```
41+
* Download the [latest binary](https://github.com/defang-io/defang/releases/latest/) of the Defang CLI. For this beta, MacOS users will have to explicitly allow running of downloaded programs in the OS security settings.
42+
2343
## Support
2444
* File any issues [right here on GitHub](https://github.com/defang-io/defang/issues)
2545
@@ -52,9 +72,16 @@ Invoke-Expression -Command (defang completion powershell | Out-String)
5272
5373
## Environment Variables
5474
The Defang CLI recognizes the following environment variables:
75+
* `COMPOSE_PROJECT_NAME` - The name of the project to use; overrides the name in the `compose.yaml` file
5576
* `DEFANG_ACCESS_TOKEN` - The access token to use for authentication; if not specified, uses token from `defang login`
77+
* `DEFANG_CD_BUCKET` - The S3 bucket to use for the BYOC CD pipeline; defaults to `defang-cd-bucket-…`
78+
* `DEFANG_CD_IMAGE` - The image to use for the Continuous Deployment (CD) pipeline; defaults to `public.ecr.aws/defang-io/cd:public-beta`
79+
* `DEFANG_DEBUG` - set this to `1` or `true` to enable debug logging
80+
* `DEFANG_DISABLE_ANALYTICS` - If set to `true`, disables sending analytics to Defang; defaults to `false`
5681
* `DEFANG_FABRIC` - The address of the Defang Fabric to use; defaults to `fabric-prod1.defang.dev`
5782
* `DEFANG_HIDE_HINTS` - If set to `true`, hides hints in the CLI output; defaults to `false`
5883
* `DEFANG_HIDE_UPDATE` - If set to `true`, hides the update notification; defaults to `false`
84+
* `DEFANG_PROVIDER` - The name of the cloud provider to use, `auto` (default), `aws`, or `defang`
5985
* `NO_COLOR` - If set to any value, disables color output; by default, color output is enabled depending on the terminal
86+
* `TZ` - The timezone to use for log timestamps: an IANA TZ name like `UTC` or `Europe/Amsterdam`; defaults to `Local`
6087
* `XDG_STATE_HOME` - The directory to use for storing state; defaults to `~/.local/state`

defang.code-workspace

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,11 @@
88
}
99
],
1010
"settings": {
11+
"go.testEnvVars": {
12+
"AWS_PROFILE": "defang-sandbox"
13+
},
14+
"go.buildTags": "integration",
15+
"go.testFlags": ["-short"],
16+
"go.testTimeout": "300s"
1117
}
1218
}

flake.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
devShell = with pkgs; mkShell {
1212
buildInputs = [
1313
buf
14+
crane
1415
git
1516
gnumake
1617
gnused # force Linux `sed` everywhere
17-
go_1_20
18+
go_1_21
1819
nixfmt
1920
nodejs_20 # for Pulumi, must match values in package.json
2021
pulumi-bin

0 commit comments

Comments
 (0)