From 5fbdef318de37bc0d3e2e8b9751d9f30287da67b Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 9 Aug 2025 10:57:15 +0530 Subject: [PATCH 1/7] ci: comment workflows --- ...ecutter-template-from-example-project.yaml | 52 ++++++------ .../scaffold-from-template-target-project.yml | 82 +++++++++---------- 2 files changed, 67 insertions(+), 67 deletions(-) diff --git a/.github/workflows/generate-cookiecutter-template-from-example-project.yaml b/.github/workflows/generate-cookiecutter-template-from-example-project.yaml index da2f166..c91f743 100644 --- a/.github/workflows/generate-cookiecutter-template-from-example-project.yaml +++ b/.github/workflows/generate-cookiecutter-template-from-example-project.yaml @@ -1,26 +1,26 @@ -name: Generate cookiecutter template from example project -on: - pull_request: - branches: - - main - paths: - - 'example/**' - workflow_dispatch: -jobs: - generate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Make script executable - run: chmod +x ./generate-cookiecutter-template-from-example-project.sh - - name: Generate cookiecutter template - run: ./generate-cookiecutter-template-from-example-project.sh - - name: Is there is difference in the generated template? - run: | - set -e - DIFF_OUTPUT=$(diff -qr example-tryout {{cookiecutter.app_name}} --exclude='.DS_Store' || true) - if [ -n "$DIFF_OUTPUT" ]; then - echo "$DIFF_OUTPUT" - echo "$DIFF_OUTPUT" > diff-output.txt - exit 1 - fi +#name: Generate cookiecutter template from example project +#on: +# pull_request: +# branches: +# - main +# paths: +# - 'example/**' +# workflow_dispatch: +#jobs: +# generate: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - name: Make script executable +# run: chmod +x ./generate-cookiecutter-template-from-example-project.sh +# - name: Generate cookiecutter template +# run: ./generate-cookiecutter-template-from-example-project.sh +# - name: Is there is difference in the generated template? +# run: | +# set -e +# DIFF_OUTPUT=$(diff -qr example-tryout {{cookiecutter.app_name}} --exclude='.DS_Store' || true) +# if [ -n "$DIFF_OUTPUT" ]; then +# echo "$DIFF_OUTPUT" +# echo "$DIFF_OUTPUT" > diff-output.txt +# exit 1 +# fi diff --git a/.github/workflows/scaffold-from-template-target-project.yml b/.github/workflows/scaffold-from-template-target-project.yml index 866b4c3..8e3b84b 100644 --- a/.github/workflows/scaffold-from-template-target-project.yml +++ b/.github/workflows/scaffold-from-template-target-project.yml @@ -1,41 +1,41 @@ -name: Scaffold code from template -on: - pull_request: - branches: - - main - paths: - - '{{cookiecutter.app_name}}/**' - workflow_dispatch: -jobs: - scaffold: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.9' - - name: Cache pip - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - - name: Install cookiecutter - run: pip install cookiecutter - - name: Test cookiecutter - run: cookiecutter --config-file=test-config.yml --no-input . - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '21' - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - - name: Build with Maven - run: | - cd cart-service - mvn git-code-format:format-code - mvn clean install -ntp \ No newline at end of file +#name: Scaffold code from template +#on: +# pull_request: +# branches: +# - main +# paths: +# - '{{cookiecutter.app_name}}/**' +# workflow_dispatch: +#jobs: +# scaffold: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - name: Set up Python +# uses: actions/setup-python@v5 +# with: +# python-version: '3.9' +# - name: Cache pip +# uses: actions/cache@v4 +# with: +# path: ~/.cache/pip +# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} +# - name: Install cookiecutter +# run: pip install cookiecutter +# - name: Test cookiecutter +# run: cookiecutter --config-file=test-config.yml --no-input . +# - name: Set up JDK 21 +# uses: actions/setup-java@v4 +# with: +# distribution: 'temurin' +# java-version: '21' +# - name: Cache Maven packages +# uses: actions/cache@v4 +# with: +# path: ~/.m2 +# key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} +# - name: Build with Maven +# run: | +# cd cart-service +# mvn git-code-format:format-code +# mvn clean install -ntp \ No newline at end of file From 81d8384176edf8ff7b74802c8d5de4a113a00d9b Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 9 Aug 2025 10:57:30 +0530 Subject: [PATCH 2/7] ci: add new workflow for ci --- .github/workflows/ci.yaml | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..75fa693 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,50 @@ +name: Continuous Integration +on: + pull_request: + branches: + - main + paths: + - 'example/**' + workflow_dispatch: +jobs: + example-ci: + defaults: + run: + working-directory: ./example + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + - name: Cache Maven dependencies + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Build with Maven + run: mvn clean install -ntp + generate-template: + needs: example-ci + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Make script executable + run: chmod +x ./generate-cookiecutter-template-from-example-project.sh + - name: Generate cookiecutter template + run: ./generate-cookiecutter-template-from-example-project.sh + - name: Copy generated template to {{cookiecutter.app_name}} + run: | + rsync -a --delete --exclude='.git' ./example-tryout/ ./{{cookiecutter.app_name}}/ + - name: Commit & push generated changes + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add . + git diff --cached --quiet || git commit -m "ci: update generated cookiecutter template from example" + git push From bc1e5f45509b92d8cf425ffe38b617697b97867e Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 9 Aug 2025 10:58:04 +0530 Subject: [PATCH 3/7] ci(dependabot): change the directory to example and limit of pr --- .github/dependabot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 066806e..f54fbb4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -2,10 +2,10 @@ version: 2 updates: - package-ecosystem: maven directories: - - "/{{cookiecutter.app_name}}/" + - "/examples/" schedule: interval: daily time: "23:30" -# open-pull-requests-limit: 10 + open-pull-requests-limit: 10 reviewers: - paul58914080 \ No newline at end of file From 640581a54298e415a6aa9e458ed427eafb8829e7 Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 9 Aug 2025 10:58:23 +0530 Subject: [PATCH 4/7] ci: update permission --- generate-cookiecutter-template-from-example-project.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 generate-cookiecutter-template-from-example-project.sh diff --git a/generate-cookiecutter-template-from-example-project.sh b/generate-cookiecutter-template-from-example-project.sh old mode 100644 new mode 100755 From 55484df38c18302d2fda98e597944bad08fc817a Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 9 Aug 2025 11:05:29 +0530 Subject: [PATCH 5/7] ci: add path .github/workflows/ci.yaml --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 75fa693..ed0c7c2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,6 +5,7 @@ on: - main paths: - 'example/**' + - '.github/workflows/ci.yaml' workflow_dispatch: jobs: example-ci: From a6633719a06a4046aed394915aa9e452dbbd22df Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 9 Aug 2025 11:09:08 +0530 Subject: [PATCH 6/7] ci: update push --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ed0c7c2..ca402aa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,4 +48,4 @@ jobs: git config --local user.name "github-actions[bot]" git add . git diff --cached --quiet || git commit -m "ci: update generated cookiecutter template from example" - git push + git push origin HEAD:${{ github.head_ref }} From f227564cfeb9334435a19ab063194d4529a60294 Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 9 Aug 2025 11:13:27 +0530 Subject: [PATCH 7/7] ci: pull latest changes --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ca402aa..0af10cf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -46,6 +46,7 @@ jobs: run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" + git pull --rebase origin ${{ github.head_ref }} git add . git diff --cached --quiet || git commit -m "ci: update generated cookiecutter template from example" git push origin HEAD:${{ github.head_ref }}