Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: implement a more resilient validation workflow #574

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/validate-examples/details.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"daprd": "0.0.0-dev",
"dashboard": "0.0.0-dev",
"cli": "0.0.0-dev",
"daprBinarySubDir": "dist",
"dockerImageSubDir": "docker",
"daprImageName": "daprio/dapr:0.0.0-dev",
"daprImageFileName": "daprio-dapr-0.0.0-dev.tar.gz"
}
118 changes: 93 additions & 25 deletions .github/workflows/validate_examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
DAPR_RUNTIME_VER: ${{ steps.outputs.outputs.DAPR_RUNTIME_VER }}
CHECKOUT_REPO: ${{ steps.outputs.outputs.CHECKOUT_REPO }}
CHECKOUT_REF: ${{ steps.outputs.outputs.CHECKOUT_REF }}
DAPR_REF: ${{ steps.outputs.outputs.DAPR_REF }}
GITHUB_SHA: ${{ steps.outputs.outputs.GITHUB_SHA }}
steps:
- name: Parse repository_dispatch payload
if: github.event_name == 'repository_dispatch'
Expand Down Expand Up @@ -79,9 +79,6 @@ jobs:
echo "DAPR_CLI_VER=$CLI_VERSION" >> $GITHUB_ENV
echo "Found $CLI_VERSION"

- name: Set up Dapr CLI
run: wget -q ${{ env.DAPR_INSTALL_URL }} -O - | /bin/bash -s ${{ env.DAPR_CLI_VER }}

- name: Checkout Dapr CLI repo to override dapr command.
uses: actions/checkout@v4
if: env.DAPR_CLI_REF != ''
Expand All @@ -98,29 +95,84 @@ jobs:
ref: ${{ env.DAPR_REF }}
path: dapr_runtime

- name: Build dapr cli with referenced commit.
- name: Build dapr cli with referenced commit and override version
if: env.DAPR_CLI_REF != ''
run: |
cd cli
make
echo "artifactPath=~/artifacts/$GITHUB_SHA/" >> $GITHUB_ENV
mkdir -p $HOME/artifacts/$GITHUB_SHA/
sudo cp dist/linux_amd64/release/dapr $HOME/artifacts/$GITHUB_SHA/dapr
cp dist/linux_amd64/release/dapr $HOME/artifacts/$GITHUB_SHA/dapr
CLI_VERSION=edge
echo "DAPR_CLI_VER=$CLI_VERSION" >> $GITHUB_ENV

- name: Build daprd and placement with referenced commit.
- name: Build dapr services with referenced commit and override version
if: env.DAPR_REF != ''
run: |
cd dapr_runtime
make
mkdir -p $HOME/artifacts/$GITHUB_SHA/
cp dist/linux_amd64/release/daprd $HOME/artifacts/$GITHUB_SHA/daprd
cp dist/linux_amd64/release/placement $HOME/artifacts/$GITHUB_SHA/placement
echo "artifactPath=~/artifacts/$GITHUB_SHA/" >> $GITHUB_ENV
RUNTIME_VERSION=edge
echo "DAPR_RUNTIME_VER=$RUNTIME_VERSION" >> $GITHUB_ENV

- name: Build Docker Image
if: env.DAPR_REF != ''
run: |
mkdir ~/dapr_docker
cd dapr_runtime
docker build --build-arg "PKG_FILES=*" -f ./docker/Dockerfile ./dist/linux_amd64/release -t daprio/dapr:0.0.0-dev

- name: Download Install Bundle CLI
if: env.DAPR_REF != '' && env.DAPR_CLI_REF == ''
run: |
mkdir -p cli/dist/linux_amd64/release
cd cli/dist/linux_amd64/release/
curl -L --remote-name https://github.com/dapr/cli/releases/download/v$DAPR_CLI_VER/dapr_linux_amd64.tar.gz
tar xvzf dapr_linux_amd64.tar.gz
ls -la

- name: Build Custom Install Bundle
if: env.DAPR_REF != '' && env.DAPR_CLI_REF != ''
run: |
: # Create daprbundle
mkdir ~/daprbundle

cp .github/workflows/validate-examples/details.json ~/daprbundle/

: # Add cli
cp ~/artifacts/$GITHUB_SHA/dapr ~/daprbundle/dapr

: # Zip daprd/dashboard/placement/scheduler/sentry /dist/ appending _linux_amd64 to tar.gz
mkdir ~/daprbundle/dist
cd dapr_runtime/dist/linux_amd64/release/
for file in $(ls -1)
do
echo "packing $file"
tar czvf ~/daprbundle/dist/${file}_linux_amd64.tar.gz ${file}
done

cd ~/daprbundle/dist/
curl -L --remote-name https://github.com/dapr/dashboard/releases/download/v0.14.0/dashboard_linux_amd64.tar.gz

: # Add docker image
mkdir ~/daprbundle/docker
docker save daprio/dapr:0.0.0-dev | gzip > ~/daprbundle/docker/daprio-dapr-0.0.0-dev.tar.gz

: # Bundle
cd ~/daprbundle
tar czvf $HOME/artifacts/$GITHUB_SHA/daprbundle.tar.gz .

- name: List artifacts
if: env.DAPR_REF != '' || env.DAPR_CLI_REF != ''
run: |
ls -la $HOME/artifacts/$GITHUB_SHA/

- name: Upload dapr-artifacts
uses: actions/upload-artifact@v4
if: env.DAPR_REF != '' || env.DAPR_CLI_REF != ''
with:
name: dapr-artifacts
path: $HOME/artifacts/$GITHUB_SHA/
path: ${{ env.artifactPath }}
if-no-files-found: error
retention-days: 1
compression-level: 0
Expand All @@ -133,7 +185,7 @@ jobs:
echo "DAPR_RUNTIME_VER=$DAPR_RUNTIME_VER" >> "$GITHUB_OUTPUT"
echo "CHECKOUT_REPO=$CHECKOUT_REPO" >> "$GITHUB_OUTPUT"
echo "CHECKOUT_REF=$CHECKOUT_REF" >> "$GITHUB_OUTPUT"
echo "DAPR_REF=$DAPR_REF" >> "$GITHUB_OUTPUT"
echo "GITHUB_SHA=$GITHUB_SHA" >> "$GITHUB_OUTPUT"

validate-example:
needs: setup
Expand All @@ -146,10 +198,9 @@ jobs:
DAPR_INSTALL_URL: ${{ needs.setup.outputs.DAPR_INSTALL_URL }}
DAPR_CLI_VER: ${{ needs.setup.outputs.DAPR_CLI_VER }}
DAPR_RUNTIME_VER: ${{ needs.setup.outputs.DAPR_RUNTIME_VER }}
DAPR_CLI_REF: ${{ github.event.inputs.daprcli_commit }}
DAPR_REF: ${{ github.event.inputs.daprdapr_commit }}
CHECKOUT_REPO: ${{ needs.setup.outputs.CHECKOUT_REPO }}
CHECKOUT_REF: ${{ needs.setup.outputs.CHECKOUT_REF }}
GITHUB_SHA: ${{ needs.setup.outputs.GITHUB_SHA }}

strategy:
fail-fast: false
Expand All @@ -175,16 +226,21 @@ jobs:
ref: ${{ env.CHECKOUT_REF }}

- name: Make Artifacts destination folder
if: env.DAPR_CLI_REF != '' || env.DAPR_REF != ''
if: env.DAPR_CLI_VER == 'edge' || env.DAPR_RUNTIME_VER == 'edge'
run: |
mkdir -p $HOME/artifacts/$GITHUB_SHA/

- name: Retrieve dapr-artifacts
if: env.DAPR_CLI_REF != '' || env.DAPR_REF != ''
if: env.DAPR_CLI_VER == 'edge' || env.DAPR_RUNTIME_VER == 'edge'
uses: actions/download-artifact@v4
with:
name: dapr-artifacts
path: $HOME/artifacts/$GITHUB_SHA/
path: ~/artifacts/${{ env.GITHUB_SHA }}

- name: Display downloaded artifacts
if: env.DAPR_CLI_VER == 'edge' || env.DAPR_RUNTIME_VER == 'edge'
run: |
ls -la $HOME/artifacts/$GITHUB_SHA/

- name: Set up Go
id: setup-go
Expand All @@ -193,25 +249,37 @@ jobs:
go-version-file: "go.mod"

- name: Set up Dapr CLI
if: env.DAPR_CLI_VER != 'edge'
run: wget -q ${{ env.DAPR_INSTALL_URL }} -O - | /bin/bash -s ${{ env.DAPR_CLI_VER }}

- name: Override dapr cli with referenced commit.
if: env.DAPR_CLI_REF != ''
- name: Set up Dapr CLI (edge)
if: env.DAPR_CLI_VER == 'edge'
run: |
sudo cp $HOME/artifacts/$GITHUB_SHA/dapr /usr/local/bin/dapr
sudo chmod +x /usr/local/bin/dapr

- name: Initialize Dapr runtime ${{ env.DAPR_RUNTIME_VER }}
if: env.DAPR_RUNTIME_VER != 'edge'
run: |
dapr uninstall --all
dapr init --runtime-version ${{ env.DAPR_RUNTIME_VER }}

- name: Override daprd and placement service with referenced commit.
if: env.DAPR_REF != ''
- name: Initialize Dapr runtime EDGE
if: env.DAPR_RUNTIME_VER == 'edge'
run: |
mkdir -p $HOME/.dapr/bin/
cp $HOME/artifacts/$GITHUB_SHA/daprd $HOME/.dapr/bin/daprd
docker stop dapr_placement
$HOME/artifacts/$GITHUB_SHA/placement --healthz-port 9091 &
: # Unpack Bundle
mkdir ~/daprbundle
tar xvzf $HOME/artifacts/$GITHUB_SHA/daprbundle.tar.gz -C ~/daprbundle

: # Run installer
dapr uninstall --all
dapr init --from-dir ~/daprbundle/

: # Initialize redis and zipkin
docker run --name "dapr_redis" --restart always -d -p 6379:6379 redislabs/rejson
docker run --name "dapr_zipkin" --restart always -d -p 9411:9411 openzipkin/zipkin

docker ps -a

- name: Set up Python ${{ env.PYTHON_VER }}
uses: actions/setup-python@v5
Expand Down
8 changes: 4 additions & 4 deletions examples/hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ expected_stdout_lines:
-->

```bash
dapr run --app-id order-app --dapr-grpc-port 3500 --log-level error -- ./order put --id 20
dapr run --app-id order-app --dapr-grpc-port 3500 --log-level error --resources-path ./config -- ./order put --id 20
```

<!-- END_STEP -->
Expand All @@ -105,7 +105,7 @@ expected_stdout_lines:
-->

```bash
dapr run --app-id order-app --dapr-grpc-port 3500 --log-level error ./order get
dapr run --app-id order-app --dapr-grpc-port 3500 --log-level error --resources-path ./config ./order get
```

<!-- END_STEP -->
Expand All @@ -116,7 +116,7 @@ dapr run --app-id order-app --dapr-grpc-port 3500 --log-level error ./order get
Alternatively, you can start a standalone Dapr runtime, and call the app from another shell:

```bash
dapr run --app-id order-app --dapr-grpc-port 3500 --log-level error
dapr run --app-id order-app --dapr-grpc-port 3500 --log-level error --resources-path ./config
```


Expand All @@ -140,7 +140,7 @@ You can run more than one app in Dapr runtime. In this example you will call `or
Another instance of the `order` app will read the state.

```sh
dapr run --app-id order-app --dapr-grpc-port 3500 --log-level error ./order seq
dapr run --app-id order-app --dapr-grpc-port 3500 --log-level error --resources-path ./config ./order seq
```

```sh
Expand Down
12 changes: 12 additions & 0 deletions examples/hello-world/config/redis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
spec:
type: state.redis
version: v1
metadata:
- name: redisHost
value: localhost:6379
- name: redisPassword
value: ""
8 changes: 4 additions & 4 deletions examples/socket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ expected_stdout_lines:
-->

```bash
dapr run --app-id order-app --log-level error --unix-domain-socket /tmp -- ./order put --id 20
dapr run --app-id order-app --log-level error --resources-path ./config --unix-domain-socket /tmp -- ./order put --id 20
```

<!-- END_STEP -->
Expand All @@ -93,15 +93,15 @@ expected_stdout_lines:
-->

```bash
dapr run --app-id order-app --log-level error --unix-domain-socket /tmp ./order get
dapr run --app-id order-app --log-level error --resources-path ./config --unix-domain-socket /tmp ./order get
```

<!-- END_STEP -->

Alternatively, you can start a standalone Dapr runtime, and call the app from another shell:

```bash
dapr run --app-id order-app --log-level error --unix-domain-socket /tmp
dapr run --app-id order-app --log-level error --resources-path ./config --unix-domain-socket /tmp
```


Expand All @@ -124,7 +124,7 @@ You can run more than one app in Dapr runtime. In this example you will call `or
Another instance of the `order` app will read the state.

```sh
dapr run --app-id order-app --log-level error --unix-domain-socket /tmp ./order seq
dapr run --app-id order-app --log-level error --resources-path ./config --unix-domain-socket /tmp ./order seq
```

```sh
Expand Down
12 changes: 12 additions & 0 deletions examples/socket/config/redis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
spec:
type: state.redis
version: v1
metadata:
- name: redisHost
value: localhost:6379
- name: redisPassword
value: ""
Loading