|
| 1 | +--- |
| 2 | +name: Running hyperconverged smoke tests |
| 3 | + |
| 4 | +"on": |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + acmeEmail: |
| 8 | + description: Set email for ACME |
| 9 | + required: true |
| 10 | + |
| 11 | + type: string |
| 12 | + gatewayDomain: |
| 13 | + description: Set domain for the gateway |
| 14 | + required: true |
| 15 | + default: cloud.local |
| 16 | + type: string |
| 17 | + sshUsername: |
| 18 | + description: Set SSH username |
| 19 | + required: true |
| 20 | + default: "ubuntu" |
| 21 | + type: choice |
| 22 | + options: |
| 23 | + - "ubuntu" |
| 24 | + - "debian" |
| 25 | + mode: |
| 26 | + description: Set mode |
| 27 | + required: true |
| 28 | + default: "test" |
| 29 | + type: choice |
| 30 | + options: |
| 31 | + - "test" |
| 32 | + - "deploy" |
| 33 | + - "cleanup" |
| 34 | + run_tests: |
| 35 | + description: Run post-deployment tests |
| 36 | + required: false |
| 37 | + default: true |
| 38 | + type: boolean |
| 39 | + test_level: |
| 40 | + description: Test level to run |
| 41 | + required: false |
| 42 | + default: "quick" |
| 43 | + type: choice |
| 44 | + options: |
| 45 | + - "quick" |
| 46 | + - "standard" |
| 47 | + - "full" |
| 48 | + pull_request: |
| 49 | + paths: |
| 50 | + - ansible/** |
| 51 | + - base-kustomize/** |
| 52 | + - base-helm-configs/** |
| 53 | + - bin/** |
| 54 | + - scripts/** |
| 55 | + - ".github/workflows/smoke-deploy-lab.yaml" |
| 56 | + |
| 57 | +env: |
| 58 | + HYPERCONVERGED_DEV: "true" |
| 59 | + GATEWAY_DOMAIN: cloud.local |
| 60 | + OS_FLAVOR: gp.5.8.16 |
| 61 | + JUMP_HOST_FLAVOR: gp.5.2.2 |
| 62 | + |
| 63 | + SSH_USERNAME: "ubuntu" |
| 64 | + TEST_LEVEL: "quick" |
| 65 | + |
| 66 | +jobs: |
| 67 | + smoke-deploy: |
| 68 | + runs-on: self-hosted |
| 69 | + container: |
| 70 | + image: localhost:5000/genestack-ci:latest |
| 71 | + steps: |
| 72 | + - name: Checkout repository |
| 73 | + uses: actions/checkout@v4 |
| 74 | + |
| 75 | + - name: Dynamically set MY_DATE environment variable |
| 76 | + if: ${{ github.event_name == 'pull_request' }} |
| 77 | + run: echo "LAB_NAME_PREFIX=smoke-$(date +%s)" >> $GITHUB_ENV |
| 78 | + |
| 79 | + - name: Statically set environment variable |
| 80 | + if: ${{ github.event_name == 'workflow_dispatch' }} |
| 81 | + run: | |
| 82 | + echo "LAB_NAME_PREFIX=$(echo '${{ github.event.inputs.gatewayDomain }}' | tr '.' '-')" >> $GITHUB_ENV |
| 83 | + echo "GATEWAY_DOMAIN=${{ github.event.inputs.gatewayDomain }}" >> $GITHUB_ENV |
| 84 | + echo "ACME_EMAIL=${{ github.event.inputs.acmeEmail }}" >> $GITHUB_ENV |
| 85 | + echo "SSH_USERNAME=${{ github.event.inputs.sshUsername }}" >> $GITHUB_ENV |
| 86 | + |
| 87 | + - name: Run deployment script |
| 88 | + if: ${{ github.event_name == 'pull_request' || contains(fromJSON('["deploy", "test"]'), github.event.inputs.mode) }} |
| 89 | + run: | |
| 90 | + eval "$(ssh-agent -s)" |
| 91 | + export TEST_LEVEL="${{ github.event.inputs.test_level }}" |
| 92 | + scripts/hyperconverged-lab.sh talos |
| 93 | + |
| 94 | + - name: Retrieve Keys |
| 95 | + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.mode == 'deploy' }} |
| 96 | + uses: actions/upload-artifact@v4 |
| 97 | + with: |
| 98 | + name: ssh-keys |
| 99 | + if-no-files-found: warn # 'warn' or 'ignore' are also available, defaults to `warn` |
| 100 | + path: "/github/home/.ssh/${{ env.LAB_NAME_PREFIX }}-key.pem" |
| 101 | + |
| 102 | + - name: Create output file in markdown format |
| 103 | + run: | |
| 104 | + if [ -s /tmp/output.txt ]; then |
| 105 | + echo "### Cloud Access" > access-output.txt |
| 106 | + cat /tmp/output.txt >> access-output.txt |
| 107 | + fi |
| 108 | + |
| 109 | + - name: Publish Output to Summary |
| 110 | + run: | |
| 111 | + if [ -s access-output.txt ]; then |
| 112 | + { |
| 113 | + cat access-output.txt |
| 114 | + } >> $GITHUB_STEP_SUMMARY |
| 115 | + fi |
| 116 | + |
| 117 | + - name: Upload Test Results |
| 118 | + if: ${{ always() && (github.event_name == 'pull_request' || (github.event.inputs.run_tests == 'true' && contains(fromJSON('["deploy", "test"]'), github.event.inputs.mode))) }} |
| 119 | + uses: actions/upload-artifact@v4 |
| 120 | + with: |
| 121 | + name: test-results-${{ github.run_number }} |
| 122 | + path: test-results/ |
| 123 | + if-no-files-found: ignore |
| 124 | + retention-days: 30 |
| 125 | + |
| 126 | + - name: Publish Test Summary |
| 127 | + if: ${{ always() && (github.event_name == 'pull_request' || (github.event.inputs.run_tests == 'true' && contains(fromJSON('["deploy", "test"]'), github.event.inputs.mode))) }} |
| 128 | + run: | |
| 129 | + echo "## Test Results" >> $GITHUB_STEP_SUMMARY |
| 130 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 131 | + |
| 132 | + if [ -f test-results/aggregate-results.txt ]; then |
| 133 | + echo "### Test Suite Summary" >> $GITHUB_STEP_SUMMARY |
| 134 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 135 | + echo "| Test Suite | Status |" >> $GITHUB_STEP_SUMMARY |
| 136 | + echo "|------------|--------|" >> $GITHUB_STEP_SUMMARY |
| 137 | + |
| 138 | + while IFS=: read -r suite status; do |
| 139 | + status=$(echo "$status" | xargs) |
| 140 | + if [ "$status" = "PASSED" ]; then |
| 141 | + echo "| $suite | :white_check_mark: PASSED |" >> $GITHUB_STEP_SUMMARY |
| 142 | + else |
| 143 | + echo "| $suite | :x: FAILED |" >> $GITHUB_STEP_SUMMARY |
| 144 | + fi |
| 145 | + done < test-results/aggregate-results.txt |
| 146 | + |
| 147 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 148 | + fi |
| 149 | + |
| 150 | + # Parse XML results if available |
| 151 | + if ls test-results/*.xml >/dev/null 2>&1; then |
| 152 | + echo "### Detailed Test Results" >> $GITHUB_STEP_SUMMARY |
| 153 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 154 | + |
| 155 | + for xml_file in test-results/*.xml; do |
| 156 | + if [ -f "$xml_file" ]; then |
| 157 | + suite_name=$(grep -o 'name="[^"]*"' "$xml_file" | head -1 | sed 's/name="//;s/"//') |
| 158 | + echo "#### $suite_name" >> $GITHUB_STEP_SUMMARY |
| 159 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 160 | + echo "| Test | Status |" >> $GITHUB_STEP_SUMMARY |
| 161 | + echo "|------|--------|" >> $GITHUB_STEP_SUMMARY |
| 162 | + |
| 163 | + grep -o '<testcase name="[^"]*"' "$xml_file" | sed 's/<testcase name="//;s/"$//' | while read test; do |
| 164 | + if grep -q "name=\"${test}\".*<failure" "$xml_file"; then |
| 165 | + echo "| $test | :x: Failed |" >> $GITHUB_STEP_SUMMARY |
| 166 | + elif grep -q "name=\"${test}\".*<skipped" "$xml_file"; then |
| 167 | + echo "| $test | :warning: Skipped |" >> $GITHUB_STEP_SUMMARY |
| 168 | + else |
| 169 | + echo "| $test | :white_check_mark: Passed |" >> $GITHUB_STEP_SUMMARY |
| 170 | + fi |
| 171 | + done |
| 172 | + |
| 173 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 174 | + fi |
| 175 | + done |
| 176 | + fi |
| 177 | + |
| 178 | + if [ ! -f test-results/aggregate-results.txt ] && ! ls test-results/*.xml >/dev/null 2>&1; then |
| 179 | + echo "_No test results available_" >> $GITHUB_STEP_SUMMARY |
| 180 | + fi |
| 181 | + |
| 182 | + - name: Cleanup the lab |
| 183 | + if: ${{ always() && (github.event_name == 'pull_request' || contains(fromJSON('["cleanup", "test"]'), github.event.inputs.mode)) }} |
| 184 | + run: scripts/hyperconverged-lab-uninstall.sh talos |
0 commit comments