|
| 1 | +# 01: What are Workflows? |
| 2 | + |
| 3 | +Welcome to the Hiero Python SDK! To ensure a smooth, safe, and professional contribution experience, this repository relies heavily on **GitHub Workflows**. This guide explains the foundational concepts of repository automation and how it helps you as a contributor. |
| 4 | + |
| 5 | +### What is a Workflow? |
| 6 | +A workflow is an automated process that is **event-driven**. It stays inactive until a specific "Trigger" occurs. |
| 7 | + |
| 8 | +* **The Trigger:** This is the **"When"** (e.g., someone comments `/assign` on an issue). |
| 9 | +* **The Logic:** This is the **"How"** (e.g., the system checks if you are eligible and then assigns you). |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## The Anatomy of a Hiero Workflow |
| 14 | +Every workflow in this repository follows a standardized design pattern to maintain security and consistency. |
| 15 | + |
| 16 | +#### 1. Job Title |
| 17 | +Every workflow defines one or more **Jobs**. These are the top-level tasks (like `lint`, `test`, or `assign`). You can see these names in the "Actions" tab of the repository to track the progress of your contribution. |
| 18 | + |
| 19 | +#### 2. Triggers (`on:`) |
| 20 | +Workflows are defined by their triggers. Common triggers in this repo include: |
| 21 | +* `pull_request`: Runs when you open or update a PR. |
| 22 | +* `issue_comment`: Runs when you type a command in an issue. |
| 23 | +* `push`: Runs when code is merged into the main branch. |
| 24 | + |
| 25 | +#### 3. Security Shield (`harden-runner`) |
| 26 | +Security is our top priority. We use `step-security/harden-runner` in every workflow. |
| 27 | +* **Purpose:** It creates a "secure perimeter" around the temporary computer running the code. It ensures that the workflow only communicates with trusted endpoints (like GitHub) and prevents unauthorized data from leaving the environment. |
| 28 | + |
| 29 | +#### 4. Workspace Setup (`checkout`) |
| 30 | +GitHub starts every workflow on a clean, empty virtual machine. The `actions/checkout` step "downloads" a copy of the Hiero repository onto that machine so the automation can interact with our files. |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## Why Workflows Call Scripts (Orchestration vs. Logic) |
| 35 | +You will notice that our workflow files (YAML) often call external **scripts** located in [`.github/scripts/`](../../.github/scripts). |
| 36 | + |
| 37 | +* **YAML (The Orchestrator):** Handles the "When." It manages the triggers, the security steps, and the environment setup. |
| 38 | +* **Scripts (The Logic):** Handles the "How." We use JavaScript, Python, or Bash scripts for complex decision-making. |
| 39 | + |
| 40 | +**Why the separation?** Scripts are easier to read, test, and debug. Complex tasks—such as checking if a contributor has completed a "Good First Issue" before assigning them a "Beginner" task—require the advanced logic that only a script can provide. |
| 41 | + |
| 42 | +--- |
| 43 | + |
| 44 | +## Why We Rely on Automation |
| 45 | +With over 30 workflows running in this repository, automation is the backbone of our "Support Infrastructure." |
| 46 | + |
| 47 | +| Benefit | Explanation | |
| 48 | +| :--- | :--- | |
| 49 | +| **Better Developer Experience (DX)** | You get instant feedback. Our Linters find formatting errors in seconds, so you don't have to wait days for a human review. | |
| 50 | +| **Safety** | Automation acts as a "Safety Net." Our test suite runs on every PR, ensuring that new changes don't accidentally break existing features. | |
| 51 | +| **Scalability** | Automation allows the project to grow. Bots handle the "boring" tasks (like assigning issues or labeling PRs) so maintainers can focus on high-level code architecture. | |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## Case Study: The Auto-Assignment Bot |
| 56 | +A great example of these concepts in action is our **Beginner Assignment Bot**. |
| 57 | + |
| 58 | +1. **The Trigger:** A contributor types `/assign` on an issue. |
| 59 | +2. **The Logic:** The workflow calls `bot-beginner-assign-on-comment.js`. This "brain" checks if the issue is already taken and verifies the contributor's history. |
| 60 | +3. **The Result:** If everything is valid, the bot assigns the user immediately. This provides a **seamless DX**—you can start working on an issue at 3 AM without waiting for a maintainer to wake up and manually assign you. |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## Troubleshooting: Handling Failed Status Checks |
| 65 | +If a workflow check fails on your Pull Request: |
| 66 | +1. **Don't Panic:** Failures are often simple formatting issues. |
| 67 | +2. **Click "Details":** This takes you to the logs. |
| 68 | +3. **Find the Error:** The bot will usually point to the exact line of code that needs fixing. |
| 69 | +4. **Fix and Push:** Look for the red text in the logs. The bot will usually point to the exact file and line number that needs fixing. |
0 commit comments