name: Build and Test j3270 on: push: branches: [ "master", "main", "develop" ] pull_request: branches: [ "master", "main" ] workflow_dispatch: jobs: build: name: Build JAR & Run Tests (Java ${{ matrix.java }}) runs-on: ubuntu-latest strategy: fail-fast: false matrix: java: [ '11', '17', '21' ] steps: - name: Configure Dynamic DNS Resolvers run: | # Ensure container has active upstream nameservers for dynamic DNS printf "nameserver 1.1.1.1\nnameserver 8.8.8.8\n" > /etc/resolv.conf 2>/dev/null || true - name: Checkout Code uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up Java JDK (Temurin ${{ matrix.java }}) uses: actions/setup-java@v3 continue-on-error: true with: java-version: ${{ matrix.java }} distribution: 'temurin' - name: Ensure Java Available run: | if ! command -v javac >/dev/null 2>&1; then echo "Installing OpenJDK ${{ matrix.java }} via package manager..." if command -v apt-get >/dev/null 2>&1; then apt-get update && apt-get install -y openjdk-${{ matrix.java }}-jdk-headless || true elif command -v apk >/dev/null 2>&1; then apk add --no-cache openjdk${{ matrix.java }} || true fi fi echo "Java compiler:" javac -version || which javac || true echo "Java runtime:" java -version || which java || true - name: Make scripts executable run: | chmod +x ./build_all.sh ./test_all.sh ./run.sh - name: Build & Run Unit Tests run: | sh ./test_all.sh - name: Prepare Versioned JAR run: | cp build/j3270.jar "build/j3270-java${{ matrix.java }}.jar" - name: Upload j3270 Executable JAR Artifact uses: actions/upload-artifact@v3 continue-on-error: true with: name: j3270-java${{ matrix.java }}-jar path: build/j3270-java${{ matrix.java }}.jar - name: Upload Test Reports if: always() uses: actions/upload-artifact@v3 continue-on-error: true with: name: test-reports-java${{ matrix.java }} path: build/reports/tests/ - name: Report Build Status if: failure() run: | echo "### ❌ Build or Test Failed for Java ${{ matrix.java }}" >> $GITHUB_STEP_SUMMARY echo "Please check the runner logs above for details." >> $GITHUB_STEP_SUMMARY