How sasp2025/actions-example works
Project Type and Purpose
• This is not a traditional multi-tier application but a repository of example GitHub Actions, jobs, and Python tests.
• It demonstrates how to define reusable workflows (.github/workflows), custom actions (.github/jobs), and how to run Python code and pytest tests automatically on GitHub.
File Structure Analysis
Top-level directories and files:
• .github/
– jobs/ (custom actions definitions)
• greeting/ (a “greeting” composite action)
• action.yml (action metadata)
• get_time.py, greetings.py (action implementation)
– workflows/ (workflow YAMLs)
• reusable_pytest.yml (reusable workflow for running pytest)
• test_greeting_action.yml (invokes greeting action and tests)
• test_pytest_action.yml (invokes reusable pytest workflow)
• src/ (source code for actions)
– example_source.py
• tests/ (pytest test suite)
– conftest.py
– test_example_pytests.py
• pyproject.toml (project metadata and dependencies)
• README.md, LICENSE, .gitignore
README Insights
• Describes the repository as “example GitHub actions and testing for use with SASP2025 summer project.”
Components
a. Repository Core
• GitHub Repo (this codebase)
• Source Code (src/example_source.py)
• Test Suite (tests/)
• Configuration (pyproject.toml)
b. GitHub Actions Layer
• Workflows (.github/workflows/*)
• Custom Actions (.github/jobs/greeting)
c. Execution Environment
• GitHub Runner (hosted VM/container)
d. External Integrations
• PyPI or Package Registry (if publishing)
• GitHub API (to fetch context and trigger workflows)
Relationships and Data Flows
• Developer pushes or opens a pull request → GitHub sends a webhook event
• Workflow YAML triggers (on: push, pull_request) → GitHub Runner starts job
• Jobs invoke either:
• A composite action from .github/jobs/greeting
• A reusable workflow from .github/workflows/reusable_pytest.yml
• Runner checks out code → sets up Python → installs dependencies from pyproject.toml → runs example_source.py logic or pytest tests
• Test results and logs are sent back to GitHub UI
Architectural Patterns and Principles
• CI/CD Pipeline Pattern: clearly separated workflow definitions and job implementations
• Reusability: workflows call other workflows (DRY principle)
• Modularity: custom actions are packaged separately under .github/jobs
• Config as code: everything defined via YAML and Python scripts
Technologies, Frameworks, Libraries
• GitHub Actions (YAML-based automation)
• Python 3 (src and tests)
• pytest (tests/test_example_pytests.py)
• PyPI packaging via pyproject.toml
Final Advice
• Capturing the flow of a code change from commit through automated testing.
• How workflows and jobs nest or call each other.
• Reusability and modularity of actions and workflows.