GitHub Metrics for Dapr's repositories #882
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2022 The Dapr Authors | |
# Licensed 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: GitHub Metrics for Dapr's repositories | |
on: | |
# Run every day | |
schedule: | |
- cron: '0 0 * * *' | |
# Manual trigger | |
workflow_dispatch: | |
jobs: | |
calculate: | |
runs-on: ubuntu-latest | |
env: | |
DAPR_CLI_VER: 1.7.0 | |
DAPR_RUNTIME_VER: 1.7.4 | |
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.7.0/install/install.sh | |
ARCHIVE_OUTDIR: dist/archives | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Set up Dapr CLI | |
run: wget -q ${{ env.DAPR_INSTALL_URL }} -O - | /bin/bash -s ${{ env.DAPR_CLI_VER }} | |
- name: Initialize Dapr runtime ${{ env.DAPR_RUNTIME_VER }} | |
run: | | |
dapr uninstall --all | |
dapr init --runtime-version ${{ env.DAPR_RUNTIME_VER }} | |
- name: Install utilities dependencies | |
run: | | |
echo "PATH=$PATH:$HOME/.local/bin" >> $GITHUB_ENV | |
pip3 install dapr humanize PyGitHub requests | |
- name: Extract metrics | |
env: | |
GITHUB_METRICS_PATH: ${{ env.ARCHIVE_OUTDIR }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
dapr run --components-path=./.github/scripts/.components/ python3 ./.github/scripts/github_issues_metrics.py | |
- name: Export metrics as env var | |
env: | |
GITHUB_METRICS_PATH: ${{ env.ARCHIVE_OUTDIR }} | |
run: | | |
dapr run --components-path=./.github/scripts/.components/ python3 ./.github/scripts/export_metrics_as_env.py | |
- name: See Dapr env variables | |
run: env | grep DAPR | |
- name: Notify Discord channel | |
env: | |
GITHUB_METRICS_PATH: ${{ env.ARCHIVE_OUTDIR }} | |
DISCORD_POST_URL: ${{ secrets.DISCORD_MONITORING_WEBHOOK_URL }} | |
run: | | |
dapr run --components-path=./.github/scripts/.components/ python3 ./.github/scripts/alert_on_discord.py | |
- name: Prepare GitHub badge content for dapr/dapr repo's E2E pass rate | |
run: | | |
echo "DAPR_E2E_BADGE_MESSAGE=${{ env.DAPR_LATEST_RUNS_E2E_TEST_SUCCESS_PERCENTAGE }}% pass rate" >> $GITHUB_ENV | |
DAPR_E2E_BADGE_COLOR=green | |
if [ ${{ env.DAPR_LATEST_RUNS_E2E_TEST_SUCCESS_PERCENTAGE }} -lt 80 ]; then | |
DAPR_E2E_BADGE_COLOR=yellow | |
fi | |
if [ ${{ env.DAPR_LATEST_RUNS_E2E_TEST_SUCCESS_PERCENTAGE }} -lt 50 ]; then | |
DAPR_E2E_BADGE_COLOR=red | |
fi | |
echo "DAPR_E2E_BADGE_COLOR=$DAPR_E2E_BADGE_COLOR" >> $GITHUB_ENV | |
- name: Updates dapr/dapr E2E pass rate badge | |
# Fork of schneegans/dynamic-badges-action | |
uses: artursouza/dynamic-badges-action@v1.4.0 | |
with: | |
auth: ${{ secrets.DAPR_BOT_TOKEN }} | |
gistID: 14e974e8fd6c6eab03a2475beb1d547a | |
filename: dapr-test-badge.json | |
label: dapr-test | |
message: ${{ env.DAPR_E2E_BADGE_MESSAGE }} | |
color: ${{ env.DAPR_E2E_BADGE_COLOR }} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@master | |
with: | |
name: dapr_github_metrics | |
path: ${{ env.ARCHIVE_OUTDIR }} |