Hackathon: Platform Cluster provisioning #237
Workflow file for this run
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: Platform Test | |
# yamllint disable-line rule:truthy | |
on: | |
push: | |
branches: ["main"] | |
paths: | |
- 'charts/**' | |
- '!charts/k8s-monitoring-v1/**' | |
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: | | |
if [ "${{ github.event_name }}" == "pull_request" ] && [ "${{contains(github.event.pull_request.labels.*.name, 'run-platform-tests')}}" != "true" ]; then | |
echo "Skipping platform tests" | |
echo "tests=[]" >> "${GITHUB_OUTPUT}" | |
exit 0 | |
fi | |
tests=$(ls charts/k8s-monitoring/tests/platform) | |
echo "Tests: ${tests}" | |
echo "tests=$(echo "${tests}" | jq --raw-input --slurp --compact-output 'split("\n") | map(select(. != ""))')" >> "${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: Check for cluster config | |
id: check-cluster-config | |
run: | | |
if [ -f "charts/k8s-monitoring/tests/integration/${{ matrix.test }}/gke-cluster-config.yaml" ]; then | |
echo "cluster-type=gke" >> "${GITHUB_OUTPUT}" | |
elif [ -f "charts/k8s-monitoring/tests/integration/${{ 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: Authenticate with GCP | |
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 Cloud SDK | |
if: ${{ steps.check-cluster-config.outputs.cluster-type == 'gke' }} | |
uses: google-github-actions/setup-gcloud@v2 | |
- name: Setup Flux CLI | |
uses: fluxcd/flux2/action@main | |
- name: Random number | |
id: random-number | |
uses: yakubique/[email protected] | |
with: | |
min: 100000 | |
max: 999999 | |
- name: Run test | |
run: ./scripts/run-integration-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_RW_POLICY_TOKEN: ${{ secrets.GRAFANA_CLOUD_RW_POLICY_TOKEN }} | |
RANDOM_NUMBER: ${{ steps.random-number.outputs.number }} |