Matrix Docker Ansible eploy
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

75 righe
2.7 KiB

  1. #!/usr/bin/env bash
  2. # SPDX-FileCopyrightText: 2026 Slavi Pantaleev
  3. #
  4. # SPDX-License-Identifier: AGPL-3.0-or-later
  5. set -euo pipefail
  6. repo_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
  7. # An optional image version lets maintainers reproduce failures before changing the pin.
  8. mapfile -t versions < <(
  9. sed -n "s/^ MATRIX_RENOVATE_VERSION: '\([^']*\)'$/\1/p" \
  10. "$repo_dir/.github/workflows/renovate.yml"
  11. )
  12. if (( ${#versions[@]} != 1 )) || [[ -z "${versions[0]}" ]]; then
  13. echo 'Could not resolve exactly one pinned Renovate version' >&2
  14. exit 1
  15. fi
  16. version="${1:-${versions[0]}}"
  17. image="ghcr.io/renovatebot/renovate:$version"
  18. log_file="$(mktemp)"
  19. trap 'rm -f -- "$log_file"' EXIT
  20. # Use the image's normal entrypoint for extraction, loading the real runtime.
  21. # No credentials or network are needed for validation and dependency extraction.
  22. docker_args=(
  23. --rm
  24. --network none
  25. --volume "$repo_dir:/workspace:ro"
  26. --workdir /workspace
  27. --env NODE_OPTIONS=--unhandled-rejections=strict
  28. )
  29. echo "Validating configuration with $image"
  30. docker run "${docker_args[@]}" \
  31. --entrypoint renovate-config-validator \
  32. "$image" --strict
  33. echo "Extracting dependencies with $image"
  34. docker run "${docker_args[@]}" \
  35. --env LOG_LEVEL=info \
  36. --env LOG_FORMAT=json \
  37. "$image" --platform=local --dry-run=extract \
  38. | tee "$log_file"
  39. # Exit status alone is insufficient: 44.64.0 crashed at startup but exited 0.
  40. # Require completion and useful results from every manager used by this repository.
  41. # The missing-token warning is expected: extraction needs no GitHub API access.
  42. if ! jq --slurp --exit-status '
  43. all(.[]; .level < 50)
  44. and any(.[]; .msg == "Repository finished" and .repository == "local")
  45. and any(.[];
  46. .msg == "Dependency extraction complete"
  47. and (.stats.managers as $managers
  48. | all(["ansible-galaxy", "dockerfile", "github-actions", "mise", "nix", "pip_requirements", "pre-commit", "regex"][];
  49. $managers[.].depCount > 0))
  50. )
  51. and any(.[];
  52. .msg == "Extracted dependencies"
  53. and any(.packageFiles["ansible-galaxy"][]?;
  54. .packageFile == "requirements.yml" and (.deps | length) > 0)
  55. and any(.packageFiles.regex[]?;
  56. (.packageFile | startswith("roles/custom/")) and (.deps | length) > 0)
  57. and any(.packageFiles.regex[]?;
  58. .packageFile == "molecule-shared/vars.yml" and (.deps | length) > 0)
  59. and any(.packageFiles.regex[]?.deps[]?;
  60. .depName == "matrix-renovate-runner" and .datasource == "docker")
  61. )
  62. ' "$log_file"; then
  63. echo 'Renovate did not complete dependency extraction successfully' >&2
  64. exit 1
  65. fi
  66. echo "Renovate $version passed configuration validation and dependency extraction"