From aeaf4a959039602c784c2c7fd6f44d4774e1350b Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Wed, 8 Nov 2023 16:58:48 +0100 Subject: [PATCH 1/3] workflows: add monthly activity / contributor status report --- .../workflows/issue-pr-contrib-metrics.yaml | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 .github/workflows/issue-pr-contrib-metrics.yaml diff --git a/.github/workflows/issue-pr-contrib-metrics.yaml b/.github/workflows/issue-pr-contrib-metrics.yaml new file mode 100644 index 0000000..10b65b4 --- /dev/null +++ b/.github/workflows/issue-pr-contrib-metrics.yaml @@ -0,0 +1,106 @@ +name: Monthly contributor report +on: + workflow_dispatch: + inputs: + start_date: + type: string + description: | + Custom start date for metrics generation in YYYY-MM-DD format. + required: true + end_date: + type: string + description: | + Custom end date for metrics generation in YYYY-MM-DD format. + required: true + # Run on every 22th of the month. This guarantees that this action runs + # before the Dev Sync (every 4th Tuesday of the month in the afternoon). + schedule: + - cron: '0 0 22 * *' + +permissions: + issues: write + +jobs: + contributor_report: + name: contributor report + runs-on: ubuntu-latest + + steps: + - name: Set the start and end dates + shell: bash + run: | + set -euo pipefail + if [[ -n "${{inputs.start_date}}" && -n "${{inputs.end_date}}" ]] ; then + start_date="${{inputs.start_date}}" + end_date=${{inputs.end_date}} + fi + + # This runs at midnight so mentrics from the previous month's 22nd are not included + # in the prev month's stats. + start_date=$(date -d "last month" +%Y-%m-22) + end_date=$(date -d "today" +%Y-%m-22) + + #Set an environment variable with the date range + echo "START_DATE=$start_date" >> "$GITHUB_ENV" + echo "END_DATE=$end_date" >> "$GITHUB_ENV" + + - name: Collect contributor metrics + uses: github/contributors@v1 + env: + GH_TOKEN: ${{ secrets.GH_ACTION_METRICS_ORG_READ }} + START_DATE: ${{ env.START_DATE }} + END_DATE: ${{ env.END_DATE }} + # We explicitly list repos for our metrics here so temporary forks like + # e.g. systemd, gentoo, or udev don't pollute the stats + REPOSITORY: "flatcar/flatcar-docs,flatcar/nebraska,flatcar/flatcar-website,flatcar/flatcar-build-script,flatcar/baselayout,flatcar/bootengine,flatcar/coreos-cloudinit,flatcar/afterburn,flatcar/flatcar-dev-util,flatcar/ignition,flatcar/init,flatcar/locksmith,flatcar/mantle,flatcar/mayday,flatcar/nss-altfiles,flatcar/scripts,flatcar/seismograph,flatcar/shim,flatcar/sysroot-wrappers,flatcar/toolbox,flatcar/torcx,flatcar/update-ssh-keys,flatcar/update_engine,flatcar/updateservicectl,flatcar/Flatcar,flatcar/flatcar-packer-qemu,flatcar/flatcar-ipxe-scripts,flatcar/flatcar-cloud-image-uploader,flatcar/flatcar-linux-update-operator,flatcar/flatcar-release-mirror,flatcar/flatcar-terraform,flatcar/sdnotify-proxy,flatcar/flatcar-automation,flatcar/nebraska-update-agent,flatcar/fleetlock,flatcar/flog,flatcar/ign-converter,flatcar/nomad-on-flatcar,flatcar/sysext-bakery,flatcar/reports,flatcar/flatcar-demos,flatcar/jitsi-server,flatcar/flatcar-mastodon,flatcar/ue-rs,flatcar/azure-marketplace-ingestion-api" + SPONSOR_INFO: "false" + + - name: Collect PR metrics + uses: github/issue-metrics@v2 + env: + GH_TOKEN: ${{ secrets.GH_ACTION_METRICS_ORG_READ }} + SEARCH_QUERY: 'org:flatcar is:pr created:${{ env.START_DATE }}..${{ env.END_DATE }}' + + - name: rename PR metrics file + shell: bash + run: | + set -euo pipefail + mv issue-metrics.md pr-metrics.md + + - name: Collect discussion metrics + uses: github/issue-metrics@v2 + env: + GH_TOKEN: ${{ secrets.GH_ACTION_METRICS_ORG_READ }} + SEARCH_QUERY: 'org:flatcar type:discussion created:${{ env.START_DATE }}..${{ env.END_DATE }}' + + - name: rename discussion metrics file + shell: bash + run: | + set -euo pipefail + mv issue-metrics.md discussion-metrics.md + + - name: Collect issue metrics + uses: github/issue-metrics@v2 + env: + GH_TOKEN: ${{ secrets.GH_ACTION_METRICS_ORG_READ }} + SEARCH_QUERY: 'org:flatcar is:issue created:${{ env.START_DATE }}..${{ env.END_DATE }}' + + - name: Assemble full report + shell: bash + run: | + set -euo pipefail + mv contributors.md report.md + echo -e "\n\n# Discussions Metrics" >> report.md + tail --lines=+2 discussion-metrics.md >> report.md + # issues already have the correct headline + cat issue-metrics.md >> report.md + echo -e "\n\n# Pull Requests Metrics" >> report.md + tail --lines=+2 pr-metrics.md >> report.md + + - name: Create issue + uses: peter-evans/create-issue-from-file@v4 + with: + title: Monthly contributions report ${{ env.START_DATE }} - ${{ env.END_DATE }} + token: ${{ secrets.GITHUB_TOKEN }} + content-filepath: ./report.md + labels: kind/metric From faeae0f6443403b5b7d85944741cf255c8b845d1 Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Wed, 8 Nov 2023 17:24:22 +0100 Subject: [PATCH 2/3] issue-pr-contrib-metrics.yaml: remove stale repos --- .github/workflows/issue-pr-contrib-metrics.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issue-pr-contrib-metrics.yaml b/.github/workflows/issue-pr-contrib-metrics.yaml index 10b65b4..565a5dc 100644 --- a/.github/workflows/issue-pr-contrib-metrics.yaml +++ b/.github/workflows/issue-pr-contrib-metrics.yaml @@ -52,7 +52,7 @@ jobs: END_DATE: ${{ env.END_DATE }} # We explicitly list repos for our metrics here so temporary forks like # e.g. systemd, gentoo, or udev don't pollute the stats - REPOSITORY: "flatcar/flatcar-docs,flatcar/nebraska,flatcar/flatcar-website,flatcar/flatcar-build-script,flatcar/baselayout,flatcar/bootengine,flatcar/coreos-cloudinit,flatcar/afterburn,flatcar/flatcar-dev-util,flatcar/ignition,flatcar/init,flatcar/locksmith,flatcar/mantle,flatcar/mayday,flatcar/nss-altfiles,flatcar/scripts,flatcar/seismograph,flatcar/shim,flatcar/sysroot-wrappers,flatcar/toolbox,flatcar/torcx,flatcar/update-ssh-keys,flatcar/update_engine,flatcar/updateservicectl,flatcar/Flatcar,flatcar/flatcar-packer-qemu,flatcar/flatcar-ipxe-scripts,flatcar/flatcar-cloud-image-uploader,flatcar/flatcar-linux-update-operator,flatcar/flatcar-release-mirror,flatcar/flatcar-terraform,flatcar/sdnotify-proxy,flatcar/flatcar-automation,flatcar/nebraska-update-agent,flatcar/fleetlock,flatcar/flog,flatcar/ign-converter,flatcar/nomad-on-flatcar,flatcar/sysext-bakery,flatcar/reports,flatcar/flatcar-demos,flatcar/jitsi-server,flatcar/flatcar-mastodon,flatcar/ue-rs,flatcar/azure-marketplace-ingestion-api" + REPOSITORY: "flatcar/nebraska,flatcar/flatcar-website,flatcar/flatcar-build-script,flatcar/baselayout,flatcar/bootengine,flatcar/coreos-cloudinit,flatcar/flatcar-dev-util,flatcar/init,flatcar/locksmith,flatcar/mantle,flatcar/mayday,flatcar/nss-altfiles,flatcar/scripts,flatcar/seismograph,flatcar/shim,flatcar/sysroot-wrappers,flatcar/toolbox,flatcar/torcx,flatcar/update-ssh-keys,flatcar/update_engine,flatcar/updateservicectl,flatcar/Flatcar,flatcar/flatcar-packer-qemu,flatcar/flatcar-ipxe-scripts,flatcar/flatcar-cloud-image-uploader,flatcar/flatcar-linux-update-operator,flatcar/flatcar-release-mirror,flatcar/flatcar-terraform,flatcar/sdnotify-proxy,flatcar/flatcar-automation,flatcar/nebraska-update-agent,flatcar/fleetlock,flatcar/flog,flatcar/ign-converter,flatcar/nomad-on-flatcar,flatcar/sysext-bakery,flatcar/reports,flatcar/flatcar-demos,flatcar/jitsi-server,flatcar/flatcar-mastodon,flatcar/ue-rs,flatcar/azure-marketplace-ingestion-api" SPONSOR_INFO: "false" - name: Collect PR metrics From 3be0d9f96f67b21ccf899bb0b2bcee133102aa15 Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Wed, 8 Nov 2023 17:43:07 +0100 Subject: [PATCH 3/3] Update .github/workflows/issue-pr-contrib-metrics.yaml Co-authored-by: Mathieu Tortuyaux --- .github/workflows/issue-pr-contrib-metrics.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issue-pr-contrib-metrics.yaml b/.github/workflows/issue-pr-contrib-metrics.yaml index 565a5dc..349a4d5 100644 --- a/.github/workflows/issue-pr-contrib-metrics.yaml +++ b/.github/workflows/issue-pr-contrib-metrics.yaml @@ -35,7 +35,7 @@ jobs: end_date=${{inputs.end_date}} fi - # This runs at midnight so mentrics from the previous month's 22nd are not included + # This runs at midnight so metrics from the previous month's 22nd are not included # in the prev month's stats. start_date=$(date -d "last month" +%Y-%m-22) end_date=$(date -d "today" +%Y-%m-22)