diff --git a/.github/actions/checkout/action.yml b/.github/actions/checkout/action.yml new file mode 100644 index 00000000..b4b0bd14 --- /dev/null +++ b/.github/actions/checkout/action.yml @@ -0,0 +1,28 @@ +name: Checkout repository +description: Checkout the repository with common configuration + +inputs: + fetch-depth: + description: Depth of git history to fetch + required: false + default: "0" + + ssh-key: + description: SSH private key for checkout + required: false + default: "" + + persist-credentials: + description: Persist git credentials + required: false + default: "true" + +runs: + using: "composite" + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + fetch-depth: ${{ inputs.fetch-depth }} + ssh-key: ${{ inputs.ssh-key }} + persist-credentials: ${{ inputs.persist-credentials }} \ No newline at end of file diff --git a/.github/actions/compute_changed_modules/action.yml b/.github/actions/compute_changed_modules/action.yml index cd090df4..a9ff935b 100644 --- a/.github/actions/compute_changed_modules/action.yml +++ b/.github/actions/compute_changed_modules/action.yml @@ -19,6 +19,7 @@ outputs: runs: using: "composite" steps: + - name: Changed files in libraries id: changed if: ${{ inputs.modules == '' }} @@ -33,21 +34,30 @@ runs: run: | set -euo pipefail + # ----------------------------- + # Manual override + # ----------------------------- if [[ -n '${{ inputs.modules }}' ]]; then modules='${{ inputs.modules }}' - hasModules=$([[ "$modules" == "[]" ]] && echo false || echo true) + + if [[ "$modules" == "[]" ]]; then + hasModules=false + else + hasModules=true + fi { - echo "value<> "$GITHUB_OUTPUT" exit 0 fi - if [[ "${{ steps.changed.outputs.any_changed }}" != "true" ]]; then + # ----------------------------- + # No changes detected + # ----------------------------- + if [[ "${{ steps.changed.outputs.any_changed || 'false' }}" != "true" ]]; then { echo "value=[]" echo "hasModules=false" @@ -57,14 +67,13 @@ runs: files_raw='${{ steps.changed.outputs.all_changed_files }}' - files_list=$(printf "%s" "$files_raw" | tr ' ' '\n' | sed '/^$/d') + files_list=$(printf "%s" "$files_raw" | tr ' \n' '\n' | sed '/^$/d') - mods_csv=$(printf "%s\n" "$files_list" \ + modules=$(printf "%s\n" "$files_list" \ | sed -n 's|^libraries/\([^/]*\)/.*|:libraries:\1|p' \ - | sort -u \ - | paste -sd, -) + | sort -u) - if [[ -z "$mods_csv" ]]; then + if [[ -z "$modules" ]]; then { echo "value=[]" echo "hasModules=false" @@ -72,20 +81,12 @@ runs: exit 0 fi - json=$(printf '%s' "$mods_csv" \ - | tr ',' '\n' \ - | sed 's/^[[:space:]]*//; s/[[:space:]]*$//' \ - | sed '/^$/d' \ - | awk '{printf "%s\"%s\"", (NR==1?"":","), $0}' \ - | sed 's/^/[/' \ - | sed 's/$/]/') + json=$(printf "%s\n" "$modules" | jq -R . | jq -s .) echo "Matrix JSON: $json" { - echo "value<> "$GITHUB_OUTPUT" @@ -100,21 +101,18 @@ runs: echo "## 🔍 Modules with Changes" echo "" - if [[ "$matrix" == "[]" ]]; then + count=$(echo "$matrix" | jq 'length') + + if [[ "$count" -eq 0 ]]; then echo "✅ **No modules changed**" echo "" else - count=$(printf "%s" "$matrix" | tr -cd ',' | wc -c | tr -d ' ') - count=$((count + 1)) echo "🧩 **Modules affected:** $count" echo "" echo "### 📦 Affected modules" echo "" - printf "%s\n" "$matrix" \ - | tr -d '[]"' \ - | tr ',' '\n' \ - | sed '/^$/d' \ - | sed 's/^/- `/; s/$/`/' + + echo "$matrix" | jq -r '.[] | "- `\(.)`"' echo "" fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ac2bffe..003e7705 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,9 +31,7 @@ jobs: timeout-minutes: 5 steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } + - uses: ./.github/actions/checkout - name: Print workflow information uses: ./.github/actions/info @@ -44,9 +42,7 @@ jobs: timeout-minutes: 5 steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } + - uses: ./.github/actions/checkout - name: Compute changed modules id: modules @@ -58,12 +54,8 @@ jobs: timeout-minutes: 10 steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } - - - name: Setup build environment - uses: ./.github/actions/setup + - uses: ./.github/actions/checkout + - uses: ./.github/actions/setup - name: Run Detekt uses: ./.github/actions/checkstyle @@ -77,12 +69,8 @@ jobs: timeout-minutes: 20 steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } - - - name: Setup build environment - uses: ./.github/actions/setup + - uses: ./.github/actions/checkout + - uses: ./.github/actions/setup - name: Assemble ${{ env.BUILD_TYPE }} uses: ./.github/actions/assemble @@ -104,12 +92,8 @@ jobs: timeout-minutes: 20 steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } - - - name: Setup build environment - uses: ./.github/actions/setup + - uses: ./.github/actions/checkout + - uses: ./.github/actions/setup - name: Execute unit tests uses: ./.github/actions/unit_tests diff --git a/.github/workflows/ci_bump.yml b/.github/workflows/ci_bump.yml index 26a52681..f8c7a59b 100644 --- a/.github/workflows/ci_bump.yml +++ b/.github/workflows/ci_bump.yml @@ -42,9 +42,7 @@ jobs: timeout-minutes: 5 steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } + - uses: ./.github/actions/checkout - name: Print workflow information uses: ./.github/actions/info @@ -56,15 +54,13 @@ jobs: timeout-minutes: 10 steps: - - name: Check out code - uses: actions/checkout@v6 + - uses: ./.github/actions/checkout with: fetch-depth: 0 ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} persist-credentials: true - - name: Setup build environment - uses: ./.github/actions/setup + - uses: ./.github/actions/setup - name: Bump versions uses: ./.github/actions/bump_version @@ -83,15 +79,13 @@ jobs: timeout-minutes: 10 steps: - - name: Check out code - uses: actions/checkout@v6 + - uses: ./.github/actions/checkout with: fetch-depth: 0 ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} persist-credentials: true - - name: Setup build environment - uses: ./.github/actions/setup + - uses: ./.github/actions/setup - name: Bump version uses: ./.github/actions/bump_version diff --git a/.github/workflows/ci_publish.yml b/.github/workflows/ci_publish.yml index 91a2f1a4..6ff6176a 100644 --- a/.github/workflows/ci_publish.yml +++ b/.github/workflows/ci_publish.yml @@ -5,9 +5,11 @@ name: Continuous Integration (Publish) # Workflow events: Controls when the action will run. # More info: https://docs.github.com/en/actions/reference/events-that-trigger-workflows on: - push: - branches: - - master +# push: +# branches: +# - master + pull_request: + types: [opened, synchronize, reopened, ready_for_review] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -50,7 +52,7 @@ env: # Build type BUILD_TYPE: ${{ github.event.inputs.build-type || 'Release' }} # Publishing type for Central Portal (USER_MANAGED or AUTOMATIC) - PUBLICATION_TYPE: ${{ github.event.inputs.publication-type || 'AUTOMATIC' }} + PUBLICATION_TYPE: ${{ github.event.inputs.publication-type || 'USER_MANAGED' }} # BOM module name (used for version bumping) BOM_MODULE: ${{ github.event.inputs.bom-module || ':bom' }} @@ -63,9 +65,7 @@ jobs: timeout-minutes: 5 steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } + - uses: ./.github/actions/checkout - name: Print workflow information uses: ./.github/actions/info @@ -80,9 +80,7 @@ jobs: hasModules: ${{ steps.computed.outputs.hasModules }} steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } + - uses: ./.github/actions/checkout - name: Compute changed modules id: computed @@ -98,12 +96,8 @@ jobs: timeout-minutes: 10 steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } - - - name: Setup build environment - uses: ./.github/actions/setup + - uses: ./.github/actions/checkout + - uses: ./.github/actions/setup - name: Check code via Detekt uses: ./.github/actions/checkstyle @@ -117,12 +111,8 @@ jobs: timeout-minutes: 20 steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } - - - name: Setup build environment - uses: ./.github/actions/setup + - uses: ./.github/actions/checkout + - uses: ./.github/actions/setup - name: Assemble ${{ env.BUILD_TYPE }} uses: ./.github/actions/assemble @@ -144,12 +134,8 @@ jobs: timeout-minutes: 20 steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } - - - name: Setup build environment - uses: ./.github/actions/setup + - uses: ./.github/actions/checkout + - uses: ./.github/actions/setup - name: Execute unit tests uses: ./.github/actions/unit_tests @@ -170,12 +156,8 @@ jobs: timeout-minutes: 20 steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } - - - name: Setup build environment - uses: ./.github/actions/setup + - uses: ./.github/actions/checkout + - uses: ./.github/actions/setup - name: Build nmcpProjects id: nmcp @@ -210,15 +192,13 @@ jobs: timeout-minutes: 10 steps: - - name: Check out code - uses: actions/checkout@v6 + - uses: ./.github/actions/checkout with: fetch-depth: 0 ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} persist-credentials: true - - name: Setup build environment - uses: ./.github/actions/setup + - uses: ./.github/actions/setup - name: Get PR info id: pr_info @@ -240,15 +220,13 @@ jobs: timeout-minutes: 10 steps: - - name: Check out code - uses: actions/checkout@v6 + - uses: ./.github/actions/checkout with: fetch-depth: 0 ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} persist-credentials: true - - name: Setup build environment - uses: ./.github/actions/setup + - uses: ./.github/actions/setup - name: Get PR info id: pr_info diff --git a/.github/workflows/ci_reports.yml b/.github/workflows/ci_reports.yml index 1dc4f49c..4c1b33cb 100644 --- a/.github/workflows/ci_reports.yml +++ b/.github/workflows/ci_reports.yml @@ -38,9 +38,7 @@ jobs: timeout-minutes: 5 steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } + - uses: ./.github/actions/checkout - name: Print workflow information uses: ./.github/actions/info @@ -51,12 +49,8 @@ jobs: timeout-minutes: 20 steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } - - - name: Setup build environment - uses: ./.github/actions/setup + - uses: ./.github/actions/checkout + - uses: ./.github/actions/setup - name: Execute unit tests uses: ./.github/actions/unit_tests @@ -71,12 +65,8 @@ jobs: timeout-minutes: 10 steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: { fetch-depth: 0 } - - - name: Setup build environment - uses: ./.github/actions/setup + - uses: ./.github/actions/checkout + - uses: ./.github/actions/setup - name: Generate JaCoCo reports and upload to codecov uses: ./.github/actions/reports