CI/CD Integration

Automated Compliance Testing

Integrate Tork SDK verification into your CI/CD pipelines to ensure continuous compliance and catch issues before they reach production.

Why CI/CD Integration?

Prevent Regressions

Catch compliance issues in pull requests before they merge to main.

Continuous Monitoring

Run daily verification checks to maintain compliance over time.

Fast Feedback

Get immediate feedback on your verification score with every commit.

Quick Setup

  1. 1

    Add your API key as a secret

    Store TORK_API_KEY in your CI/CD platform's secret management.

  2. 2

    Copy the configuration for your platform

    Use one of the examples below for GitHub Actions, GitLab CI, Jenkins, or others.

  3. 3

    Customize thresholds and notifications

    Set your minimum score threshold and configure notifications for failures.

GitHub Actions

The most comprehensive integration with PR comments and artifacts.

# .github/workflows/tork-verify.yml
name: Tork SDK Verification

on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main]
  schedule:
    - cron: '0 0 * * *' # Daily at midnight

jobs:
  verify:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - name: Install dependencies
        run: |
          pip install tork-sdk pytest

      - name: Run Tork Verification
        env:
          TORK_API_KEY: ${{ secrets.TORK_API_KEY }}
        run: |
          python -c "
          from tork import Tork
          import json
          import sys

          client = Tork()
          result = client.verify_integration()

          print(f'Score: {result.score}/100')
          print(f'Grade: {result.grade}')
          print(f'Status: {result.status}')

          # Save results for artifacts
          with open('verification-result.json', 'w') as f:
              json.dump(result.to_dict(), f, indent=2)

          # Fail if score below threshold
          if result.score < 80:
              print('::error::Verification score below threshold')
              sys.exit(1)
          "

      - name: Upload Results
        uses: actions/upload-artifact@v4
        with:
          name: tork-verification
          path: verification-result.json

      - name: Comment on PR
        if: github.event_name == 'pull_request'
        uses: actions/github-script@v7
        with:
          script: |
            const fs = require('fs');
            const result = JSON.parse(fs.readFileSync('verification-result.json'));
            const emoji = result.status === 'pass' ? '✅' : result.status === 'partial' ? '⚠️' : '❌';

            github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: `## ${emoji} Tork Verification Results

| Metric | Value |
|--------|-------|
| Score | **${result.score}/100** |
| Grade | **${result.grade}** |
| Status | ${result.status} |
| Certificate | [View](${result.certificate_url}) |

[View Full Report](https://tork.ai/verify/${result.verification_id})
`
            });

GitLab CI

Native GitLab CI/CD integration with artifacts and merge request rules.

# .gitlab-ci.yml
stages:
  - test
  - verify

tork-verification:
  stage: verify
  image: python:3.11
  variables:
    TORK_API_KEY: $TORK_API_KEY
  script:
    - pip install tork-sdk
    - |
      python << 'EOF'
      from tork import Tork
      import json
      import sys

      client = Tork()
      result = client.verify_integration()

      print(f"Score: {result.score}/100")
      print(f"Grade: {result.grade}")

      with open("verification.json", "w") as f:
          json.dump(result.to_dict(), f)

      if result.score < 80:
          sys.exit(1)
      EOF
  artifacts:
    paths:
      - verification.json
    reports:
      dotenv: tork-results.env
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

Jenkins

Declarative pipeline with email notifications on failure.

// Jenkinsfile
pipeline {
    agent any

    environment {
        TORK_API_KEY = credentials('tork-api-key')
    }

    stages {
        stage('Verify Tork Integration') {
            steps {
                sh '''
                    pip install tork-sdk
                    python -c "
from tork import Tork
import json

client = Tork()
result = client.verify_integration()

print(f'Score: {result.score}/100')
print(f'Grade: {result.grade}')

with open('verification.json', 'w') as f:
    json.dump(result.to_dict(), f)

exit(0 if result.score >= 80 else 1)
"
                '''
            }
            post {
                always {
                    archiveArtifacts artifacts: 'verification.json'
                }
                failure {
                    emailext(
                        subject: 'Tork Verification Failed',
                        body: 'Score dropped below threshold. Check Jenkins for details.',
                        to: '${DEFAULT_RECIPIENTS}'
                    )
                }
            }
        }
    }
}

CircleCI

CircleCI workflow with context-based credentials.

# .circleci/config.yml
version: 2.1

orbs:
  python: circleci/python@2.1

jobs:
  tork-verify:
    executor: python/default
    steps:
      - checkout
      - run:
          name: Install Tork SDK
          command: pip install tork-sdk
      - run:
          name: Run Verification
          command: |
            python << 'EOF'
            from tork import Tork
            import json
            import os

            client = Tork(api_key=os.environ['TORK_API_KEY'])
            result = client.verify_integration()

            print(f"Score: {result.score}/100")
            print(f"Grade: {result.grade}")

            with open("verification.json", "w") as f:
                json.dump(result.to_dict(), f)

            if result.score < 80:
                exit(1)
            EOF
      - store_artifacts:
          path: verification.json
          destination: tork-verification

workflows:
  verify:
    jobs:
      - tork-verify:
          context: tork-credentials

Bitbucket Pipelines

Bitbucket Pipelines with PR-specific verification.

# bitbucket-pipelines.yml
image: python:3.11

pipelines:
  default:
    - step:
        name: Tork Verification
        script:
          - pip install tork-sdk
          - |
            python -c "
            from tork import Tork
            import json
            import os

            client = Tork(api_key=os.environ['TORK_API_KEY'])
            result = client.verify_integration()

            print(f'Score: {result.score}/100')
            print(f'Grade: {result.grade}')

            with open('verification.json', 'w') as f:
                json.dump(result.to_dict(), f)

            exit(0 if result.score >= 80 else 1)
            "
        artifacts:
          - verification.json

  pull-requests:
    '**':
      - step:
          name: Verify on PR
          script:
            - pip install tork-sdk
            - python -m tork.verify --min-score 80

Best Practices

Set appropriate thresholds

Start with a threshold of 80 and increase as your integration matures. Use different thresholds for PRs vs. main branch.

Run on schedule, not just on push

Schedule daily runs to catch issues with external dependencies or API changes that might affect your score.

Save verification artifacts

Always save the full verification result as an artifact for debugging and compliance audits.

Don't fail silently

Configure notifications for verification failures. Use Slack, email, or your team's preferred channel.

CLI Reference

Command Line Options

python -m tork.verify

Run verification with default settings

python -m tork.verify --min-score 90

Exit with error if score below 90

python -m tork.verify --output json

Output results as JSON

python -m tork.verify --save verification.json

Save results to file

Need Help?

Our team is here to help you set up CI/CD integration. Reach out if you need assistance with custom configurations or enterprise deployments.