diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 776cca8f..c2b5c54b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1,4 @@ -* @ryanaidilp @rii92 \ No newline at end of file +* @ryanaidilp + +app/* @rii92 @gerigeri00000 @devara46 +packages/* @rii92 @gerigeri00000 @devara46 \ No newline at end of file diff --git a/.github/scripts/notify_discord.py b/.github/scripts/notify_discord.py index 6c167a94..9bb2f5ff 100644 --- a/.github/scripts/notify_discord.py +++ b/.github/scripts/notify_discord.py @@ -11,36 +11,50 @@ def main(): repo_name = os.getenv("REPO_NAME") discord_map_json = os.getenv("DISCORD_MAP") - # Parse mapping from secret + # Parse GitHub -> Discord map from secrets discord_map = json.loads(discord_map_json) - # Read CODEOWNERS + # Mention the PR author + pr_author_mention = f"<@{discord_map.get(pr_author)}>" if pr_author in discord_map else f"@{pr_author}" + + # Read .github/CODEOWNERS codeowners_path = Path(".github/CODEOWNERS") - owner_lines = codeowners_path.read_text().splitlines() - - github_mentions = set() - for line in owner_lines: - if line.strip().startswith("#") or not line.strip(): - continue - owners = re.findall(r"@([a-zA-Z0-9_-]+)", line) - github_mentions.update(owners) - - discord_mentions = [] - for gh_user in github_mentions: - discord_id = discord_map.get(gh_user) - if discord_id: - discord_mentions.append(f"<@{discord_id}>") - - mentions = " ".join(discord_mentions) if discord_mentions else "Tidak ada code owner terdeteksi." + if not codeowners_path.exists(): + print("⚠️ No CODEOWNERS file found.") + owners = [] + else: + lines = codeowners_path.read_text().splitlines() + owners = set() + for line in lines: + if line.strip().startswith("#") or not line.strip(): + continue + owners.update(re.findall(r"@([a-zA-Z0-9_-]+)", line)) + + # Remove the author from the list of codeowners + reviewers = owners - {pr_author} + + # Convert GitHub usernames to Discord mentions if available + if reviewers: + reviewer_mentions = [ + f"<@{discord_map.get(user)}>" if user in discord_map else f"@{user}" + for user in reviewers + ] + mentions = " ".join(reviewer_mentions) + else: + mentions = "Tidak ada reviewer lain yang terdeteksi." + + # Compose the message message = ( - f"📣 Pull Request Baru di **{repo_name}** oleh **{pr_author}**\n" + f"📣 Pull Request Baru di **{repo_name}** oleh {pr_author_mention}\n" f"🔗 [{pr_title}]({pr_url})\n" f"{mentions} mohon review ya 🙏" ) + # Send to Discord webhook = os.getenv("DISCORD_WEBHOOK") response = requests.post(webhook, json={"content": message}) response.raise_for_status() + print("✅ Notifikasi dikirim ke Discord.") if __name__ == "__main__": main() diff --git a/.github/workflows/codecov.yaml b/.github/workflows/codecov.yaml index 1bce5f01..e7e7475d 100644 --- a/.github/workflows/codecov.yaml +++ b/.github/workflows/codecov.yaml @@ -41,25 +41,18 @@ jobs: - name: Cleaning lcov.info run: | lcov --remove ./coverage/lcov.info \ - "**/*.config.dart" \ "**/base_entity_*.dart" \ "**/base_entity.dart" \ "**/network_client.dart" \ "**/request_data.dart" \ "**/response_data.dart" \ "**/*_model.dart" \ - "**/base_network_injector.dart" \ + "**/base_network_interceptor.dart" \ "**/result.dart" \ "**/stadata_flutter_sdk.dart" \ "**/register_module.dart" \ - "**/http_*.dart" \ - "**/*_http_module.dart" \ "**/*_log_*.dart" \ - "**/*.g.dart" \ - "**/*.freezed.dart" \ - "**/*_serializer.dart" \ "**/*_converter.dart" \ - "**/service_locator.dart" \ "**/retry_interceptor.dart" \ "**/env.dart" \ "**/api_config.dart" \ diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b5c7b4e8..6df6a7ca 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -27,4 +27,4 @@ jobs: working_directory: packages/stadata_flutter_sdk flutter_channel: stable min_coverage: 80 - coverage_excludes: "**/*.config.dart **/base_entity_*.dart **/base_entity.dart **/stadata_flutter_sdk.dart **/register_module.dart **/http_*.dart **/*_http_module.dart **/*_log_*.dart **/*.g.dart **/*.freezed.dart **/*_serializer.dart **/*_converter.dart **/service_locator.dart **/env.dart **/usecase.dart **/injector.dart **/*_injector.dart **/network_client.dart **/request_data.dart **/response_data.dart **/api_config.dart **/base_network_injector.dart **/result.dart **/*_model.dart **/retry_interceptor.dart" + coverage_excludes: "**/base_entity_*.dart **/base_entity.dart **/stadata_flutter_sdk.dart **/register_module.dart **/*_log_*.dart **/*_converter.dart **/env.dart **/usecase.dart **/injector.dart **/*_injector.dart **/network_client.dart **/request_data.dart **/response_data.dart **/api_config.dart **/base_network_interceptor.dart **/result.dart **/*_model.dart **/retry_interceptor.dart" diff --git a/.github/workflows/notify-discord-pr.yml b/.github/workflows/notify-discord-pr.yml index 6052ca36..65fa9572 100644 --- a/.github/workflows/notify-discord-pr.yml +++ b/.github/workflows/notify-discord-pr.yml @@ -2,7 +2,21 @@ name: Notify Discord on PR on: pull_request: - types: [opened] + types: [opened, ready_for_review] + workflow_dispatch: + inputs: + pr_title: + description: "Pull Request Title" + required: true + pr_url: + description: "Pull Request URL" + required: true + pr_author: + description: "Pull Request Author" + required: true + repo_name: + description: "Repository Name" + required: true jobs: notify: @@ -23,8 +37,8 @@ jobs: env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} DISCORD_MAP: ${{ secrets.DISCORD_MAP }} - PR_TITLE: ${{ github.event.pull_request.title }} - PR_URL: ${{ github.event.pull_request.html_url }} - PR_AUTHOR: ${{ github.actor }} - REPO_NAME: ${{ github.repository }} + PR_TITLE: ${{ github.event.pull_request.title || inputs.pr_title }} + PR_URL: ${{ github.event.pull_request.html_url || inputs.pr_url }} + PR_AUTHOR: ${{ github.actor || inputs.pr_author }} + REPO_NAME: ${{ github.repository || inputs.repo_name }} run: python .github/scripts/notify_discord.py diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..cf147b31 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,16 @@ +name: Publish to pub.dev + +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" # for tags like: '1.2.3' + +jobs: + publish: + permissions: + id-token: write # Required for authentication using OIDC + uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 + with: + # Specify the github actions deployment environment + environment: pub.dev + working-directory: packages/stadata_fllutter_sdk