Add git-sourced Smart Tests as examples + update hotrod images to point to latest #763
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go | |
on: | |
push: | |
branches: [ main ] | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
pull_request: | |
branches: [ main ] | |
env: | |
GO_VERSION: "1.22" | |
jobs: | |
# run change detection | |
changes: | |
runs-on: ubuntu-latest | |
# Set job outputs to values from filter step | |
outputs: | |
location: ${{ steps.filter.outputs.location }} | |
driver: ${{ steps.filter.outputs.driver }} | |
frontend: ${{ steps.filter.outputs.frontend }} | |
route: ${{ steps.filter.outputs.route }} | |
steps: | |
# The paths-filter action requires a checkout step for push events. | |
- if: ${{ github.event_name == 'push' }} | |
uses: actions/checkout@v2 | |
- uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
location: | |
- 'services/location/**' | |
- 'cmd/location.go' | |
- 'pkg/**' | |
driver: | |
- 'services/driver/**' | |
- 'cmd/driver.go' | |
- 'pkg/**' | |
frontend: | |
- 'services/frontend/**' | |
- 'cmd/frontend.go' | |
- 'pkg/**' | |
route: | |
- 'services/route/**' | |
- 'cmd/route.go' | |
- 'pkg/**' | |
build: | |
runs-on: ubuntu-latest | |
needs: [ changes ] | |
env: | |
DOCKER_CLI_EXPERIMENTAL: "enabled" | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Go Mod Cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-mod-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-${{ env.GO_VERSION }}-mod- | |
- name: Go Build Cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/go-build | |
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-build-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-${{ env.GO_VERSION }}-build- | |
- name: Setup qemu | |
uses: docker/setup-qemu-action@v1 | |
- name: Docker Login | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and Push Docker Image | |
env: | |
RELEASE_TAG: ${{ github.sha }} | |
run: | | |
make push-docker | |
sandbox-route: | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'pull_request' && needs.changes.outputs.route == 'true' }} | |
needs: [ build, changes ] | |
env: | |
SIGNADOT_ORG: signadot | |
SIGNADOT_API_KEY: ${{ secrets.SIGNADOT_API_KEY }} | |
SANDBOX_IMAGE_TAG: ${{ github.sha }}-linux-amd64 | |
SANDBOX_NAME: pr-${{ github.event.number }}-route | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Set up Signadot CLI | |
run: | | |
curl -sSLf https://raw.githubusercontent.com/signadot/cli/main/scripts/install.sh | sh | |
- name: Define Namespace | |
run: | | |
echo "Checking for labels..." | |
LABELS="${{ toJSON(github.event.pull_request.labels.*.name) }}" | |
echo "Labels on PR: $LABELS" | |
if [[ "$LABELS" == *"devmesh"* ]]; then | |
echo "Found devmesh label" | |
NAMESPACE="hotrod-devmesh" | |
else | |
echo "Using default namespace" | |
NAMESPACE="hotrod-istio" | |
fi | |
echo "Using namespace=${NAMESPACE}" | |
echo "NAMESPACE=${NAMESPACE}" >> "$GITHUB_ENV" | |
- name: Create Sandbox | |
run: | | |
echo "Creating sandbox ${SANDBOX_NAME}..." | |
signadot sandbox apply \ | |
--set name=${SANDBOX_NAME} \ | |
--set github-pr=${{ github.event.number }} \ | |
--set image=signadot/hotrod:${SANDBOX_IMAGE_TAG} \ | |
--set branch=${{ github.head_ref }} \ | |
--set service=route \ | |
--set namespace=${NAMESPACE} \ | |
-f - \ | |
< ${GITHUB_WORKSPACE}/.signadot/sbx-gh-template.yaml | |
- name: Run Smart Tests | |
run: | | |
signadot st run --sandbox=${SANDBOX_NAME} --publish | |
- name: Run Integration Tests using Signadot Local Proxy | |
run: | | |
# Run the proxy | |
echo "Starting signadot proxy..." | |
signadot local proxy --sandbox ${SANDBOX_NAME} \ | |
--map grpc://route.${NAMESPACE}:8083@localhost:38083 \ | |
--map http://frontend.${NAMESPACE}:8080@localhost:38080 > /tmp/signadot-proxy.log & | |
PROXY_PID=$! | |
sleep 1 | |
cat /tmp/signadot-proxy.log | |
# Run api tests | |
echo "Executing tests..." | |
go install github.com/jstemmer/go-junit-report/v2@latest | |
TEST_ROUTE_ADDR=localhost:38083 go test -v \ | |
${GITHUB_WORKSPACE}/services/route/ | go-junit-report -set-exit-code -out api-report.xml | |
# Run integration tests | |
TEST_FRONTEND_ADDR=localhost:38080 TEST_TARGET_WORKLOAD=route TEST_SANDBOX_NAME=${SANDBOX_NAME} go test -v \ | |
${GITHUB_WORKSPACE}/services/frontend/ | go-junit-report -set-exit-code -out integration-report.xml | |
# Stop the proxy | |
echo "Stopping signadot proxy..." | |
cat /tmp/signadot-proxy.log | |
kill ${PROXY_PID} | |
sandbox-frontend: | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'pull_request' && needs.changes.outputs.frontend == 'true' }} | |
needs: [ build, changes ] | |
env: | |
SIGNADOT_ORG: signadot | |
SIGNADOT_API_KEY: ${{ secrets.SIGNADOT_API_KEY }} | |
SANDBOX_IMAGE_TAG: ${{ github.sha }}-linux-amd64 | |
SANDBOX_NAME: pr-${{ github.event.number }}-frontend | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Set up Signadot CLI | |
run: | | |
curl -sSLf https://raw.githubusercontent.com/signadot/cli/main/scripts/install.sh | sh | |
- name: Define Namespace | |
run: | | |
echo "Checking for labels..." | |
LABELS="${{ toJSON(github.event.pull_request.labels.*.name) }}" | |
echo "Labels on PR: $LABELS" | |
if [[ "$LABELS" == *"devmesh"* ]]; then | |
echo "Found devmesh label" | |
NAMESPACE="hotrod-devmesh" | |
else | |
echo "Using default namespace" | |
NAMESPACE="hotrod-istio" | |
fi | |
echo "Using namespace=${NAMESPACE}" | |
echo "NAMESPACE=${NAMESPACE}" >> "$GITHUB_ENV" | |
- name: Create Sandbox | |
run: | | |
echo "Creating sandbox ${SANDBOX_NAME}..." | |
signadot sandbox apply \ | |
--set name=${SANDBOX_NAME} \ | |
--set github-pr=${{ github.event.number }} \ | |
--set image=signadot/hotrod:${SANDBOX_IMAGE_TAG} \ | |
--set branch=${{ github.head_ref }} \ | |
--set service=frontend \ | |
--set namespace=${NAMESPACE} \ | |
-f - \ | |
< ${GITHUB_WORKSPACE}/.signadot/sbx-gh-template.yaml | |
- name: Run Smart Tests | |
run: | | |
signadot st run --sandbox=${SANDBOX_NAME} --publish | |
sandbox-location: | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'pull_request' && needs.changes.outputs.location == 'true' }} | |
needs: [ build, changes ] | |
env: | |
SIGNADOT_ORG: signadot | |
SIGNADOT_API_KEY: ${{ secrets.SIGNADOT_API_KEY }} | |
SANDBOX_IMAGE_TAG: ${{ github.sha }}-linux-amd64 | |
SANDBOX_NAME: pr-${{ github.event.number }}-location | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Set up Signadot CLI | |
run: | | |
curl -sSLf https://raw.githubusercontent.com/signadot/cli/main/scripts/install.sh | sh | |
- name: Define Namespace | |
run: | | |
echo "Checking for labels..." | |
LABELS="${{ toJSON(github.event.pull_request.labels.*.name) }}" | |
echo "Labels on PR: $LABELS" | |
if [[ "$LABELS" == *"devmesh"* ]]; then | |
echo "Found devmesh label" | |
NAMESPACE="hotrod-devmesh" | |
else | |
echo "Using default namespace" | |
NAMESPACE="hotrod-istio" | |
fi | |
echo "Using namespace=${NAMESPACE}" | |
echo "NAMESPACE=${NAMESPACE}" >> "$GITHUB_ENV" | |
- name: Create Sandbox | |
run: | | |
echo "Creating sandbox ${SANDBOX_NAME}..." | |
signadot sandbox apply \ | |
--set name=${SANDBOX_NAME} \ | |
--set github-pr=${{ github.event.number }} \ | |
--set image=signadot/hotrod:${SANDBOX_IMAGE_TAG} \ | |
--set branch=${{ github.head_ref }} \ | |
--set service=location \ | |
--set namespace=${NAMESPACE} \ | |
-f - \ | |
< ${GITHUB_WORKSPACE}/.signadot/sbx-gh-template.yaml | |
- name: Run Smart Tests | |
run: | | |
signadot st run --sandbox=${SANDBOX_NAME} --publish | |
sandbox-driver: | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'pull_request' && needs.changes.outputs.driver == 'true' }} | |
needs: [ build, changes ] | |
env: | |
SIGNADOT_ORG: signadot | |
SIGNADOT_API_KEY: ${{ secrets.SIGNADOT_API_KEY }} | |
SANDBOX_IMAGE_TAG: ${{ github.sha }}-linux-amd64 | |
SANDBOX_NAME: pr-${{ github.event.number }}-driver | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Set up Signadot CLI | |
run: | | |
curl -sSLf https://raw.githubusercontent.com/signadot/cli/main/scripts/install.sh | sh | |
- name: Define Namespace | |
run: | | |
echo "Checking for labels..." | |
LABELS="${{ toJSON(github.event.pull_request.labels.*.name) }}" | |
echo "Labels on PR: $LABELS" | |
if [[ "$LABELS" == *"devmesh"* ]]; then | |
echo "Found devmesh label" | |
NAMESPACE="hotrod-devmesh" | |
else | |
echo "Using default namespace" | |
NAMESPACE="hotrod-istio" | |
fi | |
echo "Using namespace=${NAMESPACE}" | |
echo "NAMESPACE=${NAMESPACE}" >> "$GITHUB_ENV" | |
- name: Create Sandbox | |
run: | | |
echo "Creating sandbox ${SANDBOX_NAME}..." | |
signadot sandbox apply \ | |
--set name=${SANDBOX_NAME} \ | |
--set github-pr=${{ github.event.number }} \ | |
--set image=signadot/hotrod:${SANDBOX_IMAGE_TAG} \ | |
--set branch=${{ github.head_ref }} \ | |
--set service=driver \ | |
--set namespace=${NAMESPACE} \ | |
-f - \ | |
< ${GITHUB_WORKSPACE}/.signadot/sbx-gh-template.yaml | |
- name: Run Smart Tests | |
run: | | |
signadot st run --sandbox=${SANDBOX_NAME} --publish |