CI/CD Pipelines
Relevant source files
The following files were used as context for generating this wiki page:
The CI/CD pipeline for the Actionmap project is designed to automate software quality assurance through a series of automated tests and linting procedures. It ensures that every contribution meets the project's standards for Ruby on Rails and JavaScript codebases before integration. The primary orchestration for these pipelines is handled via GitHub Actions, specifically focused on running the full suite of specifications and linting tools.
The pipeline integrates multiple testing frameworks including RSpec for unit and integration testing, Cucumber for behavior-driven development (BDD), and specialized linters for JavaScript (ESLint) and HAML templates. Coverage reporting is also integrated into the test suite to monitor code quality over time.
Sources: .github/workflows/specs.yml, README.md:12
Pipeline Orchestration
The project utilizes GitHub Actions to define its automated workflows. The primary workflow, titled "All Specs," is triggered on every push to the repository and for pull requests targeting the main branch. This ensures a continuous integration loop where code is validated immediately upon submission.
Workflow Configuration
The workflow is defined in YAML and specifies a job named specs that runs on an Ubuntu environment. It handles the environment setup, including Ruby and Node.js dependencies, database initialization, and the execution of the test suites.
The diagram above illustrates the sequential execution of the CI pipeline from trigger to final reporting.
Sources: .github/workflows/specs.yml:1-30
Automated Testing Suites
The CI pipeline executes three distinct types of tests to ensure comprehensive coverage of the application logic and user interface.
1. RSpec Testing
RSpec is used for testing the Ruby backend. The pipeline configures the environment to use SimpleCov for tracking code coverage. When running in a CI environment, specialized formatters (such as Codecov) can be enabled to export these metrics.
| Component | Description | File Reference |
|---|---|---|
| SimpleCov | Analyzes code coverage for Rails components, filtering out the lib directory. | spec/rails_helper.rb |
| DatabaseCleaner | Ensures a clean database state between tests using transaction or truncation strategies. | spec/rails_helper.rb |
| FactoryBot | Manages test data generation by finding and loading definitions before the suite runs. | spec/rails_helper.rb |
Sources: spec/rails_helper.rb:5-80, spec/spec_helper.rb:1-100
2. Cucumber BDD
Behavioral tests are managed through Cucumber. The CI environment uses specific profiles defined in the configuration to manage execution speed and strictness.
- Default Profile: Runs all features with a "pretty" format, excluding work-in-progress (
@wip) tags. - Rerun Profile: Used to record and re-run failing tests to isolate intermittent issues.
Sources: config/cucumber.yml:1-10, features/support/env.rb:1-60
Static Analysis and Linters
Static analysis is integrated directly into the RSpec suite, allowing linting errors to fail the build just like a broken test case.
JavaScript Linting (ESLint)
JavaScript code quality is enforced using ESLint. The project uses the eslint-config-airbnb-base standard. The CI runs a specific spec that executes the yarn run lint command and expects a clean report.
// package.json scripts
"scripts": {
"lint": "./node_modules/.bin/eslint \"app/**/*.js\" \"config/**/*.js\"",
"lint_fix": "./node_modules/.bin/eslint --fix \"app/**/*.js\" \"config/**/*.js\""
}
Sources: package.json:28-31, spec/linters/eslint_spec.rb:5-15
HAML Linting
The pipeline includes haml-lint to analyze the project's view templates. Similar to ESLint, this is wrapped in an RSpec test that inspects all HAML files and fails if any lints are detected.
Sources: spec/linters/haml_lint_spec.rb:5-15
Environment Configuration
The pipeline manages environment-specific settings to ensure that tests run in an isolated and predictable manner. This includes Babel configurations for transpiling JavaScript during tests and Webpacker settings for asset compilation.
The diagram shows how the build environment differentiates between test and production configurations for asset compilation.
Conclusion
The CI/CD pipeline in Actionmap provides a robust safety net by combining behavior-driven tests, unit tests, and strict static analysis. By embedding linting within the test suite and utilizing GitHub Actions for orchestration, the project maintains a high standard of code quality and ensures that the codebase remains stable across all contributions.