[2025/12] Christmas Tree Farm (Part 1) #287
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Build and Test" | |
| on: | |
| push: | |
| branches: | |
| - "master" | |
| jobs: | |
| build-natively-with-gradle: | |
| name: "Build natively with Gradle" | |
| runs-on: "ubuntu-latest" | |
| steps: | |
| - name: "Check out source code" | |
| uses: "actions/checkout@v6.0.0" | |
| - name: "Set up JDK 21" | |
| uses: "actions/setup-java@v5.0.0" | |
| with: | |
| java-version: "21" | |
| distribution: "corretto" | |
| - name: "Validate Gradle wrapper" | |
| uses: "gradle/actions/wrapper-validation@v5.0.0" | |
| - name: "Set up Gradle" | |
| uses: "gradle/actions/setup-gradle@v5.0.0" | |
| - name: "Build with Gradle" | |
| run: "./gradlew build" | |
| - name: "Upload 'AdventOfCode.jar' artifact" | |
| uses: "actions/upload-artifact@v5.0.0" | |
| with: | |
| name: "AdventOfCode.jar" | |
| path: "build/libs/AdventOfCode.jar" | |
| if-no-files-found: "error" | |
| - name: "Upload Ktlint reports artifact" | |
| if: "${{ always() }}" | |
| uses: "actions/upload-artifact@v5.0.0" | |
| with: | |
| name: "Ktlint Reports" | |
| path: "build/reports/ktlint" | |
| if-no-files-found: "error" | |
| - name: "Upload test summary artifact" | |
| if: "${{ always() }}" | |
| uses: "actions/upload-artifact@v5.0.0" | |
| with: | |
| name: "Test Summary" | |
| path: "build/reports/tests/test" | |
| if-no-files-found: "error" | |
| - name: "Upload coverage report artifact" | |
| if: "${{ always() }}" | |
| uses: "actions/upload-artifact@v5.0.0" | |
| with: | |
| name: "Coverage Report" | |
| path: "build/reports/jacoco/test" | |
| if-no-files-found: "error" | |
| run-jar-natively: | |
| name: "Run JAR archive natively" | |
| needs: "build-natively-with-gradle" | |
| runs-on: "ubuntu-latest" | |
| steps: | |
| - name: "Download 'AdventOfCode.jar' artifact" | |
| uses: "actions/download-artifact@v6.0.0" | |
| with: | |
| name: "AdventOfCode.jar" | |
| path: "." | |
| - name: "Set up JDK 21" | |
| uses: "actions/setup-java@v5.0.0" | |
| with: | |
| java-version: "21" | |
| distribution: "corretto" | |
| - name: "Run JAR archive" | |
| run: "java -jar AdventOfCode.jar 2025" | |
| build-docker-image: | |
| name: "Build Docker Image" | |
| runs-on: "ubuntu-latest" | |
| steps: | |
| - name: "Check out source code" | |
| uses: "actions/checkout@v6.0.0" | |
| - name: "Lint Dockerfile" | |
| uses: "luke142367/Docker-Lint-Action@v1.1.1" | |
| env: | |
| GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
| - name: "Set up Docker Buildx" | |
| uses: "docker/setup-buildx-action@v3.11.1" | |
| - name: "Build Docker Image" | |
| uses: "docker/build-push-action@v6.18.0" | |
| with: | |
| tags: "pfolta/advent-of-code:latest" | |
| outputs: "type=docker, dest=AdventOfCode.tar" | |
| push: false | |
| - name: "Upload Docker image artifact" | |
| uses: "actions/upload-artifact@v5.0.0" | |
| with: | |
| name: "Docker Image" | |
| path: "AdventOfCode.tar" | |
| if-no-files-found: "error" | |
| run-docker-image: | |
| name: "Run Docker Image" | |
| needs: "build-docker-image" | |
| runs-on: "ubuntu-latest" | |
| steps: | |
| - name: "Download Docker image artifact" | |
| uses: "actions/download-artifact@v6.0.0" | |
| with: | |
| name: "Docker Image" | |
| path: "." | |
| - name: "Load Docker image" | |
| run: | | |
| docker load --input AdventOfCode.tar | |
| docker image ls pfolta/advent-of-code | |
| - name: "Run Docker image" | |
| uses: "addnab/docker-run-action@v3" | |
| with: | |
| image: "pfolta/advent-of-code:latest" | |
| run: "java -jar AdventOfCode.jar 2025" | |
| publish-coverage-data: | |
| name: "Publish coverage data to Codecov" | |
| needs: ["run-jar-natively", "run-docker-image"] | |
| runs-on: "ubuntu-latest" | |
| steps: | |
| - name: "Check out source code" | |
| uses: "actions/checkout@v6.0.0" | |
| - name: "Download coverage report artifact" | |
| uses: "actions/download-artifact@v6.0.0" | |
| with: | |
| name: "Coverage Report" | |
| path: "build/reports/jacoco/test" | |
| - name: "Publish coverage data to Codecov" | |
| uses: "codecov/codecov-action@v5.5.1" | |
| with: | |
| token: "${{ secrets.CODECOV_TOKEN }}" |