Local Development
This document provides instructions for local development and testing of the ComplianceAsCode Builder project.
Testing GitHub Actions Workflows Locally
GitHub Actions workflows can be tested locally before committing using act, a tool that runs GitHub Actions locally.
Prerequisites
- Install
act
- See Installing Act for detailed installation instructions for all platforms - Docker must be installed and running
Running Local Workflow Tests
Use the provided script to test workflows:
# List available workflows and jobs
./scripts/test-github-actions.sh --list
# Test a specific workflow
./scripts/test-github-actions.sh --workflow build-test.yml
# Test a specific job in a workflow
./scripts/test-github-actions.sh --workflow publish-container.yml --job push-to-registry
# Simulate a specific event (e.g., pull_request)
./scripts/test-github-actions.sh --event pull_request
How Local Testing Works
The local testing process:
- Creates a test environment with the necessary certificates and configuration
- Uses Docker to simulate GitHub’s runner environment
- Executes the workflow steps in isolated containers
- Shows outputs similar to what you’d see in GitHub’s UI
Limitations
Local testing with act
has some limitations:
- Some GitHub-specific features may not work fully (e.g., certain GitHub context variables)
- Secrets handling is different locally
- Performance may differ from GitHub-hosted runners
- Container registry interactions will need proper credentials
Developing and Testing Container Changes
To test changes to the Docker containers:
- Make changes to the Dockerfile or Dockerfile.optimized
- Run the setup script:
./setup.sh
- Build the container:
docker-compose build
- Start the container:
docker-compose up -d
- Connect to the container:
docker exec -it compliance-as-code bash
- Test your changes inside the container
Documentation Development
When updating documentation:
- Ensure cross-links between documents are maintained
- Test all code examples
- Update the appropriate README files
- Consider impact on GitHub Pages if implemented
Submitting Changes
After local testing:
- Commit your changes:
git commit -am 'Add feature XYZ'
- Push to your fork:
git push origin my-feature
- Create a pull request
- GitHub Actions will run the workflows automatically on your PR
For more details, see CONTRIBUTING.md.