test.yaml
1 # Copyright 2024 Defense Unicorns 2 # SPDX-License-Identifier: AGPL-3.0-or-later OR LicenseRef-Defense-Unicorns-Commercial 3 4 variables: 5 - name: EXCLUDED_PACKAGES 6 description: A comma separated string of packages to be excluded from validation and e2e tests. 7 default: "" 8 9 includes: 10 - create: ./create.yaml 11 - setup: ./setup.yaml 12 - deploy: ./deploy.yaml 13 - util: ./utils.yaml 14 - test-resources: ../src/test/tasks.yaml 15 - base-layer: ../packages/base/tasks.yaml 16 - idam-layer: ../packages/identity-authorization/tasks.yaml 17 - common-setup: https://raw.githubusercontent.com/defenseunicorns/uds-common/v1.22.1/tasks/setup.yaml 18 - private-pki: ../test/playwright/private-pki/tasks.yaml 19 - trust-bundle: ../test/vitest/trust-bundle/tasks.yaml 20 21 22 tasks: 23 - name: base 24 description: "Build and test the base layer" 25 actions: 26 - task: create:pepr-build 27 - task: setup:k3d-test-cluster 28 - cmd: uds run -f tasks/test.yaml single-layer --set FLAVOR=${FLAVOR} --set=layer=base 29 30 - name: single-layer 31 description: "Build and test a single layer, must set UDS_LAYER environment variable" 32 inputs: 33 create_options: 34 default: "--skip-sbom" 35 description: "Additional options passed in when creating Zarf packages. Defaults to: --skip-sbom" 36 actions: 37 - task: create:single-layer 38 with: 39 layer: ${LAYER} 40 create_options: ${{ .inputs.create_options }} 41 - task: deploy:single-layer 42 with: 43 layer: ${LAYER} 44 - task: validate-package 45 with: 46 layer: ${LAYER} 47 48 - name: layer-dependencies 49 description: "Sets up a k3d cluster and deploys dependencies for the given layer" 50 actions: 51 - task: setup:k3d-test-cluster 52 - cmd: uds zarf tools yq '.metadata.x-uds-dependencies.[]' packages/${LAYER}/zarf.yaml 2>/dev/null 53 mute: true 54 setVariables: 55 - name: LAYER_DEPS 56 - cmd: | 57 for dep in $LAYER_DEPS; do 58 uds run -f tasks/test.yaml single-layer --set LAYER=$dep --set FLAVOR=${FLAVOR} --no-progress 59 done 60 61 - name: validate-packages 62 description: "Validate all packages" 63 inputs: 64 # Added to support bypassing passthrough gateway validation on non-k3d distributions. 65 validate_passthrough: 66 description: Whether to validate the passthrough gateway. 67 default: "true" 68 # loop through each src/* package and run the validate.yaml task 69 actions: 70 - cmd: | 71 for package in $(ls src); do 72 if [ ! $(echo ${EXCLUDED_PACKAGES} | grep ${package}) ]; then 73 if [ ${package} = "istio" ]; then 74 uds run -f src/${package}/tasks.yaml validate --no-progress --with validate_passthrough=${{ .inputs.validate_passthrough }} 75 else 76 uds run -f src/${package}/tasks.yaml validate --no-progress 77 fi 78 fi 79 done 80 set +e 81 82 - name: validate-package 83 description: "Validate a single package" 84 inputs: 85 layer: 86 description: The UDS Core layer to validate 87 required: true 88 actions: 89 - cmd: | 90 uds run -f packages/${{ index .inputs "layer" }}/tasks.yaml validate --no-progress 91 92 - name: e2e-tests 93 description: "E2E Test all packages" 94 inputs: 95 architecture: 96 description: "System architecture that the test-apps package should be built for." 97 required: true 98 default: ${UDS_ARCH} 99 # Run each e2e test type from the e2e folder 100 actions: 101 - description: "Setup the Doug User for testing" 102 task: common-setup:keycloak-user 103 with: 104 group: "/UDS Core/Admin" 105 - description: "Create and Deploy Test App Package" 106 task: test-resources:create-deploy 107 with: 108 architecture: ${{ .inputs.architecture }} 109 - description: "Run Playwright E2E tests for all packages" 110 dir: test/playwright 111 cmd: | 112 # renovate: datasource=docker depName=mcr.microsoft.com/playwright versioning=docker 113 docker run --rm --ipc=host --net=host -e FULL_CORE="true" --mount type=bind,source="$(pwd)",target=/app mcr.microsoft.com/playwright:v1.57.0-noble sh -c " \ 114 cd app && \ 115 npm ci && \ 116 npx playwright test \ 117 " 118 - description: "Run E2E Tests" 119 cmd: | 120 npm ci 121 npx vitest run 122 dir: test/vitest 123 - description: remove test resources 124 task: test-resources:remove 125 126 - name: unit-tests 127 description: "Run all unit tests for uds-core" 128 actions: 129 - cmd: | 130 npm ci 131 npx vitest run 132 133 - name: uds-core 134 description: "Build and test UDS Core" 135 inputs: 136 K3D_EXTRA_ARGS: 137 default: "" 138 description: "Extra args for k3d" 139 actions: 140 - task: create:standard-package 141 with: 142 create_options: "--skip-sbom" 143 - task: create:k3d-standard-bundle 144 - task: deploy:k3d-standard-bundle 145 with: 146 K3D_EXTRA_ARGS: "${{ .inputs.K3D_EXTRA_ARGS }}" 147 - task: validate-packages 148 149 - name: uds-core-e2e 150 description: "Build and test UDS Core e2e" 151 actions: 152 - task: uds-core 153 - task: e2e-tests 154 155 - name: uds-core-non-k3d 156 description: "Validate and Test UDS Core deployment on a non K3d Cluster" 157 actions: 158 - task: util:setup-hosts 159 - task: validate-packages 160 with: 161 validate_passthrough: "false" 162 - task: e2e-tests 163 with: 164 architecture: "amd64" 165 166 - name: uds-core-ha 167 description: "Build and test UDS Core" 168 actions: 169 - task: create:standard-package 170 with: 171 create_options: "--skip-sbom" 172 - task: create:k3d-standard-bundle 173 - task: deploy:k3d-standard-bundle-ha 174 - task: validate-packages 175 176 - name: uds-core-ha-upgrade 177 description: "Test an upgrade from the latest released UDS Core package with HA to current branch with HA" 178 actions: 179 - task: uds-core-upgrade 180 with: 181 configFile: "bundles/k3d-standard/uds-ha-config.yaml" 182 183 - name: uds-core-upgrade 184 inputs: 185 configFile: 186 description: "UDS_CONFIG file to use for the deployments" 187 description: "Test an upgrade from the latest released UDS Core package to current branch" 188 actions: 189 - task: deploy:latest-bundle-release 190 with: 191 configFile: ${{ .inputs.configFile }} 192 - task: deploy:latest-release-test-resources 193 - task: create:standard-package 194 with: 195 create_options: "--skip-sbom" 196 - task: create:k3d-standard-bundle 197 # Note: we want to deploy from the bundle since we need overrides, but we don't want to redeploy k3d/zarf init so we pass `--packages` here 198 - cmd: | 199 # Set UDS_CONFIG for bundle deployment 200 export UDS_CONFIG="${{ .inputs.configFile }}" 201 uds deploy bundles/k3d-standard/uds-bundle-k3d-core-demo-${UDS_ARCH}-${VERSION}.tar.zst --set FALCO_SANDBOX_RULES_ENABLED=true --set FALCO_INCUBATING_RULES_ENABLED=true --packages core --confirm --no-progress 202 - task: validate-packages 203 - task: e2e-tests 204 205 - name: slim-dev 206 description: "Run validate for the components contained in the slim dev bundle" 207 actions: 208 - task: base-layer:validate 209 with: 210 validate_passthrough: "false" 211 - task: idam-layer:validate 212 - task: test-resources:e2e-test 213 with: 214 validate_egress: "false" 215 216 - name: uds-core-private-pki 217 description: "Create and Deploy Private PKI Bundle" 218 actions: 219 - task: private-pki:private-pki-certs 220 - task: create:standard-package 221 with: 222 create_options: "--skip-sbom" 223 - task: create:k3d-standard-bundle 224 - task: deploy:k3d-standard-bundle-private-pki 225 - task: validate-packages 226 - description: "Setup the Doug User for testing" 227 task: common-setup:keycloak-user 228 with: 229 group: "/UDS Core/Admin" 230 - description: "Setup Authservice App for Testing" 231 cmd: | 232 uds zarf tools kubectl apply -f src/test/app-ambient-authservice-tenant-package.yaml 233 uds zarf tools kubectl label namespace authservice-ambient-test-app zarf.dev/agent=ignore 234 uds zarf tools kubectl apply -f src/test/app-ambient-authservice-tenant.yaml 235 - task: private-pki:private-pki-tests 236 - task: trust-bundle:trust-bundle-tests