Skip to content

Merge pull request #237 from signadot/kafka-consumer-improvements #642

Merge pull request #237 from signadot/kafka-consumer-improvements

Merge pull request #237 from signadot/kafka-consumer-improvements #642

Workflow file for this run

name: Go
on:
push:
branches: [ main ]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches: [ main ]
env:
GO_VERSION: "1.21"
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@v2
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@v2
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 ]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Create Sandbox
id: create-sandbox
env:
SIGNADOT_ORG: signadot
SIGNADOT_API_KEY: ${{ secrets.SIGNADOT_API_KEY }}
IMAGE_TAG: ${{ github.sha }}-linux-amd64
run: |
echo "Checking for labels..."
LABELS="${{ toJSON(github.event.pull_request.labels.*.name) }}"
echo "Labels on PR: $LABELS"
if [[ "$LABELS" == *"istio"* ]]; then
echo "Found istio label"
NAMESPACE="hotrod-istio"
else
echo "istio label not found"
NAMESPACE="hotrod-devmesh"
fi
# run the cli
# setting the gitsha to a short version to respect the name
# limit (30 chars)
docker run -i \
-e SIGNADOT_ORG=${SIGNADOT_ORG} \
-e SIGNADOT_API_KEY=${SIGNADOT_API_KEY} \
signadot/signadot-cli \
/signadot sandbox apply \
--set github-pr=${{ github.event.number }} \
--set image=signadot/hotrod:${IMAGE_TAG} \
--set branch=${{ github.head_ref }} \
--set name=pr-${{ github.event.number }}-route \
--set service=route \
--set namespace=${NAMESPACE} \
-f - \
-o yaml \
< ${GITHUB_WORKSPACE}/.signadot/sbx-template.yaml \
> ${GITHUB_WORKSPACE}/.signadot/sbx-response.yaml
go install github.com/mikefarah/yq/v4@latest
- id: get-comment-body
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
run: |
body="https://app.signadot.com/sandbox/name/$(yq -r '.name' ${GITHUB_WORKSPACE}/.signadot/sbx-response.yaml)"
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "::set-output name=body::$body"
- name: Find Comment
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Sandbox
- name: Create or update comment
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body: |
Sandbox Ready!
${{ steps.get-comment-body.outputs.body }}
edit-mode: replace
# - name: Test Sandbox
# run: |
# sleep 20 # just to make sure our sandbox is ready.
# endpoint=$(yq '.endpoints[0].url' ${GITHUB_WORKSPACE}/.signadot/sbx-response.yaml)
# pushd .
# cd test
# npm install
# # don't exit with error code if test fails and fail action.
# ENDPOINT=$endpoint SIGNADOT_API_KEY=${{ secrets.SIGNADOT_API_KEY }} npm test || true
# popd
# - name: Publish Test Results
# uses: EnricoMi/publish-unit-test-result-action/composite@v2
# with:
# files: |
# test/*.xml
sandbox-frontend:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && needs.changes.outputs.frontend == 'true' }}
needs: [ build, changes ]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Create Sandbox
id: create-sandbox
env:
SIGNADOT_ORG: signadot
SIGNADOT_API_KEY: ${{ secrets.SIGNADOT_API_KEY }}
IMAGE_TAG: ${{ github.sha }}-linux-amd64
run: |
echo "Checking for labels..."
LABELS="${{ toJSON(github.event.pull_request.labels.*.name) }}"
echo "Labels on PR: $LABELS"
if [[ "$LABELS" == *"istio"* ]]; then
echo "Found istio label"
NAMESPACE="hotrod-istio"
else
echo "istio label not found"
NAMESPACE="hotrod-devmesh"
fi
# run the cli
# setting the gitsha to a short version to respect the name
# limit (30 chars)
docker run -i \
-e SIGNADOT_ORG=${SIGNADOT_ORG} \
-e SIGNADOT_API_KEY=${SIGNADOT_API_KEY} \
signadot/signadot-cli \
/signadot sandbox apply \
--set github-pr=${{ github.event.number }} \
--set image=signadot/hotrod:${IMAGE_TAG} \
--set branch=${{ github.head_ref }} \
--set name=pr-${{ github.event.number }}-frontend \
--set service=frontend \
--set namespace=${NAMESPACE} \
-f - \
-o yaml \
< ${GITHUB_WORKSPACE}/.signadot/sbx-template.yaml \
> ${GITHUB_WORKSPACE}/.signadot/sbx-response.yaml
go install github.com/mikefarah/yq/v4@latest
- id: get-comment-body
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
run: |
body="https://app.signadot.com/sandbox/name/$(yq -r '.name' ${GITHUB_WORKSPACE}/.signadot/sbx-response.yaml)"
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "::set-output name=body::$body"
- name: Find Comment
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Sandbox
- name: Create or update comment
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body: |
Sandbox Ready!
${{ steps.get-comment-body.outputs.body }}
edit-mode: replace
sandbox-location:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && needs.changes.outputs.location == 'true' }}
needs: [ build, changes ]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Create Sandbox
id: create-sandbox
env:
SIGNADOT_ORG: signadot
SIGNADOT_API_KEY: ${{ secrets.SIGNADOT_API_KEY }}
IMAGE_TAG: ${{ github.sha }}-linux-amd64
run: |
echo "Checking for labels..."
LABELS="${{ toJSON(github.event.pull_request.labels.*.name) }}"
echo "Labels on PR: $LABELS"
if [[ "$LABELS" == *"istio"* ]]; then
echo "Found istio label"
NAMESPACE="hotrod-istio"
else
echo "istio label not found"
NAMESPACE="hotrod-devmesh"
fi
# run the cli
# setting the gitsha to a short version to respect the name
# limit (30 chars)
docker run -i \
-e SIGNADOT_ORG=${SIGNADOT_ORG} \
-e SIGNADOT_API_KEY=${SIGNADOT_API_KEY} \
signadot/signadot-cli \
/signadot sandbox apply \
--set github-pr=${{ github.event.number }} \
--set image=signadot/hotrod:${IMAGE_TAG} \
--set branch=${{ github.head_ref }} \
--set name=pr-${{ github.event.number }}-location \
--set service=location \
--set namespace=${NAMESPACE} \
-f - \
-o yaml \
< ${GITHUB_WORKSPACE}/.signadot/sbx-template.yaml \
> ${GITHUB_WORKSPACE}/.signadot/sbx-response.yaml
go install github.com/mikefarah/yq/v4@latest
- id: get-comment-body
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
run: |
body="https://app.signadot.com/sandbox/name/$(yq -r '.name' ${GITHUB_WORKSPACE}/.signadot/sbx-response.yaml)"
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "::set-output name=body::$body"
- name: Find Comment
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Sandbox
- name: Create or update comment
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body: |
Sandbox Ready!
${{ steps.get-comment-body.outputs.body }}
edit-mode: replace
sandbox-driver:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && needs.changes.outputs.driver == 'true' }}
needs: [ build, changes ]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Create Sandbox
id: create-sandbox
env:
SIGNADOT_ORG: signadot
SIGNADOT_API_KEY: ${{ secrets.SIGNADOT_API_KEY }}
IMAGE_TAG: ${{ github.sha }}-linux-amd64
run: |
echo "Checking for labels..."
LABELS="${{ toJSON(github.event.pull_request.labels.*.name) }}"
echo "Labels on PR: $LABELS"
if [[ "$LABELS" == *"istio"* ]]; then
echo "Found istio label"
NAMESPACE="hotrod-istio"
else
echo "istio label not found"
NAMESPACE="hotrod-devmesh"
fi
# run the cli
# setting the gitsha to a short version to respect the name
# limit (30 chars)
docker run -i \
-e SIGNADOT_ORG=${SIGNADOT_ORG} \
-e SIGNADOT_API_KEY=${SIGNADOT_API_KEY} \
signadot/signadot-cli \
/signadot sandbox apply \
--set github-pr=${{ github.event.number }} \
--set image=signadot/hotrod:${IMAGE_TAG} \
--set branch=${{ github.head_ref }} \
--set name=pr-${{ github.event.number }}-driver \
--set service=driver \
--set namespace=${NAMESPACE} \
-f - \
-o yaml \
< ${GITHUB_WORKSPACE}/.signadot/sbx-template.yaml \
> ${GITHUB_WORKSPACE}/.signadot/sbx-response.yaml
go install github.com/mikefarah/yq/v4@latest
- id: get-comment-body
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
run: |
body="https://app.signadot.com/sandbox/name/$(yq -r '.name' ${GITHUB_WORKSPACE}/.signadot/sbx-response.yaml)"
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "::set-output name=body::$body"
- name: Find Comment
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Sandbox
- name: Create or update comment
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body: |
Sandbox Ready!
${{ steps.get-comment-body.outputs.body }}
edit-mode: replace