ci: add build-and-release watchdog

This commit is contained in:
Haitao Pan 2026-04-05 17:50:23 +08:00
parent 3c3050187e
commit c1e4e444cb
2 changed files with 107 additions and 0 deletions

View File

@ -0,0 +1,41 @@
name: Watch Build And Release XWorkmate Packages
on:
workflow_run:
workflows:
- Build and Release XWorkmate Packages
types:
- completed
workflow_dispatch:
schedule:
- cron: "17 3 * * 1"
permissions:
contents: read
concurrency:
group: watch-build-and-release-${{ github.ref }}
cancel-in-progress: true
env:
FLUTTER_VERSION: 3.41.4
jobs:
watch:
runs-on: ubuntu-22.04
steps:
- name: Checkout source
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Set up Flutter SDK
uses: ./.github/actions/setup-flutter-sdk
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
- name: Install Linux dependencies
shell: bash
run: bash ./scripts/ci/setup_platform_deps.sh linux
- name: Run workflow health monitor
shell: bash
run: bash ./scripts/ci/monitor_build_and_release.sh

View File

@ -0,0 +1,66 @@
#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
workflow_file="$repo_root/.github/workflows/build-and-release.yml"
require_file() {
local path="$1"
if [[ ! -f "$path" ]]; then
echo "Missing required file: $path" >&2
exit 1
fi
}
require_exec() {
local path="$1"
if [[ ! -x "$path" ]]; then
echo "Missing executable bit: $path" >&2
exit 1
fi
}
require_file "$workflow_file"
require_file "$repo_root/scripts/ci/run_code_analysis.sh"
require_file "$repo_root/scripts/ci/build_matrix_artifacts.sh"
require_file "$repo_root/scripts/ci/setup_platform_deps.sh"
require_file "$repo_root/scripts/ci/compute_release_metadata.sh"
require_exec "$repo_root/scripts/ci/run_code_analysis.sh"
require_exec "$repo_root/scripts/ci/build_matrix_artifacts.sh"
require_exec "$repo_root/scripts/ci/setup_platform_deps.sh"
require_exec "$repo_root/scripts/ci/compute_release_metadata.sh"
ruby - "$workflow_file" <<'RUBY'
require 'yaml'
workflow_path = ARGV.fetch(0)
data = YAML.load_file(workflow_path)
expected_jobs = %w[prepare verify build release]
missing_jobs = expected_jobs.reject { |job| data.fetch('jobs', {}).key?(job) }
abort("Missing workflow jobs: #{missing_jobs.join(', ')}") unless missing_jobs.empty?
build_job = data.fetch('jobs').fetch('build')
matrix = build_job.fetch('strategy', {}).fetch('matrix', {}).fetch('include', [])
platforms = matrix.map { |entry| entry['platform'] }.compact.to_h { |platform| [platform, true] }.keys
expected_platforms = %w[linux windows macos ios android]
missing_platforms = expected_platforms.reject { |platform| platforms.include?(platform) }
abort("Missing build matrix platforms: #{missing_platforms.join(', ')}") unless missing_platforms.empty?
text = File.read(workflow_path)
required_snippets = [
'bash ./scripts/ci/run_code_analysis.sh',
'bash ./scripts/ci/build_matrix_artifacts.sh',
'bash ./scripts/ci/setup_platform_deps.sh',
'bash ./scripts/ci/compute_release_metadata.sh',
'actions/upload-artifact',
'actions/download-artifact'
]
missing_snippets = required_snippets.reject { |snippet| text.include?(snippet) }
abort("Missing workflow references: #{missing_snippets.join(', ')}") unless missing_snippets.empty?
puts 'Workflow structure check passed.'
RUBY
echo "Monitoring checks passed for build-and-release workflow."