CI/CD Automation Scripts
This section provides an overview of the CI/CD automation scripts present within the open-telemetry/opentelemetry-demo
project. Key components, such as GitHub Action workflows and their configurations, will be outlined to articulate the automated processes associated with building, testing, and deploying the project.
GitHub Workflows
The project leverages GitHub Actions for CI/CD automation. The workflows are defined in the .github/workflows/
directory. Below are the notable workflows:
build-images.yml: This workflow is responsible for building Docker images for various services in the repository.
name: Build Docker Images on: push: branches: - main jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Build Docker images run: | docker build -t myservice:latest ./src/myservice
run-integration-tests.yml: This workflow executes integration tests after the code is pushed to the repository.
name: Run Integration Tests on: push: branches: - main jobs: test: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Run Tests run: | docker-compose -f docker-compose.yml up -d docker exec myservice_container npm test
release.yml: This workflow handles the release process whenever a new version is tagged in the GitHub repository.
name: Release on: release: types: [created] jobs: release: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Build Docker images run: | docker build -t myservice:${{ github.event.release.tag }} ./src/myservice - name: Push Docker images run: | docker push myservice:${{ github.event.release.tag }}
stale.yml: This workflow helps to manage stale issues and pull requests in the repository.
name: Manage Stale issues and PRs on: schedule: - cron: '0 0 * * *' jobs: stale: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Stale PRs Cleanup uses: actions/stale@v5 with: days: 30 period: 86400 staleLabel: 'stale' deleteLabel: 'delete'
Makefile
A Makefile
is also included to provide simplified commands for building the project and its components.
.PHONY: all build clean
all: build
build:
docker-compose build
clean:
docker-compose down
Code and Script Examples
The Dockerfile for the
frauddetectionservice
is used to create a Docker image that utilizes Gradle for building the service and incorporates the OpenTelemetry Java instrumentation agent.FROM --platform=${BUILDPLATFORM} gradle:8-jdk17 AS builder WORKDIR /usr/src/app/ COPY ./src/frauddetectionservice/ ./ COPY ./pb/ ./src/main/proto/ RUN gradle shadowJar FROM gcr.io/distroless/java17-debian11 ARG OTEL_JAVA_AGENT_VERSION WORKDIR /usr/src/app/ COPY --from=builder /usr/src/app/build/libs/frauddetectionservice-1.0-all.jar ./ ADD --chmod=644 https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$OTEL_JAVA_AGENT_VERSION/opentelemetry-javaagent.jar /app/opentelemetry-javaagent.jar ENV JAVA_TOOL_OPTIONS=-javaagent:/app/opentelemetry-javaagent.jar ENTRYPOINT [ "java", "-jar", "frauddetectionservice-1.0-all.jar" ]
A referenced Golang module aspect within the project can be highlighted by the module located in
src/checkoutservice
, which impacts the build output.module github.com/open-telemetry/opentelemetry-demo/src/checkoutservice go 1.17
If CI/CD has not been setup yet, next steps should include defining workflows in the .github/workflows
directory and establishing build scripts relevant to your services, ensuring seamless integration and deployment processes.