CI/CD Automation Scripts
For the open-telemetry/opentelemetry-dotnet
project, there are scripts and workflows set up within the GitHub Actions framework to automate the Continuous Integration and Continuous Deployment (CI/CD) process. The existing workflows cover various aspects of the development lifecycle, from building and testing to releasing and publishing packages.
Key Workflows
Component.BuildTest.yml
This workflow is crucial for building the project and running tests to ensure code quality. It is typically triggered on pull requests and commits to the main branch.
Example:
name: Build and Test on: push: branches: - main pull_request: branches: - main jobs: build: runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v2 - name: Setup DotNet uses: actions/setup-dotnet@v1 with: dotnet-version: '8.0.x' - name: Build Project run: dotnet build --configuration Release - name: Run Tests run: dotnet test --no-build --verbosity normal
ci.yml
This workflow is fundamental for CI, focusing on code quality checks, building the project, and running unit tests.
Example:
name: CI on: push: branches: - main pull_request: branches: - main jobs: validate: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Setup DotNet uses: actions/setup-dotnet@v1 with: dotnet-version: '8.0.x' - name: Restore Dependencies run: dotnet restore - name: Build run: dotnet build --configuration Release - name: Run Tests run: dotnet test --no-build --verbosity normal
publish-packages-1.0.yml
This workflow handles the publishing of the NuGet packages to the NuGet feed based on the version tags applied to commits.
Example:
name: Publish Packages on: push: tags: - 'v*' jobs: publish: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Setup DotNet uses: actions/setup-dotnet@v1 with: dotnet-version: '8.0.x' - name: Publish Package run: dotnet pack src/OpenTelemetry/OpenTelemetry.csproj --configuration Release -o ./nuget - name: Push to NuGet run: dotnet nuget push ./nuget/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
Supporting Scripts
In addition to the GitHub Actions workflows, supplementary PowerShell and Python scripts exist to streamline various tasks:
PowerShell Scripts
build/scripts/test-threadSafety.ps1
: This script is designed to test thread safety in the system.build/scripts/sanitycheck.py
: Ensures that the code passes a set of predefined sanity checks.
Example:
# test-threadSafety.ps1 .\build\scripts\sanitycheck.py
Dockerfile and Docker Compose The presence of a
Dockerfile
anddocker-compose.yml
facilitates the building of container images for the application, ensuring consistent environments for development and testing.Example Dockerfile:
ARG SDK_VERSION=8.0 FROM mcr.microsoft.com/dotnet/sdk:${SDK_VERSION} AS build WORKDIR /app COPY . ./ RUN dotnet publish ./examples/MicroserviceExample/WorkerService -c Release -o /out
Example Docker Compose:
version: '3.8' services: webapi: build: context: ../.. dockerfile: ./examples/MicroserviceExample/WebApi/Dockerfile ports: - 5000:5000
These workflows and scripts enable a well-organized automated process that confirms all changes are built, tested, and, when ready, deployed efficiently.
To fully utilize and customize these automation scripts and workflows, users are encouraged to review the contents of the .github/workflows/
directory and build/scripts/
directory in the repository.
For further reading on CI/CD best practices and implementation details, refer to the relevant GitHub documentation and other CI/CD resources.
Source: Directory listing provided