Skip to content

fix: [Policy Assistant] translate could grab labels from other pods #60

fix: [Policy Assistant] translate could grab labels from other pods

fix: [Policy Assistant] translate could grab labels from other pods #60

name: policy-assistant
on:
push:
branches:
- 'main'
- 'release*'
tags:
- 'v*'
paths:
- 'cmd/policy-assistant/**'
- '.github/workflows/policy-assistant.yml'
pull_request:
branches:
- 'main'
- 'release*'
paths:
- 'cmd/policy-assistant/**'
- '.github/workflows/policy-assistant.yml'
workflow_dispatch:
env:
GO_VERSION: "1.22.0"
permissions: write-all
jobs:
go-tests:
name: Go Tests
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Run Unit Tests
run: |
cd cmd/policy-assistant/
go test ./...
- name: Run Go Vet
run: |
cd cmd/policy-assistant/
go vet ./...
- name: Run Go Fmt
shell: bash
run: |
cd cmd/policy-assistant/
exitCode=0
go fmt ./... | grep "\.go" || exitCode=$?
if [[ $exitCode == 0 ]]; then
echo "please run 'make fmt' in the cmd/policy-assistant/ directory"
exit 1
else
echo "go files are properly formatted"
fi
build:
name: Build Policy Assistant
runs-on: ubuntu-22.04
needs: go-tests
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Build policy-assistant Binary
run: |
cd cmd/policy-assistant/
make policy-assistant
- name: Save policy-assistant Binary
run: |
mkdir -p artifacts
cp cmd/policy-assistant/cmd/policy-assistant/policy-assistant artifacts/
- name: Upload policy-assistant Binary
uses: actions/upload-artifact@v4
with:
name: policy-assistant-binary
path: artifacts/policy-assistant
integration-tests:
name: Integration Tests
runs-on: ubuntu-22.04
needs: build
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Download policy-assistant Binary
uses: actions/download-artifact@v4
with:
name: policy-assistant-binary
path: artifacts
- name: Set policy-assistant Binary Permissions
run: chmod u+x artifacts/policy-assistant
- name: Run Integration Test - Explain Mode
run: |
artifacts/policy-assistant analyze --mode explain --policy-path cmd/policy-assistant/examples/demos/kubecon-eu-2024/policies/
- name: Run Integration Test - Probe Mode
run: |
artifacts/policy-assistant analyze --mode probe --policy-path cmd/policy-assistant/examples/demos/kubecon-eu-2024/policies/ --probe-path cmd/policy-assistant/examples/demos/kubecon-eu-2024/demo-probe.json
- name: Run Integration Test - Walkthrough Mode
run: |
artifacts/policy-assistant analyze --mode walkthrough --policy-path cmd/policy-assistant/examples/demos/kubecon-eu-2024/policies/