|
| 1 | +name: Continuous Integration |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +jobs: |
| 10 | + pr-tests: |
| 11 | + if: github.event_name == 'pull_request' |
| 12 | + runs-on: ubuntu-latest |
| 13 | + name: Run Tests |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Ensure test scripts are executable |
| 19 | + run: | |
| 20 | + if compgen -G "test/*.sh" > /dev/null; then |
| 21 | + chmod +x test/*.sh |
| 22 | + fi |
| 23 | +
|
| 24 | + - name: Execute pull request tests |
| 25 | + run: | |
| 26 | + set -euo pipefail |
| 27 | + if compgen -G "test/*.sh" > /dev/null; then |
| 28 | + for test_script in test/*.sh; do |
| 29 | + echo "Running ${test_script}" |
| 30 | + bash "${test_script}" |
| 31 | + done |
| 32 | + else |
| 33 | + echo "No tests found in ./test" |
| 34 | + fi |
| 35 | +
|
| 36 | + pr-report: |
| 37 | + if: github.event_name == 'pull_request' |
| 38 | + runs-on: ubuntu-latest |
| 39 | + name: Report Tests Statuses |
| 40 | + needs: |
| 41 | + - pr-tests |
| 42 | + steps: |
| 43 | + - name: Summarize pull request test results |
| 44 | + run: echo "Pull request tests completed successfully." |
| 45 | + |
| 46 | + main-build: |
| 47 | + if: github.event_name != 'pull_request' |
| 48 | + runs-on: ubuntu-latest |
| 49 | + name: Build and Upload Artifacts |
| 50 | + steps: |
| 51 | + - name: Checkout repository |
| 52 | + uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: Build static site |
| 55 | + run: | |
| 56 | + set -euo pipefail |
| 57 | + mkdir -p build |
| 58 | + cp index.html build/ |
| 59 | + cp style.css build/ |
| 60 | + cp landing.js build/ |
| 61 | +
|
| 62 | + - name: Upload static site artifact |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: static-site |
| 66 | + path: build |
| 67 | + |
| 68 | + main-report-build: |
| 69 | + if: github.event_name != 'pull_request' |
| 70 | + runs-on: ubuntu-latest |
| 71 | + name: Report Build Status |
| 72 | + needs: |
| 73 | + - main-build |
| 74 | + steps: |
| 75 | + - name: Report build outcome |
| 76 | + run: echo "Static site build completed successfully." |
| 77 | + |
| 78 | + main-tests: |
| 79 | + if: github.event_name != 'pull_request' |
| 80 | + runs-on: ubuntu-latest |
| 81 | + name: Run Tests |
| 82 | + needs: |
| 83 | + - main-build |
| 84 | + steps: |
| 85 | + - name: Checkout repository |
| 86 | + uses: actions/checkout@v4 |
| 87 | + |
| 88 | + - name: Ensure test scripts are executable |
| 89 | + run: | |
| 90 | + if compgen -G "tests/*.sh" > /dev/null; then |
| 91 | + chmod +x tests/*.sh |
| 92 | + fi |
| 93 | +
|
| 94 | + - name: Execute main branch tests |
| 95 | + run: | |
| 96 | + set -euo pipefail |
| 97 | + if compgen -G "tests/*.sh" > /dev/null; then |
| 98 | + for test_script in tests/*.sh; do |
| 99 | + echo "Running ${test_script}" |
| 100 | + bash "${test_script}" |
| 101 | + done |
| 102 | + else |
| 103 | + echo "No tests found in ./tests" |
| 104 | + fi |
| 105 | +
|
| 106 | + main-report-tests: |
| 107 | + if: github.event_name != 'pull_request' |
| 108 | + runs-on: ubuntu-latest |
| 109 | + name: Report Tests Statuses |
| 110 | + needs: |
| 111 | + - main-tests |
| 112 | + steps: |
| 113 | + - name: Summarize main branch test results |
| 114 | + run: echo "Main branch tests completed successfully." |
| 115 | + |
| 116 | + deploy-pages: |
| 117 | + if: github.event_name != 'pull_request' |
| 118 | + runs-on: ubuntu-latest |
| 119 | + name: Deploy to Pages |
| 120 | + needs: |
| 121 | + - main-build |
| 122 | + steps: |
| 123 | + - name: Deploy placeholder |
| 124 | + run: echo "Deploying static site to GitHub Pages (placeholder)." |
0 commit comments