-
Notifications
You must be signed in to change notification settings - Fork 94
132 lines (116 loc) · 5.13 KB
/
platform-test.yml
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
---
name: Platform Test
# yamllint disable-line rule:truthy
on:
pull_request:
paths:
- 'charts/**'
- '!charts/k8s-monitoring-v1/**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
list-tests:
name: List tests
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.list_tests.outputs.tests }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: List tests
id: list_tests
run: |
allTests=$(find charts/k8s-monitoring/tests/platform -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | jq --raw-input --slurp --compact-output 'split("\n") | map(select(. != ""))')
if [ "${{ github.event_name }}" == "pull_request" ]; then
# All labels on this PR
labels='${{ toJson(github.event.pull_request.labels.*.name) }}'
# Filter out labels that don't start with "platform-test-" and remove the prefix
chosenTests=$(echo "${labels}" | jq --raw-output --compact-output '[.[] | select(startswith("platform-test-")) | sub("^platform-test-"; "")]')
# Choose the tests that match the labels
tests=$(jq --null-input --compact-output --argjson allTests "${allTests}" --argjson chosenTests "${chosenTests}" '$allTests | map(select(. as $test | $chosenTests | index($test)))')
else
tests="${allTests}"
fi
echo "Running tests: ${tests}"
echo "tests=${tests}" >> "${GITHUB_OUTPUT}"
run-tests:
name: Platform Test
needs: list-tests
runs-on: ubuntu-latest
if: ${{ needs.list-tests.outputs.tests != '[]' }}
strategy:
matrix:
test: ${{ fromJson(needs.list-tests.outputs.tests) }}
fail-fast: false
concurrency:
group: ${{ matrix.test || 'no-platform-test' }}
cancel-in-progress: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Helm
uses: azure/setup-helm@v4
- name: Setup Flux CLI
uses: fluxcd/flux2/action@main
- name: Random number
id: random-number
uses: yakubique/random-number@v1.1
with:
min: 100000
max: 999999
- name: Check for cluster config
id: check-cluster-config
run: |
if [ -f "charts/k8s-monitoring/tests/platform/${{ matrix.test }}/eks-cluster-config.yaml" ]; then
echo "cluster-type=eks" >> "${GITHUB_OUTPUT}"
elif [ -f "charts/k8s-monitoring/tests/platform/${{ matrix.test }}/gke-cluster-config.yaml" ]; then
echo "cluster-type=gke" >> "${GITHUB_OUTPUT}"
elif [ -f "charts/k8s-monitoring/tests/platform/${{ matrix.test }}/gke-autopilot-cluster-config.yaml" ]; then
echo "cluster-type=gke" >> "${GITHUB_OUTPUT}"
else
echo "cluster-type=kind" >> "${GITHUB_OUTPUT}"
fi
- name: Setup Kind CLI
if: ${{ steps.check-cluster-config.outputs.cluster-type == 'kind' }}
uses: helm/kind-action@v1
with:
install_only: true
- name: Setup eksctl CLI
if: ${{ steps.check-cluster-config.outputs.cluster-type == 'eks' }}
run: |
PLATFORM="$(uname -s)_$ARCH"
curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz"
tar -xzf "eksctl_$PLATFORM.tar.gz" -C /tmp && rm "eksctl_$PLATFORM.tar.gz"
sudo mv /tmp/eksctl /usr/local/bin
env:
ARCH: amd64
- name: Configure AWS Credentials
if: ${{ steps.check-cluster-config.outputs.cluster-type == 'eks' }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Configure GCP Credentials
if: ${{ steps.check-cluster-config.outputs.cluster-type == 'gke' }}
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GCP_SERVICE_ACCOUNT_TOKEN }}'
- name: Set up GCP Cloud SDK
if: ${{ steps.check-cluster-config.outputs.cluster-type == 'gke' }}
uses: google-github-actions/setup-gcloud@v2
with:
install_components: gke-gcloud-auth-plugin
- name: Run test
run: ./scripts/run-cluster-test.sh "charts/k8s-monitoring/tests/platform/${{ matrix.test }}"
env:
CREATE_CLUSTER: "true"
DELETE_CLUSTER: "true"
GRAFANA_CLOUD_FLEET_MGMT_USER: ${{ secrets.GRAFANA_CLOUD_FLEET_MGMT_USER }}
GRAFANA_CLOUD_FLEET_MGMT_TOKEN: ${{ secrets.GRAFANA_CLOUD_FLEET_MGMT_TOKEN }}
GRAFANA_CLOUD_METRICS_USERNAME: ${{ secrets.GRAFANA_CLOUD_METRICS_USERNAME }}
GRAFANA_CLOUD_LOGS_USERNAME: ${{ secrets.GRAFANA_CLOUD_LOGS_USERNAME }}
GRAFANA_CLOUD_TRACES_USERNAME: ${{ secrets.GRAFANA_CLOUD_TRACES_USERNAME }}
GRAFANA_CLOUD_OTLP_USERNAME: ${{ secrets.GRAFANA_CLOUD_OTLP_USERNAME }}
GRAFANA_CLOUD_RW_POLICY_TOKEN: ${{ secrets.GRAFANA_CLOUD_RW_POLICY_TOKEN }}
RANDOM_NUMBER: ${{ steps.random-number.outputs.number }}