Skip to content

Commit

Permalink
Merge branch 'master' into placement-ha-chart
Browse files Browse the repository at this point in the history
  • Loading branch information
yaron2 committed Jun 16, 2023
2 parents a2526b0 + 8a995de commit 367bbe9
Show file tree
Hide file tree
Showing 22 changed files with 1,781 additions and 2 deletions.
62 changes: 62 additions & 0 deletions .github/scripts/dapr_bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ async function handleIssueCommentCreate({ github, context }) {
case '/test-sdk-java':
case '/test-sdk-python':
case '/test-sdk-js':
case '/test-sdk-go':
await cmdTestSDK(
github,
issue,
Expand All @@ -132,6 +133,17 @@ async function handleIssueCommentCreate({ github, context }) {
commandParts.join(' ')
)
break
case '/test-version-skew':
const previousVersion = commandParts.length > 0 ? commandParts.shift() : null
await cmdTestVersionSkew(
github,
issue,
isFromPulls,
command,
previousVersion,
commandParts.join(' ')
)
break
default:
console.log(
`[handleIssueCommentCreate] command ${command} not found, exiting.`
Expand Down Expand Up @@ -421,3 +433,53 @@ async function cmdTestSDK(github, issue, isFromPulls, command, args) {
)
}
}

/**
* Trigger Version Skew tests for the pull request.
* @param {*} github GitHub object reference
* @param {*} issue GitHub issue object
* @param {boolean} isFromPulls is the workflow triggered by a pull request?
* @param {string} command which was used
* @param {string} previousVersion previous version to test against
*/
async function cmdTestVersionSkew(github, issue, isFromPulls, command, previousVersion, args) {
if (!isFromPulls) {
console.log(
'[cmdTestVersionSkew] only pull requests supported, skipping command execution.'
)
return
}

// Get pull request
const pull = await github.pulls.get({
owner: issue.owner,
repo: issue.repo,
pull_number: issue.number,
})

if (pull && pull.data) {
// Get commit id and repo from pull head
const testVersionSkewPayload = {
pull_head_ref: pull.data.head.sha,
pull_head_repo: pull.data.head.repo.full_name,
command: command.substring(1),
previous_version: previousVersion,
args,
issue: issue,
}

// Fire repository_dispatch event to trigger e2e test
await github.repos.createDispatchEvent({
owner: issue.owner,
repo: issue.repo,
event_type: command.substring(1),
client_payload: testVersionSkewPayload,
})

console.log(
`[cmdTestVersionSkew] triggered Version Skew test for ${JSON.stringify(
testVersionSkewPayload
)}`
)
}
}
123 changes: 123 additions & 0 deletions .github/workflows/dapr-test-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ on:
- test-sdk-python
- test-sdk-java
- test-sdk-js
- test-sdk-go
env:
GOOS: linux
GOARCH: amd64
Expand All @@ -38,6 +39,7 @@ env:
# /test-sdk-python
# /test-sdk-java
# /test-sdk-js
# /test-sdk-go
jobs:
python-sdk:
if: |
Expand Down Expand Up @@ -464,3 +466,124 @@ jobs:
## ⚠️ JS SDK tests cancelled
The Action has been canceled
go-sdk:
if: |
github.event_name == 'schedule' ||
( github.event_name == 'repository_dispatch' &&
(
github.event.action == 'test-sdk-all' ||
github.event.action == 'test-sdk-go'
)
)
name: "Go SDK verification tests"
runs-on: ubuntu-latest
steps:
- name: Set up for scheduled test
if: github.event_name != 'repository_dispatch'
run: |
echo "CHECKOUT_REPO=${{ github.repository }}" >> $GITHUB_ENV
echo "CHECKOUT_REF=refs/heads/master" >> $GITHUB_ENV
shell: bash
- name: Parse test payload
if: github.event_name == 'repository_dispatch'
uses: actions/github-script@v6.2.0
with:
github-token: ${{secrets.DAPR_BOT_TOKEN}}
script: |
const testPayload = context.payload.client_payload;
if (testPayload) {
var fs = require('fs');
// Set environment variables
fs.appendFileSync(process.env.GITHUB_ENV,
`CHECKOUT_REPO=${testPayload.pull_head_repo}\n`+
`CHECKOUT_REF=${testPayload.pull_head_ref}\n`+
`PR_NUMBER=${testPayload.issue.number}`
);
}
- name: Create PR comment
if: env.PR_NUMBER != ''
uses: artursouza/sticky-pull-request-comment@v2.2.0
with:
header: ${{ github.run_id }}-go
number: ${{ env.PR_NUMBER }}
hide: true
hide_classify: OUTDATED
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
message: |
# Dapr SDK Go test
🔗 **[Link to Action run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})**
Commit ref: ${{ env.CHECKOUT_REF }}
- name: Check out code
uses: actions/checkout@v3
with:
repository: ${{ env.CHECKOUT_REPO }}
ref: ${{ env.CHECKOUT_REF }}
- name: "Set up Go"
id: setup-go
uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- name: Checkout go-sdk repo to run tests.
uses: actions/checkout@v3
with:
repository: dapr/go-sdk
path: go-sdk
- name: Set up Dapr CLI
run: wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash -s
- name: Initialize Dapr runtime
run: |
dapr uninstall --all
dapr init
- name: Build and override daprd with HEAD.
run: |
make
mkdir -p $HOME/.dapr/bin/
cp dist/linux_amd64/release/daprd $HOME/.dapr/bin/daprd
- name: Override placement service.
run: |
docker stop dapr_placement
./dist/linux_amd64/release/placement --healthz-port 9091 &
- name: Check Examples
run: |
cd go-sdk/examples
./validate.sh hello-world
./validate.sh pubsub
./validate.sh service
./validate.sh actor
- name: Update PR comment for success
if: ${{ success() }}
uses: artursouza/sticky-pull-request-comment@v2.2.0
with:
header: ${{ github.run_id }}-go
number: ${{ env.PR_NUMBER }}
append: true
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
message: |
## ✅ Go SDK tests passed
- name: Update PR comment for failure
if: ${{ failure() }}
uses: artursouza/sticky-pull-request-comment@v2.2.0
with:
header: ${{ github.run_id }}-go
number: ${{ env.PR_NUMBER }}
append: true
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
message: |
## ❌ Go SDK tests failed
Please check the logs for details on the error.
- name: Update PR comment for cancellation
if: ${{ cancelled() }}
uses: artursouza/sticky-pull-request-comment@v2.2.0
with:
header: ${{ github.run_id }}-go
number: ${{ env.PR_NUMBER }}
append: true
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
message: |
## ⚠️ Go SDK tests cancelled
The Action has been canceled
77 changes: 76 additions & 1 deletion .github/workflows/dapr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,85 @@ jobs:
with:
name: ${{ matrix.target_os }}_${{ matrix.target_arch }}_test_unit.json
path: ${{ env.TEST_OUTPUT_FILE_PREFIX }}_unit.json

integration-tests:
name: Integration tests
needs: lint
runs-on: "${{ matrix.os }}"
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target_os: linux
target_arch: amd64
- os: windows-2022
target_os: windows
target_arch: amd64
windows_version: ltsc2022
- os: macOS-latest
target_os: darwin
target_arch: amd64
env:
GOOS: "${{ matrix.target_os }}"
GOARCH: "${{ matrix.target_arch }}"
GOPROXY: "https://proxy.golang.org"
ARCHIVE_OUTDIR: "dist/archives"
TEST_OUTPUT_FILE_PREFIX: "test_report"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up Go
id: setup-go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
- name: Cache Go modules (Linux)
if: matrix.target_os == 'linux'
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ steps.setup-go.outputs.go-version }}-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ steps.setup-go.outputs.go-version }}-build-
- name: Cache Go modules (Windows)
if: matrix.target_os == 'windows'
uses: actions/cache@v3
with:
path: |
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ steps.setup-go.outputs.go-version }}-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ steps.setup-go.outputs.go-version }}-build-
- name: Cache Go modules (macOS)
if: matrix.target_os == 'darwin'
uses: actions/cache@v3
with:
path: |
~/Library/Caches/go-build
~/go/pkg/mod
key: ${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ steps.setup-go.outputs.go-version }}-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ steps.setup-go.outputs.go-version }}-build-
- name: Run make test-integration
env:
COVERAGE_OPTS: "-coverprofile=coverage.txt -covermode=atomic"
run: make test-integration
- name: Codecov
uses: codecov/codecov-action@v1
- name: Upload test results
if: always()
uses: actions/upload-artifact@master
with:
name: ${{ matrix.target_os }}_${{ matrix.target_arch }}_test_integration.json
path: ${{ env.TEST_OUTPUT_FILE_PREFIX }}_integration.json
build:
name: "Build artifacts on ${{ matrix.job_name }} - ${{ matrix.sidecar_flavor }}"
runs-on: "${{ matrix.os }}"
needs: unit-tests
needs: [unit-tests, integration-tests]
env:
GOOS: "${{ matrix.target_os }}"
GOARCH: "${{ matrix.target_arch }}"
Expand Down

0 comments on commit 367bbe9

Please sign in to comment.