From 9af35bf00d237947733d31e8b4357865ca7c25e1 Mon Sep 17 00:00:00 2001 From: Roberto Cella Date: Sat, 7 Oct 2023 13:18:27 +0200 Subject: [PATCH 1/4] enabled automerge for minor updates, reworked docker ci, and downgraded codecov action --- .github/renovate.json | 19 ++++++++- .github/workflows/docker-image.yml | 68 +++++++++++++++++++++++------- .github/workflows/gradle.yml | 2 +- 3 files changed, 71 insertions(+), 18 deletions(-) diff --git a/.github/renovate.json b/.github/renovate.json index 4e47961..2868b96 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,6 +1,21 @@ { + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "packageRules": [ + { + "matchPackagePatterns": [ + "*" + ], + "matchUpdateTypes": [ + "minor", + "patch" + ], + "automerge": true, + "labels": [ + "dependencies" + ] + } + ], "extends": [ - "config:base", - ":dependencyDashboard" + "config:base" ] } diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index dab422e..a782d84 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,23 +1,61 @@ name: Docker Image CI on: + workflow_dispatch: + pull_request: push: - branches: [ master ] + branches: + - master jobs: - - build: - + docker: + name: Build and upload Docker image runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Build the Docker image - run: docker build . --file Dockerfile --tag rob93c/christmas-greeter:latest - - - name: Perform Docker login - run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin - - - name: Upload the latest Docker image - run: docker push rob93c/christmas-greeter:latest + - name: Checkout code changes + uses: actions/checkout@v4 + + - name: Prepare Docker + uses: docker/setup-buildx-action@v3 + + - name: Access Docker + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata + id: metadata + uses: docker/metadata-action@v5 + with: + images: | + rob93c/christmas-greeter + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=ref,event=branch + type=ref,event=pr + + - name: Set Docker tags + id: docker-tags + run: | + cleaned_tags=${{ steps.metadata.outputs.tags }} + if [[ " ${{ steps.metadata.outputs.tags }} " =~ "christmas-greeter:latest" ]]; then + cleaned_tags=("***/christmas-greeter:latest") + fi + echo "cleaned_tags=${cleaned_tags}" >> "$GITHUB_OUTPUT" + + - name: Upload Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.docker-tags.outputs.cleaned_tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Delete Docker tag + if: github.event.pull_request.merged + run: | + tag_to_delete="pr-${{github.event.issue.number}}" + docker rmi rob93c/christmas-greeter:$tag_to_delete + echo "The tag $tag_to_delete has been deleted" diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 32cbbd0..2976e17 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -22,7 +22,7 @@ jobs: - name: Build project with Gradle run: chmod +x gradlew && ./gradlew build --no-daemon - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} directory: ./build/reports/jacoco/test/ From 5005bad5a711b37ef767f9e5b02347080d0b1e8f Mon Sep 17 00:00:00 2001 From: Roberto Cella Date: Sat, 7 Oct 2023 13:25:15 +0200 Subject: [PATCH 2/4] updated readme and cleaned coverage ci --- .../workflows/{gradle.yml => coverage.yml} | 20 +++++++++++-------- README.md | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) rename .github/workflows/{gradle.yml => coverage.yml} (76%) diff --git a/.github/workflows/gradle.yml b/.github/workflows/coverage.yml similarity index 76% rename from .github/workflows/gradle.yml rename to .github/workflows/coverage.yml index 2976e17..b7df8eb 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/coverage.yml @@ -1,26 +1,30 @@ -name: Gradle build CI +name: Code coverage CI on: - push: - branches: [ master ] + workflow_dispatch: pull_request: - branches: [ master ] + push: + branches: + - master jobs: - build: - + coverage: + name: Build project and upload coverage runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 + - name: Checkout code changes + uses: actions/checkout@v4 + - name: Set up JDK 19 uses: actions/setup-java@v3 with: java-version: 19 distribution: temurin cache: gradle + - name: Build project with Gradle run: chmod +x gradlew && ./gradlew build --no-daemon + - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: diff --git a/README.md b/README.md index a90dc4f..f228660 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Java version](https://badgen.net/badge/Java/Java%2019/orange?icon=https://raw.githubusercontent.com/rob93c/BadgenIcons/master/icons/java-logo.svg&labelColor=292f35&label)](https://github.com/rob93c/ChristmasGreeter/search?l=java) [![Codacy Badge](https://badgen.net/codacy/grade/361904c6ec0d4a1490aa7d5593f8e26a?icon=https://raw.githubusercontent.com/rob93c/BadgenIcons/master/icons/codacy-logo.svg&labelColor=292f35&label=Code%20quality)](https://www.codacy.com/gh/rob93c/ChristmasGreeter/dashboard) [![Codecov](https://badgen.net/badge/codecov/coverage/3bbe58?icon=https://raw.githubusercontent.com/rob93c/BadgenIcons/master/icons/codecov-logo.svg&labelColor=292f35&label=codecov)](https://app.codecov.io/gh/rob93c/ChristmasGreeter) -[![Gradle build CI](https://github.com/rob93c/ChristmasGreeter/actions/workflows/gradle.yml/badge.svg)](https://github.com/rob93c/ChristmasGreeter/actions/workflows/gradle.yml) +[![Code coverage CI](https://github.com/rob93c/ChristmasGreeter/actions/workflows/gradle.yml/badge.svg)](https://github.com/rob93c/ChristmasGreeter/actions/workflows/coverage.yml) [![Docker Image CI](https://github.com/rob93c/ChristmasGreeter/actions/workflows/docker-image.yml/badge.svg)](https://github.com/rob93c/ChristmasGreeter/actions/workflows/docker-image.yml) [![Code Analysis CI](https://github.com/rob93c/ChristmasGreeter/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/rob93c/ChristmasGreeter/actions/workflows/codeql-analysis.yml) [![Docker Image](https://badgen.net/badge/docker/Docker?icon=docker&labelColor=292f35&label)](https://hub.docker.com/r/rob93c/christmas-greeter) @@ -20,7 +20,7 @@ The project itself is built with **Java 19**, and it comes with the following de * `Apache Commons 3` * `JUnit 5` -* `Mockito 4` +* `Mockito 5` * `Apache log4j 2` ## How to set up the project From 0a8b03934bdff321ddd99e5861e2550d3e64664f Mon Sep 17 00:00:00 2001 From: Roberto Cella Date: Sat, 7 Oct 2023 13:33:02 +0200 Subject: [PATCH 3/4] rollback codecov action downgrade --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index b7df8eb..88bea0b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -26,7 +26,7 @@ jobs: run: chmod +x gradlew && ./gradlew build --no-daemon - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} directory: ./build/reports/jacoco/test/ From 89c7afe77c1bba6e682d2a281c994925af3be5d6 Mon Sep 17 00:00:00 2001 From: Roberto Cella Date: Sat, 7 Oct 2023 13:34:14 +0200 Subject: [PATCH 4/4] Revert "rollback codecov action downgrade" This reverts commit 0a8b03934bdff321ddd99e5861e2550d3e64664f. --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 88bea0b..b7df8eb 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -26,7 +26,7 @@ jobs: run: chmod +x gradlew && ./gradlew build --no-daemon - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} directory: ./build/reports/jacoco/test/