Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

github_actions: Check if feature levels are updated in API docs.

Vector73f9d52189fcae
diff --git a/.github/workflows/check-feature-level-updated.yml b/.github/workflows/check-feature-level-updated.yml
new file mode 100644
index 00000000000..f60c552b672
--- /dev/null
+++ b/.github/workflows/check-feature-level-updated.yml
@@ -0,0 +1,46 @@
+name: Check feature level updated
+
+on:
+ push:
+ branches: [main]
+ paths:
+ - "api_docs/**"
+ workflow_dispatch:
+
+jobs:
+ check-feature-level-updated:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Set up Python
+ uses: actions/setup-python@v4
+ with:
+ python-version: "3.x"
+
+ - name: Add required permissions
+ run: chmod +x ./tools/check-feature-level-updated
+
+ - name: Run tools/check-feature-level-updated
+ id: run_check
+ run: ./tools/check-feature-level-updated >> $GITHUB_OUTPUT
+
+ - name: Report status to CZO
+ if: ${{ steps.run_check.outputs.fail == 'true' && github.repository == 'zulip/zulip'}}
+ uses: zulip/github-actions-zulip/send-message@v1
+ with:
+ api-key: ${{ secrets.ZULIP_BOT_KEY }}
+ organization-url: "https://chat.zulip.org"
+ to: "automated testing"
+ topic: ${{ steps.run_check.outputs.topic }}
+ type: "stream"
+ content: ${{ steps.run_check.outputs.content }}
+
+ - name: Fail job if feature level not updated in API docs
+ if: ${{ steps.run_check.outputs.fail == 'true' }}
+ run: exit 1
diff --git a/tools/check-feature-level-updated b/tools/check-feature-level-updated
new file mode 100755
index 00000000000..99b2d6dfe5b
--- /dev/null
+++ b/tools/check-feature-level-updated
@@ -0,0 +1,31 @@
+#!/usr/bin/env python3
+import os
+import sys
+from pathlib import Path
+
+
+def get_build_url_from_environment() -> str:
+ server = os.environ["GITHUB_SERVER_URL"]
+ repo = os.environ["GITHUB_REPOSITORY"]
+ run_id = os.environ["GITHUB_RUN_ID"]
+ return f"{server}/{repo}/actions/runs/{run_id}"
+
+
+if __name__ == "__main__":
+ branch = os.environ.get("GITHUB_REF", "unknown branch").split("/")[-1]
+ topic = f"{branch} failing"
+ build_url = get_build_url_from_environment()
+ github_actor = os.environ.get("GITHUB_ACTOR", "unknown user")
+
+ api_docs_folder = Path("api_docs")
+ api_docs_paths = list(api_docs_folder.glob("*.md"))
+ api_docs_paths.append(Path("zerver/openapi/zulip.yaml"))
+
+ for api_docs_path in api_docs_paths:
+ with open(api_docs_path) as file:
+ if "ZF-" in file.read():
+ content = f"[Build]({build_url}) triggered by {github_actor} on branch `{branch}` has failed: Feature level not replaced in '{api_docs_path}'."
+ print(f"fail=true\ntopic={topic}\ncontent={content}")
+ sys.exit(0)
+
+ print("fail=false")