Debian Codegraph @

debian/missing-sources/zerocopy/ci/check_actions.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2 #
3 # Copyright 2025 The Fuchsia Authors
4 #
5 # Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
6 # <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
7 # license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
8 # This file may not be copied, modified, or distributed except according to
9 # those terms.
10
11 set -eo pipefail
12
13 script_name="ci/check_actions.sh"
14
15 # Ensure action-validator is installed
16 if [ ! -x "$HOME/.cargo/bin/action-validator" ]; then
17 echo "$script_name: action-validator not found, installing..." >&2
18 # Install specific version to ensure reproducibility
19 cargo install -q action-validator --version 0.8.0 --locked
20 fi
21 export PATH="$HOME/.cargo/bin:$PATH"
22
23 # Files to exclude from validation (e.g., because they are not Actions/Workflows)
24 # Use relative paths matching `find .github` output
25 EXCLUDE_FILES=(
26 "./.github/dependabot.yml"
27 "./.github/release.yml"
28 )
29
30 failed=0
31
32 # Use process substitution and while loop to handle filenames with spaces robustly
33 while IFS= read -r -d '' file; do
34 # Check if file is in exclusion list
35 for exclude in "${EXCLUDE_FILES[@]}"; do
36 if [[ "$file" == "$exclude" ]]; then
37 continue 2
38 fi
39 done
40
41 if ! output=$(action-validator "$file" 2>&1); then
42 echo "$script_name: ❌ Validation failed for $file" >&2
43 echo "$output" | sed "s|^|$script_name: |" >&2
44 failed=1
45 fi
46 done < <(find ./.github -type f \( -iname '*.yml' -o -iname '*.yaml' \) -print0)
47
48 if [[ $failed -ne 0 ]]; then
49 echo "$script_name: One or more files failed validation." >&2
50 exit 1
51 fi