From a65eddaa4e9217ed5cdf436b3438d2ffd837ba55 Mon Sep 17 00:00:00 2001 From: mikeee Date: Fri, 19 Jan 2024 17:07:59 +0000 Subject: [PATCH] fix: Overhaul the validation action (#495) * fix: remove the referenced daprd tag Signed-off-by: mikeee * update example validation flow Signed-off-by: mikeee * split into two+ jobs Signed-off-by: mikeee * chore: tidy Signed-off-by: mikeee * implement artifacts transfer and setup validate-example jobs Signed-off-by: mikeee * fix: only run the artifact steps when generated Signed-off-by: mikeee * fix: tag outputs with a step id Signed-off-by: mikeee * fix: typo in matrix Signed-off-by: mikeee * chore: cleanup Signed-off-by: mikeee * disable fail-fast Signed-off-by: mikeee * fix: grpc-service example sleeps Signed-off-by: mikeee --------- Signed-off-by: mikeee --- .github/workflows/validate_examples.yaml | 203 ++++++++++++++++++----- examples/grpc-service/README.md | 2 +- 2 files changed, 161 insertions(+), 44 deletions(-) diff --git a/.github/workflows/validate_examples.yaml b/.github/workflows/validate_examples.yaml index 62a52df3..fc67fd1d 100644 --- a/.github/workflows/validate_examples.yaml +++ b/.github/workflows/validate_examples.yaml @@ -4,97 +4,214 @@ on: push: branches: - main + - release-* tags: - v* pull_request: branches: - main + - release-* + workflow_dispatch: + inputs: + daprdapr_commit: + description: 'Dapr/Dapr commit to build custom daprd from' + required: false + default: '' + daprcli_commit: + description: 'Dapr/CLI commit to build custom dapr CLI from' + required: false + default: '' + repository_dispatch: + types: [ validate-examples ] + merge_group: jobs: - validate: + setup: runs-on: ubuntu-latest env: - PYTHON_VER: 3.7 - GOVER: "1.20" GOOS: linux GOARCH: amd64 GOPROXY: https://proxy.golang.org DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/master/install/install.sh - DAPR_CLI_REF: "" - DAPR_REF: 770d4e51604f1264d8bb25cedf16ea9f77539394 + DAPR_CLI_REF: ${{ github.event.inputs.daprcli_commit }} + DAPR_REF: ${{ github.event.inputs.daprdapr_commit }} + CHECKOUT_REPO: ${{ github.repository }} + CHECKOUT_REF: ${{ github.ref }} + outputs: + DAPR_INSTALL_URL: ${{ env.DAPR_INSTALL_URL }} + DAPR_CLI_VER: ${{ steps.outputs.outputs.DAPR_CLI_VER }} + 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 }} steps: - - uses: actions/checkout@v3 + - name: Parse repository_dispatch payload + if: github.event_name == 'repository_dispatch' + run: | + if [ ${{ github.event.client_payload.command }} = "ok-to-test" ]; then + echo "CHECKOUT_REPO=${{ github.event.client_payload.pull_head_repo }}" >> $GITHUB_ENV + echo "CHECKOUT_REF=${{ github.event.client_payload.pull_head_ref }}" >> $GITHUB_ENV + echo "DAPR_REF=master" >> $GITHUB_ENV + fi + + - name: Check out code onto GOPATH + uses: actions/checkout@v4 + with: + repository: ${{ env.CHECKOUT_REPO }} + ref: ${{ env.CHECKOUT_REF }} + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + + - name: Run go mod tidy check diff + run: make modtidy check-diff + - name: Determine latest Dapr Runtime version run: | RUNTIME_VERSION=$(curl -s "https://api.github.com/repos/dapr/dapr/releases/latest" | grep '"tag_name"' | cut -d ':' -f2 | tr -d '",v') echo "DAPR_RUNTIME_VER=$RUNTIME_VERSION" >> $GITHUB_ENV echo "Found $RUNTIME_VERSION" + - name: Determine latest Dapr Cli version run: | CLI_VERSION=$(curl -s "https://api.github.com/repos/dapr/cli/releases/latest" | grep '"tag_name"' | cut -d ':' -f2 | tr -d '",v') echo "DAPR_CLI_VER=$CLI_VERSION" >> $GITHUB_ENV echo "Found $CLI_VERSION" - - name: Set up Python ${{ env.PYTHON_VER }} - uses: actions/setup-python@v4 - with: - python-version: ${{ env.PYTHON_VER }} - - name: Install Mechanical Markdown - run: | - python -m pip install --upgrade pip - pip install mechanical-markdown - - name: Run go mod tidy check diff - run: make modtidy check-diff + - name: Set up Dapr CLI run: wget -q ${{ env.DAPR_INSTALL_URL }} -O - | /bin/bash -s ${{ env.DAPR_CLI_VER }} - - name: Set up Go ${{ env.GOVER }} - if: env.DAPR_REF != '' || env.DAPR_CLI_REF != '' - uses: actions/setup-go@v3 - with: - go-version: ${{ env.GOVER }} + - name: Checkout Dapr CLI repo to override dapr command. - uses: actions/checkout@v3 + uses: actions/checkout@v4 if: env.DAPR_CLI_REF != '' with: repository: dapr/cli ref: ${{ env.DAPR_CLI_REF }} path: cli + - name: Checkout Dapr repo to override daprd. - uses: actions/checkout@v3 + uses: actions/checkout@v4 if: env.DAPR_REF != '' with: repository: dapr/dapr ref: ${{ env.DAPR_REF }} path: dapr_runtime - - name: Build and override dapr cli with referenced commit. + + - name: Build dapr cli with referenced commit. if: env.DAPR_CLI_REF != '' run: | cd cli make - sudo cp dist/linux_amd64/release/dapr /usr/local/bin/dapr - cd .. + mkdir -p $HOME/artifacts/$GITHUB_SHA/ + sudo cp dist/linux_amd64/release/dapr $HOME/artifacts/$GITHUB_SHA/dapr + + - name: Build daprd and placement with referenced commit. + 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 + + - 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/ + if-no-files-found: error + retention-days: 1 + compression-level: 0 + + - name: Outputs + id: outputs + run: | + echo "DAPR_INSTALL_URL=$DAPR_INSTALL_URL" + echo "DAPR_CLI_VER=$DAPR_CLI_VER" >> "$GITHUB_OUTPUT" + 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" + + validate-example: + needs: setup + runs-on: ubuntu-latest + env: + PYTHON_VER: 3.12 + GOOS: linux + GOARCH: amd64 + GOPROXY: https://proxy.golang.org + 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 }} + + strategy: + fail-fast: false + matrix: + examples: [ "actor", "configuration", "grpc-service", "hello-world", "pubsub", "service", "socket" ] + steps: + - name: Check out code onto GOPATH + uses: actions/checkout@v4 + with: + repository: ${{ env.CHECKOUT_REPO }} + ref: ${{ env.CHECKOUT_REF }} + + - name: Make Artifacts destination folder + if: env.DAPR_CLI_REF != '' || env.DAPR_REF != '' + run: | + mkdir -p $HOME/artifacts/$GITHUB_SHA/ + + - name: Retrieve dapr-artifacts + if: env.DAPR_CLI_REF != '' || env.DAPR_REF != '' + uses: actions/download-artifact@v4 + with: + name: dapr-artifacts + path: $HOME/artifacts/$GITHUB_SHA/ + + - name: Set up Go + id: setup-go + uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + + - name: Set up Dapr CLI + 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 != '' + run: | + sudo cp $HOME/artifacts/$GITHUB_SHA/dapr /usr/local/bin/dapr + - name: Initialize Dapr runtime ${{ env.DAPR_RUNTIME_VER }} run: | dapr uninstall --all dapr init --runtime-version ${{ env.DAPR_RUNTIME_VER }} - - name: Build and override daprd with referenced commit. + + - name: Override daprd and placement service with referenced commit. if: env.DAPR_REF != '' run: | - cd dapr_runtime - make mkdir -p $HOME/.dapr/bin/ - cp dist/linux_amd64/release/daprd $HOME/.dapr/bin/daprd - cd .. - - name: Override placement service. - if: env.DAPR_REF != '' - run: | + cp $HOME/artifacts/$GITHUB_SHA/daprd $HOME/.dapr/bin/daprd docker stop dapr_placement - cd dapr_runtime - ./dist/linux_amd64/release/placement --healthz-port 9091 & - - name: Check Examples + $HOME/artifacts/$GITHUB_SHA/placement --healthz-port 9091 & + + - name: Set up Python ${{ env.PYTHON_VER }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VER }} + + - name: Install Mechanical Markdown + run: | + python -m pip install --upgrade pip + pip install mechanical-markdown + + - name: Check Example run: | cd examples - ./validate.sh grpc-service - ./validate.sh configuration - ./validate.sh hello-world - ./validate.sh pubsub - ./validate.sh service - ./validate.sh actor + ./validate.sh ${{ matrix.examples }} diff --git a/examples/grpc-service/README.md b/examples/grpc-service/README.md index 8491b6ad..980b5856 100644 --- a/examples/grpc-service/README.md +++ b/examples/grpc-service/README.md @@ -17,7 +17,7 @@ output_match_mode: substring expected_stdout_lines: - 'Received: Dapr' background: true -sleep: 15 +sleep: 30 --> ```bash