|
| 1 | +name: Test Apache Airflow on Arm64 |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + workflow_dispatch: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + - smoke_tests |
| 10 | + paths: |
| 11 | + - 'content/opensource_packages/apache_airflow.md' |
| 12 | + - '.github/workflows/test-airflow.yml' |
| 13 | + |
| 14 | +jobs: |
| 15 | + test-airflow: |
| 16 | + runs-on: ubuntu-24.04-arm |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Set test metadata |
| 23 | + id: metadata |
| 24 | + run: | |
| 25 | + echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT |
| 26 | + echo "package_slug=apache_airflow" >> $GITHUB_OUTPUT |
| 27 | + echo "dashboard_link=/opensource_packages/apache_airflow" >> $GITHUB_OUTPUT |
| 28 | + |
| 29 | + - name: Install Python |
| 30 | + uses: actions/setup-python@v5 |
| 31 | + with: |
| 32 | + python-version: '3.10' |
| 33 | + |
| 34 | + - name: Install Apache Airflow |
| 35 | + id: install |
| 36 | + run: | |
| 37 | + echo "Installing Apache Airflow..." |
| 38 | + # Using version 2.8.1 |
| 39 | + # Need to set AIRFLOW_HOME |
| 40 | + export AIRFLOW_HOME=~/airflow |
| 41 | + |
| 42 | + # Install with constraints to ensure compatibility |
| 43 | + CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-2.8.1/constraints-3.10.txt" |
| 44 | + pip install "apache-airflow==2.8.1" --constraint "${CONSTRAINT_URL}" |
| 45 | + |
| 46 | + echo "install_status=success" >> $GITHUB_OUTPUT |
| 47 | + |
| 48 | + - name: Get Airflow version |
| 49 | + id: version |
| 50 | + run: | |
| 51 | + VERSION=$(airflow version | head -n 1) |
| 52 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 53 | + echo "Detected Airflow version: $VERSION" |
| 54 | + |
| 55 | + - name: Test 1 - Check Version Command |
| 56 | + id: test1 |
| 57 | + run: | |
| 58 | + START_TIME=$(date +%s) |
| 59 | + |
| 60 | + if airflow version | grep -q "2.8.1"; then |
| 61 | + echo "✓ airflow version check passed" |
| 62 | + echo "status=passed" >> $GITHUB_OUTPUT |
| 63 | + else |
| 64 | + echo "✗ airflow version check failed" |
| 65 | + airflow version |
| 66 | + echo "status=failed" >> $GITHUB_OUTPUT |
| 67 | + exit 1 |
| 68 | + fi |
| 69 | + |
| 70 | + END_TIME=$(date +%s) |
| 71 | + echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT |
| 72 | + |
| 73 | + - name: Test 2 - Initialize Database |
| 74 | + id: test2 |
| 75 | + run: | |
| 76 | + START_TIME=$(date +%s) |
| 77 | + |
| 78 | + export AIRFLOW_HOME=~/airflow |
| 79 | + |
| 80 | + if airflow db init; then |
| 81 | + echo "✓ airflow db init passed" |
| 82 | + echo "status=passed" >> $GITHUB_OUTPUT |
| 83 | + else |
| 84 | + echo "✗ airflow db init failed" |
| 85 | + echo "status=failed" >> $GITHUB_OUTPUT |
| 86 | + exit 1 |
| 87 | + fi |
| 88 | + |
| 89 | + END_TIME=$(date +%s) |
| 90 | + echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT |
| 91 | +
|
| 92 | + - name: Test 3 - Check Config List |
| 93 | + id: test3 |
| 94 | + run: | |
| 95 | + START_TIME=$(date +%s) |
| 96 | + |
| 97 | + export AIRFLOW_HOME=~/airflow |
| 98 | + |
| 99 | + if airflow config list | grep -q "core"; then |
| 100 | + echo "✓ airflow config list passed" |
| 101 | + echo "status=passed" >> $GITHUB_OUTPUT |
| 102 | + else |
| 103 | + echo "✗ airflow config list failed" |
| 104 | + echo "status=failed" >> $GITHUB_OUTPUT |
| 105 | + exit 1 |
| 106 | + fi |
| 107 | + |
| 108 | + END_TIME=$(date +%s) |
| 109 | + echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT |
| 110 | +
|
| 111 | + - name: Test 4 - Create User |
| 112 | + id: test4 |
| 113 | + run: | |
| 114 | + START_TIME=$(date +%s) |
| 115 | + |
| 116 | + export AIRFLOW_HOME=~/airflow |
| 117 | + |
| 118 | + if airflow users create \ |
| 119 | + --username admin \ |
| 120 | + --firstname Peter \ |
| 121 | + --lastname Parker \ |
| 122 | + --role Admin \ |
| 123 | + --email spiderman@superhero.org \ |
| 124 | + --password admin; then |
| 125 | + echo "✓ airflow user creation passed" |
| 126 | + echo "status=passed" >> $GITHUB_OUTPUT |
| 127 | + else |
| 128 | + echo "✗ airflow user creation failed" |
| 129 | + echo "status=failed" >> $GITHUB_OUTPUT |
| 130 | + exit 1 |
| 131 | + fi |
| 132 | + |
| 133 | + END_TIME=$(date +%s) |
| 134 | + echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT |
| 135 | +
|
| 136 | + - name: Test 5 - Check Users List |
| 137 | + id: test5 |
| 138 | + run: | |
| 139 | + START_TIME=$(date +%s) |
| 140 | + |
| 141 | + export AIRFLOW_HOME=~/airflow |
| 142 | + |
| 143 | + if airflow users list | grep -q "admin"; then |
| 144 | + echo "✓ airflow users list passed" |
| 145 | + echo "status=passed" >> $GITHUB_OUTPUT |
| 146 | + else |
| 147 | + echo "✗ airflow users list failed" |
| 148 | + echo "status=failed" >> $GITHUB_OUTPUT |
| 149 | + exit 1 |
| 150 | + fi |
| 151 | + |
| 152 | + END_TIME=$(date +%s) |
| 153 | + echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT |
| 154 | +
|
| 155 | + - name: Calculate test summary |
| 156 | + if: always() |
| 157 | + id: summary |
| 158 | + run: | |
| 159 | + PASSED=0 |
| 160 | + FAILED=0 |
| 161 | + TOTAL_DURATION=0 |
| 162 | + |
| 163 | + process_test() { |
| 164 | + local status=$1 |
| 165 | + local duration=$2 |
| 166 | + if [ "$status" == "passed" ]; then |
| 167 | + PASSED=$((PASSED + 1)) |
| 168 | + elif [ "$status" == "failed" ]; then |
| 169 | + FAILED=$((FAILED + 1)) |
| 170 | + fi |
| 171 | + TOTAL_DURATION=$((TOTAL_DURATION + duration)) |
| 172 | + } |
| 173 | + |
| 174 | + process_test "${{ steps.test1.outputs.status }}" "${{ steps.test1.outputs.duration || 0 }}" |
| 175 | + process_test "${{ steps.test2.outputs.status }}" "${{ steps.test2.outputs.duration || 0 }}" |
| 176 | + process_test "${{ steps.test3.outputs.status }}" "${{ steps.test3.outputs.duration || 0 }}" |
| 177 | + process_test "${{ steps.test4.outputs.status }}" "${{ steps.test4.outputs.duration || 0 }}" |
| 178 | + process_test "${{ steps.test5.outputs.status }}" "${{ steps.test5.outputs.duration || 0 }}" |
| 179 | + |
| 180 | + echo "passed=$PASSED" >> $GITHUB_OUTPUT |
| 181 | + echo "failed=$FAILED" >> $GITHUB_OUTPUT |
| 182 | + echo "duration=$TOTAL_DURATION" >> $GITHUB_OUTPUT |
| 183 | + |
| 184 | + if [ $FAILED -eq 0 ]; then |
| 185 | + echo "overall_status=success" >> $GITHUB_OUTPUT |
| 186 | + echo "badge_status=passing" >> $GITHUB_OUTPUT |
| 187 | + else |
| 188 | + echo "overall_status=failure" >> $GITHUB_OUTPUT |
| 189 | + echo "badge_status=failing" >> $GITHUB_OUTPUT |
| 190 | + fi |
| 191 | + |
| 192 | + - name: Generate test results JSON |
| 193 | + if: always() |
| 194 | + run: | |
| 195 | + mkdir -p test-results |
| 196 | + |
| 197 | + cat > test-results/apache_airflow.json << EOF |
| 198 | + { |
| 199 | + "schema_version": "1.0", |
| 200 | + "package": { |
| 201 | + "name": "Apache Airflow", |
| 202 | + "version": "${{ steps.version.outputs.version }}", |
| 203 | + "language": "Python", |
| 204 | + "category": "Workflow Orchestration" |
| 205 | + }, |
| 206 | + "run": { |
| 207 | + "id": "${{ github.run_id }}", |
| 208 | + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", |
| 209 | + "timestamp": "${{ steps.metadata.outputs.timestamp }}", |
| 210 | + "status": "${{ steps.summary.outputs.overall_status }}", |
| 211 | + "runner": { |
| 212 | + "os": "ubuntu-24.04", |
| 213 | + "arch": "arm64" |
| 214 | + } |
| 215 | + }, |
| 216 | + "tests": { |
| 217 | + "passed": ${{ steps.summary.outputs.passed }}, |
| 218 | + "failed": ${{ steps.summary.outputs.failed }}, |
| 219 | + "skipped": 0, |
| 220 | + "duration_seconds": ${{ steps.summary.outputs.duration }}, |
| 221 | + "details": [ |
| 222 | + { |
| 223 | + "name": "Check Version Command", |
| 224 | + "status": "${{ steps.test1.outputs.status }}", |
| 225 | + "duration_seconds": ${{ steps.test1.outputs.duration || 0 }} |
| 226 | + }, |
| 227 | + { |
| 228 | + "name": "Initialize Database", |
| 229 | + "status": "${{ steps.test2.outputs.status }}", |
| 230 | + "duration_seconds": ${{ steps.test2.outputs.duration || 0 }} |
| 231 | + }, |
| 232 | + { |
| 233 | + "name": "Check Config List", |
| 234 | + "status": "${{ steps.test3.outputs.status }}", |
| 235 | + "duration_seconds": ${{ steps.test3.outputs.duration || 0 }} |
| 236 | + }, |
| 237 | + { |
| 238 | + "name": "Create User", |
| 239 | + "status": "${{ steps.test4.outputs.status }}", |
| 240 | + "duration_seconds": ${{ steps.test4.outputs.duration || 0 }} |
| 241 | + }, |
| 242 | + { |
| 243 | + "name": "Check Users List", |
| 244 | + "status": "${{ steps.test5.outputs.status }}", |
| 245 | + "duration_seconds": ${{ steps.test5.outputs.duration || 0 }} |
| 246 | + } |
| 247 | + ] |
| 248 | + }, |
| 249 | + "metadata": { |
| 250 | + "dashboard_link": "${{ steps.metadata.outputs.dashboard_link }}", |
| 251 | + "badge_status": "${{ steps.summary.outputs.badge_status }}" |
| 252 | + } |
| 253 | + } |
| 254 | + EOF |
| 255 | + |
| 256 | + echo "Generated test results:" |
| 257 | + cat test-results/apache_airflow.json |
| 258 | + |
| 259 | + - name: Upload test results |
| 260 | + if: always() |
| 261 | + uses: actions/upload-artifact@v4 |
| 262 | + with: |
| 263 | + name: apache_airflow-test-results |
| 264 | + path: test-results/apache_airflow.json |
| 265 | + retention-days: 90 |
| 266 | + |
| 267 | + - name: Commit test results to repository |
| 268 | + if: always() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/smoke_tests') |
| 269 | + run: | |
| 270 | + git config --global user.name 'github-actions[bot]' |
| 271 | + git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
| 272 | + |
| 273 | + mkdir -p data/test-results |
| 274 | + cp test-results/apache_airflow.json data/test-results/apache_airflow.json |
| 275 | + |
| 276 | + git add data/test-results/apache_airflow.json |
| 277 | + |
| 278 | + if ! git diff --staged --quiet; then |
| 279 | + git commit -m "Update Apache Airflow test results [skip ci]" |
| 280 | + for i in {1..5}; do |
| 281 | + if git pull --rebase origin ${{ github.ref_name }}; then |
| 282 | + if git push; then |
| 283 | + echo "Successfully pushed test results" |
| 284 | + break |
| 285 | + fi |
| 286 | + else |
| 287 | + echo "Rebase failed, resolving conflicts..." |
| 288 | + git checkout --ours data/test-results/apache_airflow.json |
| 289 | + git add data/test-results/apache_airflow.json |
| 290 | + git rebase --continue || true |
| 291 | + fi |
| 292 | + sleep $((i * 2)) |
| 293 | + done |
| 294 | + else |
| 295 | + echo "No changes to commit" |
| 296 | + fi |
| 297 | + |
| 298 | + - name: Create test summary |
| 299 | + if: always() |
| 300 | + run: | |
| 301 | + echo "## Apache Airflow Test Results" >> $GITHUB_STEP_SUMMARY |
| 302 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 303 | + echo "- **Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY |
| 304 | + echo "- **Status:** ${{ steps.summary.outputs.overall_status }}" >> $GITHUB_STEP_SUMMARY |
| 305 | + echo "- **Tests Passed:** ${{ steps.summary.outputs.passed }}" >> $GITHUB_STEP_SUMMARY |
| 306 | + echo "- **Tests Failed:** ${{ steps.summary.outputs.failed }}" >> $GITHUB_STEP_SUMMARY |
| 307 | + echo "- **Duration:** ${{ steps.summary.outputs.duration }}s" >> $GITHUB_STEP_SUMMARY |
| 308 | + echo "- **Runner:** ubuntu-24.04 (arm64)" >> $GITHUB_STEP_SUMMARY |
0 commit comments