Skip to content

Commit

Permalink
ci: upgrade CI enabling commit-based testing of cli and dapr
Browse files Browse the repository at this point in the history
Signed-off-by: mikeee <hey@mike.ee>
  • Loading branch information
mikeee committed Jun 16, 2024
1 parent ea64454 commit e69fbaf
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 28 deletions.
126 changes: 99 additions & 27 deletions .github/workflows/validate-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
GOARCH: amd64
GOPROXY: https://proxy.golang.org
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/master/install/install.sh
DAPR_CLI_REF: ${{ github.event.inputs.daprcli_commit }}
DAPR_REF: ${{ github.event.inputs.daprdapr_commit }}
DAPR_CLI_REF: 4881ca11d7f0ab70217761d93834df0139625dc7
DAPR_REF: a04348b0099df1890a88627333d0b1ecb3534e70
CHECKOUT_REPO: ${{ github.repository }}
CHECKOUT_REF: ${{ github.ref }}
outputs:
Expand All @@ -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 All @@ -53,6 +53,12 @@ jobs:
echo "DAPR_REF=master" >> $GITHUB_ENV
fi
- name: Check out code
uses: actions/checkout@v4
with:
repository: ${{ env.CHECKOUT_REPO }}
ref: ${{ env.CHECKOUT_REF }}

- name: Set up Go
uses: actions/setup-go@v5
with:
Expand All @@ -70,9 +76,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 @@ -89,29 +92,82 @@ 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 daprd and placement 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 directory
mkdir ~/daprbundle
cp .github/workflows/validate-examples/details.json ~/daprbundle/
: # Add cli
cp ~/artifacts/$GITHUB_SHA/dapr ~/daprbundle/dapr
: # Compress executables to /dist/ appending _linux_amd64 to the name
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 @@ -124,7 +180,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 @@ -134,10 +190,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 }}
RUST_BACKTRACE: full

strategy:
Expand All @@ -153,16 +208,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: Rust setup
run: rustup toolchain install stable --profile minimal
Expand All @@ -173,25 +233,37 @@ jobs:
version: "25.2"

- 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
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"
}
1 change: 1 addition & 0 deletions examples/actors/dapr.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: 1
common:
resourcesPath: ./resources/
daprdLogDestination: console
apps:
- appID: actor-server
Expand Down
14 changes: 14 additions & 0 deletions examples/actors/resources/redis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
spec:
type: state.redis
version: v1
metadata:
- name: redisHost
value: localhost:6379
- name: redisPassword
value: ""
- name: actorStateStore
value: "true"
2 changes: 1 addition & 1 deletion examples/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ timeout_seconds: 30
-->

```bash
dapr run --app-id=rustapp --dapr-grpc-port 3500 cargo run -- --example client
dapr run --app-id=rustapp --dapr-grpc-port 3500 --resources-path ./resources cargo run -- --example client
```

<!-- END_STEP -->
Expand Down
12 changes: 12 additions & 0 deletions examples/client/resources/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: ""

0 comments on commit e69fbaf

Please sign in to comment.