|
| 1 | +name: 🔄 CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + schedule: |
| 9 | + - cron: '0 0 * * 0' # Run weekly on Sundays at midnight UTC |
| 10 | + workflow_dispatch: # Allows manual triggering |
| 11 | + |
| 12 | +jobs: |
| 13 | + lint: |
| 14 | + name: 🧹 Code Quality Checks |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: 📥 Checkout code |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: ☕ Set up JDK 21 |
| 21 | + uses: actions/setup-java@v4 |
| 22 | + with: |
| 23 | + java-version: '21' |
| 24 | + distribution: 'temurin' |
| 25 | + cache: 'gradle' |
| 26 | + |
| 27 | + - name: 🛠️ Setup Gradle |
| 28 | + uses: gradle/gradle-build-action@v3 |
| 29 | + with: |
| 30 | + gradle-version: wrapper |
| 31 | + |
| 32 | + - name: 🔍 Check code style |
| 33 | + run: ./gradlew checkstyleMain checkstyleTest --no-daemon |
| 34 | + |
| 35 | + - name: 🔍 Check for deprecated API usage |
| 36 | + run: ./gradlew spotbugsMain spotbugsTest --no-daemon |
| 37 | + |
| 38 | + build: |
| 39 | + name: 🚀 Build and Test |
| 40 | + needs: lint |
| 41 | + runs-on: ${{ matrix.os }} |
| 42 | + strategy: |
| 43 | + matrix: |
| 44 | + os: [ubuntu-latest, macos-latest] |
| 45 | + java-version: [21] |
| 46 | + |
| 47 | + steps: |
| 48 | + - name: 📥 Checkout code |
| 49 | + uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - name: ☕ Set up JDK ${{ matrix.java-version }} |
| 52 | + uses: actions/setup-java@v4 |
| 53 | + with: |
| 54 | + java-version: ${{ matrix.java-version }} |
| 55 | + distribution: 'temurin' |
| 56 | + cache: 'gradle' |
| 57 | + |
| 58 | + - name: 🛠️ Setup Gradle |
| 59 | + uses: gradle/gradle-build-action@v3 |
| 60 | + with: |
| 61 | + gradle-version: wrapper |
| 62 | + |
| 63 | + - name: 📦 Install dependencies (macOS) |
| 64 | + if: runner.os == 'macOS' |
| 65 | + run: | |
| 66 | + brew update |
| 67 | + brew tap confluentinc/tap |
| 68 | + brew bundle |
| 69 | +
|
| 70 | + - name: 📦 Install dependencies (Ubuntu) |
| 71 | + if: runner.os == 'Linux' |
| 72 | + run: | |
| 73 | + sudo apt-get update |
| 74 | + sudo apt-get install -y jq |
| 75 | +
|
| 76 | + - name: 🏗️ Build with Gradle |
| 77 | + run: ./gradlew build --no-daemon |
| 78 | + |
| 79 | + - name: 🧪 Run tests |
| 80 | + run: ./gradlew test --no-daemon |
| 81 | + |
| 82 | + - name: 📦 Build shadow JARs |
| 83 | + run: ./gradlew shadowJar --no-daemon |
| 84 | + |
| 85 | + - name: 📤 Upload build artifacts |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: build-artifacts-${{ matrix.os }} |
| 89 | + path: | |
| 90 | + flink-streaming/build/libs/*.jar |
| 91 | + flink-sql/build/libs/*.jar |
| 92 | + retention-days: 5 |
| 93 | + |
| 94 | + docker: |
| 95 | + name: 🐳 Docker Build Test |
| 96 | + needs: build |
| 97 | + runs-on: ubuntu-latest |
| 98 | + steps: |
| 99 | + - name: 📥 Checkout code |
| 100 | + uses: actions/checkout@v4 |
| 101 | + |
| 102 | + - name: 🐳 Set up Docker Buildx |
| 103 | + uses: docker/setup-buildx-action@v3 |
| 104 | + |
| 105 | + - name: 🏗️ Build Docker image |
| 106 | + uses: docker/build-push-action@v5 |
| 107 | + with: |
| 108 | + context: . |
| 109 | + push: false |
| 110 | + tags: flink-for-java-workshop:test |
| 111 | + cache-from: type=gha |
| 112 | + cache-to: type=gha,mode=max |
0 commit comments