This documentation provides a detailed overview of the Continuous Integration/Continuous Deployment (CI/CD) automation scripts associated with the thanos-io/thanos
project. It outlines the steps for automation within the project and describes the existing scripts that support CI/CD processes.
Overview
As of the latest available data, the thanos-io/thanos
project has implemented CI/CD automation using tooling and workflows located primarily within the .circleci
directory and various scripts in the scripts
directory. This section will detail some important scripts and processes that facilitate the automation.
CI/CD Automation Scripts
CircleCI Configuration
The CircleCI configuration file located at .circleci/config.yml
serves as the primary entry point for the CI/CD pipeline. This YAML file defines jobs, workflows, and execution parameters pertaining to testing, building, and deploying the thanos
project.
Key jobs in CircleCI configuration:
- Build and Test: Invokes the various Makefile targets that manage compilation and run tests.
- Versioning: Handles version updates for containers and other components.
Snippet from .circleci/config.yml
:
version: 2.1
jobs:
build:
docker:
- image: golang:1.16
steps:
- checkout
- run:
name: Set up Go environment
command: make install-tool-deps
- run:
name: Run unit tests
command: make test
Makefile for CI Tasks
The project’s Makefile
contains a range of targets that streamline the build and test processes. Key CI tasks include linting, testing, and building Docker images.
Example commands in Makefile:
make test
: Executes all test files and checks that they pass.make docker
: Builds the Docker images according to the specifications in theDockerfile
.
Example target in Makefile
:
test:
go test ./... -v -tags '!linux,!stringlabels'
Utility Scripts
Several scripts assist with various automation tasks, ranging from quick-starting local environments to processing web content. Here are a few important ones:
Quickstart Script
The scripts/quickstart.sh
script is designed to initiate multiple instances of Prometheus with sidecars for testing purposes. This is particularly useful for integration testing and local development.
Snippet from scripts/quickstart.sh
:
for i in $(seq 0 2); do
PROMETHEUS_URL="http://localhost:909${i}"
${THANOS_EXECUTABLE} sidecar \
--prometheus.url "${PROMETHEUS_URL}" \
--tsdb.path data/prom"${i}" &
sleep 0.25
done
Website Processing Scripts
The scripts/website/
directory contains important scripts for preprocessing documentation and releasing content to the project’s website.
websitepreprocess.sh
: This script prepares the documentation content for deployment.mdoxpostprocess.sh
: This script handles post-processing of documentation files.
Snippet from scripts/website/websitepreprocess.sh
:
# Support gtar and ggrep on OSX (installed via brew)
TAR=$(which gtar 2>/dev/null || which tar)
GREP=$(which ggrep 2>/dev/null || which grep)
export OUTPUT_CONTENT_DIR="${WEBSITE_DIR}/docs-pre-processed"
git remote add upstream https://github.com/thanos-io/thanos.git
Running Tests and Constraints
When running tests for the thanos
project, specific build constraints are in place to filter which tests are executed. The constraints defined in test files as !linux
and !stringlabels
control test execution in various environments.
Example command for running tests:
go test ./... -tags '!linux,!stringlabels'
Future Directions
Currently, CI/CD automation in this project is active and ongoing. Developers are encouraged to review the existing scripts and CircleCI configuration for enhancements. Future advancements could involve:
- Increased automation of release processes.
- Integration with other CI/CD systems (e.g., GitHub Actions).
- Further test optimizations using integration testing.
This documentation serves as a foundational reference for existing and future CI/CD processes within the thanos-io/thanos
project. For further development of these scripts, contribution to the respective areas based on the outlined instructions is welcomed.