CI/CD
Use PR-oriented workflows & CI that pushes to Airfold
Airfold workspaces are fully defined in YAML files, which enables you to leverage version control and CI/CD similar to tools like dbt, Terraform, and other infrastructure as code systems.
Your files represent data pipelines as code with Airfold.
How CI/CD Works
CI/CD (Continuous Integration and Continuous Deployment) automates the process of testing, validating, and deploying changes to your projects.
In a typical CI/CD workflow:
- Continuous Integration (CI) ensures that changes, such as updates to pipelines or configurations, are tested and validated automatically whenever new code is pushed or a pull request is opened
- Continuous Deployment (CD) automates the deployment of validated changes to staging or production environments
Why Use CI/CD?
Implementing CI/CD for Airfold workspaces is highly recommended for production systems as it enables you to:
- Automate the process of testing, validating, and deploying changes to Airfold pipelines
- Track changes by leveraging version control with your CI/CD pipelines
- Maintain consistency across various environments (e.g., staging and production)
GitHub Actions Example
GitHub Actions is one way to integrate Airfold with CI/CD pipelines.
Let’s go through an example of setting up a deployment workflow for Airlang using GitHub Actions:
on
push
: Runs the workflow whenever changes are pushed to the main
branch
pull_request
: Executes the workflow when a pull request is opened or updated for the main branch
workflow_dispatch
: Allows the workflow to be triggered manually from the Actions tab in GitHub
permissions
Grants the workflow specific permissions:
id-token
: Required for OIDC authenticationcontents
: Allows the workflow to read/write repository contentspull-requests
: Enables the workflow to comment on pull requests
jobs
jobs
: Defines a single job named Plan / Apply
runs-on: ubuntu-latest
: Specifies the environment where the job will run
1. Checkout Repository
- Clones the repository, fetching all commit history and submodules
- Authenticates using a secret
DEPLOY_TOKEN
2. Set Up Python 3.11
- Installs and configures Python 3.11 for the workflow
3. Setup Airfold CLI
- Installs the Airfold CLI and configures it using the API key
4. Airfold diff
- Runs
af diff
to compare the current and previous states of the Airfold configuration - Executes only for pull requests
continue-on-error: true
: Prevents failures in this step from stopping the workflow
5. Airfold plan
- Performs a dry run of
af push
to simulate changes
6. Airfold Status
- Stops the workflow if the plan step fails, ensuring only valid changes proceed
7. Airfold push and apply
Pushes changes to Airfold workspace when:
- Code is pushed to main
- The workflow is triggered manually through
workflow_dispatch
GitHub Actions
GitHub Actions enable you to define workflows as code using YAML configuration files in your repository.
High-level overview of a GitHub Actions workflow:
-
Define a Workflow
-
Specify Triggers
-
Define Jobs
See more on the GitHub Actions Documentation.