Skip to content

cicd-tooling-github-workflow-meta_tests #926

cicd-tooling-github-workflow-meta_tests

cicd-tooling-github-workflow-meta_tests #926

---
name: cicd-tooling-github-workflow-meta_tests
on:
push:
schedule:
- cron: "0 6 * * 1"
workflow_dispatch:
# secrets:
# OPSGENIE_API_KEY:
# description: "Optional, enables Ops Genie alerts."
# required: false
# SLACK_WEBHOOK:
# description: "Optional, enables Slack notifications."
# required: false
env:
EXPECTED_MOLECULE_SCENARIOS: '[]'
jobs:
configuration:
uses: ./.github/workflows/job-00-cookiecutter-read_configuration.yml
scenarios:
needs:
- configuration
uses: ./.github/workflows/job-00-generic-identify_molecule_scenarios.yml
with:
MOLECULE_EXCLUSION_REGEX: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_MOLECULE_EXCLUDED_SCENARIOS_REGEX }}
MOLECULE_SCENARIO_PATH: "{{cookiecutter.project_slug}}/ansible_role/molecule"
scenarios_data_test:
needs:
- scenarios
runs-on: ubuntu-latest
steps:
- name: Molecule Scenario Discovery Test -- Checkout Repository
uses: actions/checkout@v4
- name: Molecule Scenario Discovery Test -- Setup Environment
env:
WORKFLOW_NAME: "test"
run: |
bash "./.github/scripts/step-setup-environment.sh"
shell: bash
- name: Molecule Scenario Discovery Test -- Install Toolbox
uses: ./.github/actions/action-00-toolbox
- name: Molecule Scenario Discovery Test -- Run Success Notification Action (Testing Locally)
if: needs.scenarios.outputs.SCENARIOS == env.EXPECTED_MOLECULE_SCENARIOS
uses: ./.cicd-tools/boxes/active/ci/github/actions/action-00-generic-notification
with:
NOTIFICATION_EMOJI: ":heavy_check_mark:"
NOTIFICATION_MESSAGE: "Molecule Scenario detection is working (received: ${{ toJSON(needs.scenarios.outputs.SCENARIOS) }})!"
NOTIFICATION_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
- name: Molecule Scenario Discovery Test -- Run Failure Notification Action (Testing Locally)
if: needs.scenarios.outputs.SCENARIOS != env.EXPECTED_MOLECULE_SCENARIOS
uses: ./.cicd-tools/boxes/active/ci/github/actions/action-00-generic-notification
with:
FORCE_HALT_WORKFLOW: true
NOTIFICATION_EMOJI: ":x:"
NOTIFICATION_MESSAGE: "Molecule Scenario detection is NOT working (received: ${{ toJSON(needs.scenarios.outputs.SCENARIOS) }}) !"
NOTIFICATION_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
secret_exists:
secrets:
SECRET: ${{ secrets.SLACK_WEBHOOK }}
uses: ./.github/workflows/job-00-generic-identify_secret_exists.yml
secret_does_not_exist:
secrets:
SECRET: ${{ secrets.NON_EXISTING_SECRET }}
uses: ./.github/workflows/job-00-generic-identify_secret_exists.yml
secrets_data_test:
needs:
- secret_exists
- secret_does_not_exist
runs-on: ubuntu-latest
steps:
- name: Secret Exists Test -- Checkout Repository
uses: actions/checkout@v4
- name: Secret Exists Test -- Setup Environment
env:
WORKFLOW_NAME: "test"
run: |
bash "./.github/scripts/step-setup-environment.sh"
shell: bash
- name: Secret Exists Test -- Install Toolbox
uses: ./.github/actions/action-00-toolbox
- name: Secret Exists Test -- Run Success Notification Action (Testing Locally)
if: needs.secret_exists.outputs.EXISTS == 'true' && needs.secret_does_not_exist.outputs.EXISTS == 'false'
uses: ./.cicd-tools/boxes/active/ci/github/actions/action-00-generic-notification
with:
NOTIFICATION_EMOJI: ":heavy_check_mark:"
NOTIFICATION_MESSAGE: "Secret definition validation is working (received: ${{ needs.secret_exists.outputs.EXISTS }} / ${{ needs.secret_does_not_exist.outputs.EXISTS }})!"
NOTIFICATION_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
- name: Secret Exists Test -- Run Failure Notification Action (Testing Locally)
if: needs.secret_exists.outputs.EXISTS != 'true' || needs.secret_does_not_exist.outputs.EXISTS != 'false'
uses: ./.cicd-tools/boxes/active/ci/github/actions/action-00-generic-notification
with:
FORCE_HALT_WORKFLOW: true
NOTIFICATION_EMOJI: ":x:"
NOTIFICATION_MESSAGE: "Secret definition validation is NOT working (received: ${{ needs.secret_exists.outputs.EXISTS }} / ${{ needs.secret_does_not_exist.outputs.EXISTS }})!"
NOTIFICATION_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
send_notification_test_success:
runs-on: ubuntu-latest
steps:
- name: Notification (Local Action Test) -- Checkout Repository
uses: actions/checkout@v4
- name: Notification (Local Action Test) -- Setup Environment
env:
WORKFLOW_NAME: "test"
run: |
bash "./.github/scripts/step-setup-environment.sh"
shell: bash
- name: Notification (Local Action Test) -- Install Toolbox
uses: ./.github/actions/action-00-toolbox
- name: Notification (Local Action Test) -- Run Notification Action (Testing Locally)
uses: ./.cicd-tools/boxes/active/ci/github/actions/action-00-generic-notification
with:
NOTIFICATION_EMOJI: ":vertical_traffic_light:"
NOTIFICATION_MESSAGE: "The testing workflow has started!"
NOTIFICATION_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
send_notification_test_failure:
runs-on: ubuntu-latest
steps:
- name: Notification (Local Action Test) -- Checkout Repository
uses: actions/checkout@v4
- name: Notification (Local Action Test) -- Setup Environment
env:
WORKFLOW_NAME: "test"
run: |
bash "./.github/scripts/step-setup-environment.sh"
shell: bash
- name: Notification (Local Action Test) -- Install Toolbox
uses: ./.github/actions/action-00-toolbox
- name: Notification (Local Action Test) -- Run Notification Action (Testing Locally)
uses: ./.cicd-tools/boxes/active/ci/github/actions/action-00-generic-notification
with:
NOTIFICATION_EMOJI: ":heavy_check_mark:"
NOTIFICATION_MESSAGE: "The local notification script is working!"
NOTIFICATION_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
TESTING_MODE: true
send_alert_test_failure_action:
runs-on: ubuntu-latest
steps:
- name: Alert (Local Action Test) -- Checkout Repository
uses: actions/checkout@v4
- name: Alert (Local Action Test) -- Setup Environment
env:
WORKFLOW_NAME: "test"
run: |
bash "./.github/scripts/step-setup-environment.sh"
shell: bash
- name: Alert (Local Action Test) -- Install Toolbox
uses: ./.github/actions/action-00-toolbox
- name: Alert (Local Action Test) -- Run Alert Action (Testing Locally)
uses: ./.cicd-tools/boxes/active/ci/github/actions/action-00-generic-alert_opsgenie
with:
ALERT_ALIAS: "test_alias"
ALERT_PRIORITY: "P0"
ALERT_MESSAGE: "Just a test alert."
NOTIFICATION_API_KEY: ${{ secrets.OPSGENIE_API_KEY }}
TESTING_MODE: true
send_alert_test_failure_workflow:
needs: [configuration]
secrets:
OPSGENIE_API_KEY: ${{ secrets.OPSGENIE_API_KEY }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: ./.github/workflows/job-00-generic-alert_opsgenie.yml
with:
ALERT_ALIAS: "test_alias"
ALERT_PRIORITY: "P0"
ALERT_MESSAGE: "Just a test alert."
TESTING_MODE: true
WORKFLOW_NAME: "test"
security_test_failure:
needs:
- configuration
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: ./.github/workflows/job-10-generic-security_scan_credentials.yml
with:
TESTING_MODE: true
WORKFLOW_NAME: "test"
markdown_links_test_failure:
needs:
- configuration
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: ./.github/workflows/job-30-cookiecutter-markdown_links.yml
with:
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
CONFIG_FILE: "{{cookiecutter.project_slug}}/.github/config/actions/gaurav-nelson-github-action-markdown-link-check.json"
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_PYTHON_VERSIONS) }}
TESTING_MODE: true
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_VERBOSE_NOTIFICATIONS }}
WORKFLOW_NAME: "test"
pre-commit_hooks_test_failure:
needs:
- configuration
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: ./.github/workflows/job-50-cookiecutter-test_precommit_hooks.yml
with:
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
ENABLED_PRECOMMIT_CHECKS: '["test_commit_lint_fails", "test_credentials_fails", "test_commit_spelling_fails", "test_shell_lint_fails", "test_shell_format_fails", "test_toml_lint_fails", "test_toml_lint_passes", "test_workflow_lint_fails", "test_workflow_header_lint_fails"]'
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_PYTHON_VERSIONS) }}
TEMPLATE_SCENARIOS: '["0.toml_linting-0.workflow_linting"]'
TESTING_MODE: true
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_VERBOSE_NOTIFICATIONS }}
WORKFLOW_NAME: "test"
commitizen_hooks_test_failure:
needs:
- configuration
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: ./.github/workflows/job-50-poetry-test_commitizen_hooks.yml
with:
COMMITIZEN_BUMP_TYPE: "MINOR"
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
EXPECTED_BUMPED_VERSION: "0.2.0"
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_PYTHON_VERSIONS) }}
TESTING_MODE: true
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_VERBOSE_NOTIFICATIONS }}
WORKFLOW_NAME: "test"
commit_lint_test_failure:
needs:
- configuration
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: ./.github/workflows/job-80-poetry-rev_range_command.yml
with:
COMMAND: |
poetry run cz check --rev-range "${PUSHED_COMMIT_REV_RANGE}"
COMMAND_NAME: "Commit Message Lint"
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_PYTHON_VERSIONS) }}
TESTING_MODE: true
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_VERBOSE_NOTIFICATIONS }}
WORKFLOW_NAME: "cookiecutter"
commit_spell_check_test_failure:
needs:
- configuration
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: ./.github/workflows/job-80-poetry-rev_range_command.yml
with:
COMMAND: |
CICD_COMMIT_MESSAGES_FILE="$(mktemp XXXXXXXX.git_history_file)"
git log --pretty=format:%s "${PUSHED_COMMIT_REV_RANGE}" > "${CICD_COMMIT_MESSAGES_FILE}"
poetry run pre-commit run --hook-stage manual spelling-vale-sync
poetry run pre-commit run --hook-stage commit-msg spelling-commit-message --commit-msg-filename "${CICD_COMMIT_MESSAGES_FILE}"
COMMAND_NAME: "Commit Message Spelling"
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_PYTHON_VERSIONS) }}
TESTING_MODE: true
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_VERBOSE_NOTIFICATIONS }}
WORKFLOW_NAME: "cookiecutter"
shell_lint_test_failure:
needs:
- configuration
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
strategy:
fail-fast: true
matrix:
hook:
- id: "format-shell"
name: "Shell Formatting"
- id: "lint-shell"
name: "Shell Linting"
max-parallel: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
uses: ./.github/workflows/job-80-cookiecutter-precommit_commit_stage_hook.yml
with:
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
PRECOMMIT_HOOK_ID: ${{ matrix.hook.id }}
PRECOMMIT_HOOK_NAME: ${{ matrix.hook.name }}
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_PYTHON_VERSIONS) }}
TESTING_MODE: true
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_VERBOSE_NOTIFICATIONS }}
WORKFLOW_NAME: "test"
toml_lint_test_failure:
needs:
- configuration
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: ./.github/workflows/job-80-cookiecutter-precommit_commit_stage_hook.yml
with:
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
PRECOMMIT_HOOK_ID: "format-toml"
PRECOMMIT_HOOK_NAME: "TOML Formatting"
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_PYTHON_VERSIONS) }}
TESTING_MODE: true
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_VERBOSE_NOTIFICATIONS }}
WORKFLOW_NAME: "test"
workflow_lint_test_failure:
needs:
- configuration
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
strategy:
fail-fast: true
matrix:
hook:
- id: "lint-github-workflow"
name: "Workflow Linting"
- id: "lint-github-workflow-header"
name: "Workflow Header Linting"
max-parallel: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
uses: ./.github/workflows/job-80-cookiecutter-precommit_commit_stage_hook.yml
with:
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
PRECOMMIT_HOOK_ID: ${{ matrix.hook.id }}
PRECOMMIT_HOOK_NAME: ${{ matrix.hook.name }}
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_PYTHON_VERSIONS) }}
TESTING_MODE: true
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_VERBOSE_NOTIFICATIONS }}
WORKFLOW_NAME: "test"
yaml_lint_test_failure:
needs:
- configuration
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: ./.github/workflows/job-80-cookiecutter-precommit_commit_stage_hook.yml
with:
CONCURRENCY: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_CONCURRENCY }}
PRECOMMIT_HOOK_ID: "yamllint"
PRECOMMIT_HOOK_NAME: "YAML Linting"
PYTHON_VERSIONS: ${{ toJSON(fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_PYTHON_VERSIONS) }}
TEMPLATE_SCENARIOS: '["0.toml_linting-0.workflow_linting"]'
VERBOSE_NOTIFICATIONS: ${{ fromJSON(needs.configuration.outputs.COOKIECUTTER_CONFIGURATION)._GITHUB_CI_DEFAULT_VERBOSE_NOTIFICATIONS }}
WORKFLOW_NAME: "test"
create_release_test_failure:
needs:
- configuration
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: ./.github/workflows/job-99-poetry-create_release.yml
with:
TESTING_MODE: true
WORKFLOW_NAME: "test"
success:
needs:
- commit_lint_test_failure
- commit_spell_check_test_failure
- commitizen_hooks_test_failure
- create_release_test_failure
- markdown_links_test_failure
- pre-commit_hooks_test_failure
- scenarios_data_test
- secrets_data_test
- security_test_failure
- send_alert_test_failure_action
- send_alert_test_failure_workflow
- send_notification_test_failure
- send_notification_test_success
- shell_lint_test_failure
- toml_lint_test_failure
- workflow_lint_test_failure
- yaml_lint_test_failure
runs-on: ubuntu-latest
steps:
- name: Notification (Local Action Test) -- Checkout Repository
uses: actions/checkout@v4
- name: Notification (Local Action Test) -- Setup Environment
env:
WORKFLOW_NAME: "test"
run: |
bash "./.github/scripts/step-setup-environment.sh"
shell: bash
- name: Notification (Local Action Test) -- Install Toolbox
uses: ./.github/actions/action-00-toolbox
- name: Notification (Local Action Test) -- Run Notification Action (Testing Locally)
uses: ./.cicd-tools/boxes/active/ci/github/actions/action-00-generic-notification
with:
NOTIFICATION_EMOJI: ":checkered_flag:"
NOTIFICATION_MESSAGE: "All tests have passed successfully!"
NOTIFICATION_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}