-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (72 loc) · 2.89 KB
/
tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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