Add validation webhook #856
This file contains 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: Tests | |
# Trigger the workflow on pull requests and direct pushes to any branch | |
on: | |
push: | |
pull_request: | |
jobs: | |
test: | |
name: ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
# Pull requests from the same repository won't trigger this checks as they were already triggered by the push | |
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) | |
steps: | |
- name: Clone the code | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '~1.22' | |
- name: Install Helm and Kubectl | |
if: matrix.os == 'macos-latest' | |
run: | | |
brew install helm | |
brew install kubectl | |
- name: Setup Minikube cluster | |
if: matrix.os != 'macos-latest' | |
uses: medyagh/setup-minikube@latest | |
# This step is needed as the following one tries to remove | |
# kustomize for each test but has no permission to do so | |
- name: Remove pre-installed kustomize | |
if: matrix.os != 'macos-latest' | |
run: sudo rm -f /usr/local/bin/kustomize | |
# Install vault to minikube cluster to test vault case with kubernetes auth | |
- name: Install and configure Vault | |
if: matrix.os != 'macos-latest' | |
env: | |
GITHUB_PRIVATE_KEY: ${{ secrets.GH_TEST_APP_PK }} | |
run: | | |
cd scripts | |
chmod +x install_and_setup_vault_k8s.sh | |
./install_and_setup_vault_k8s.sh | |
- name: Perform the test | |
if: matrix.os != 'macos-latest' | |
run: | | |
export "GITHUB_PRIVATE_KEY=${{ secrets.GH_TEST_APP_PK }}" | |
export "GH_APP_ID=${{ secrets.GH_APP_ID }}" | |
export "GH_INSTALL_ID=${{ secrets.GH_INSTALL_ID }}" | |
export "VAULT_ADDR=http://localhost:8200" | |
export "VAULT_ROLE_AUDIENCE=githubapp" | |
export "VAULT_ROLE=githubapp" | |
# Run vault port forward in background | |
kubectl port-forward vault-0 8200:8200 & | |
# Run tests | |
USE_EXISTING_CLUSTER=true make test | |
- name: Report failure | |
uses: nashmaniac/[email protected] | |
# Only report failures of pushes (PRs have are visible through the Checks section) to the default branch | |
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/main' | |
with: | |
title: 🐛 Unit tests failed on ${{ matrix.os }} for ${{ github.sha }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
labels: kind/bug | |
body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
- name: Send the coverage output | |
if: matrix.os != 'macos-latest' | |
uses: shogo82148/actions-goveralls@v1 | |
with: | |
path-to-profile: cover.out |