This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch activity-monitor
in repository https://gitbox.apache.org/repos/asf/logging-site.git


The following commit(s) were added to refs/heads/activity-monitor by this push:
     new 88e20d8a Add the first statistics collector
88e20d8a is described below

commit 88e20d8a53192d8b045b0bb3185b1a9c59612204
Author: Volkan Yazıcı <[email protected]>
AuthorDate: Thu Oct 26 17:15:55 2023 +0200

    Add the first statistics collector
---
 .github/workflows/update-stats.yaml | 146 ++++++++++++++++++++++++++++++++++++
 1 file changed, 146 insertions(+)

diff --git a/.github/workflows/update-stats.yaml 
b/.github/workflows/update-stats.yaml
new file mode 100644
index 00000000..0cef1aaa
--- /dev/null
+++ b/.github/workflows/update-stats.yaml
@@ -0,0 +1,146 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+name: update-stats
+
+on:
+  schedule:
+    - cron: "17 17 * * *"
+
+concurrency:
+  group: ${{ github.ref_name }}
+  cancel-in-progress: true
+
+permissions: read-all
+
+env:
+  DATA_FILEPATH: stats.csv
+
+jobs:
+
+  collect:
+
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        proj-spec:
+          - id: log4j-1
+            repo-name: apache/logging-log4j1
+            repo-branch: main
+          - id: log4j-2
+            repo-name: apache/logging-log4j2
+            repo-branch: 2.x
+          - id: log4j-kotlin
+            repo-name: apache/logging-log4j-kotlin
+          - id: log4j-scala
+            repo-name: apache/logging-log4j-scala
+          - id: log4j-transform
+            repo-name: apache/logging-log4j-transform
+          - id: log4j-tools
+            repo-name: apache/logging-log4j-tools
+          - id: log4j-audit
+            repo-name: apache/logging-log4j-audit
+          - id: chainsaw
+            repo-name: apache/logging-chainsaw
+
+    env:
+      PROJ_ID: ${{ matrix.proj-spec.id }}
+      REPO_NAME: ${{ matrix.proj-spec.repo-name }}
+      REPO_BRANCH: ${{ matrix.proj-spec.repo-branch || 'main' }}
+
+    steps:
+
+      - name: Checkout the repository
+        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11   # 
4.0.0
+        with:
+          repository: apache/${{ env.REPO_NAME }}
+          ref: ${{ env.REPO_BRANCH }}
+          # Fetch all the history:
+          fetch-depth: 0
+
+      - name: Collect statistics
+        shell: bash
+        run: |
+          find . -regextype posix-extended -name "pom.xml" -and -not -regex 
"(.*/)?target/.*" | while read pomXmlFilepath; do
+
+            # Ignore artifact which are skipped at deployment
+            grep -q "<maven.deploy.skip>true" "$pomXmlFilepath" && continue
+
+            # Extract the module name (i.e., `artifactId`)
+            module=$(awk 'match($0, /^[ \t]+<artifactId>(.+)<\/artifactId>$/, 
m) {print m[1]}' "$pomXmlFilepath")
+
+            # Dump statistics of the module folder
+            moduleDir=$(dirname "$pomXmlFilepath")
+            git log --pretty=tformat:"%as %ae" -- "$moduleDir" | while read 
instant author; do
+              echo "$PROJ_ID,$module,$instant,$author"
+            done >"$DATA_FILEPATH"
+
+      - name: Upload statistics
+        uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 
 # 3.1.3
+        with:
+          name: ${{ env.PROJ_ID }}-${{ env.REPO_BRANCH }}-${{ 
env.$DATA_FILEPATH }}
+          path: ${{ env.$DATA_FILEPATH }}
+
+  merge:
+
+    runs-on: ubuntu-latest
+
+    env:
+      DOWNLOAD_DIR: /tmp/stats
+
+    steps:
+
+      # We could have rolled out our own shell script to read the GPG private 
key.
+      # Though we use `actions/setup-java` everywhere for that purpose, and it 
simply works.
+      - name: Set up GPG
+        uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0   # 
3.7.0
+        with:
+          distribution: temurin
+          java-version: 17
+          java-package: jdk
+          architecture: x64
+          cache: maven
+          server-id: apache.releases.https
+          server-username: NEXUS_USERNAME
+          server-password: NEXUS_PASSWORD
+          gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
+
+      - name: Set up Git
+        shell: bash
+        run: |
+          # Set up user name and email required for `git commit`
+          git config user.name "ASF Logging Services RM"
+          git config user.email [email protected]
+
+      - name: Checkout the repository
+        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11   # 
4.0.0
+
+      - name: Download statistics
+        uses: 
actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a  # 3.0.2
+        with:
+          path: ${{ env.DOWNLOAD_DIR }}
+
+      - name: Merge & commit statistics
+        shell: bash
+        run: |
+          echo project,module,instant,author >"$DATA_FILEPATH"
+          find "$DOWNLOAD_DIR" -type f | xargs cat >>"$DATA_FILEPATH"
+          if [ -n "$(git status --porcelain)" ]; then
+            git commit -S "$DATA_FILEPATH" -m "Update \`$DATA_FILEPATH\`'
+            git push -f origin
+          fi

Reply via email to