Skip to content

Detect CI/CD platform from config files #5

@mvoutov

Description

@mvoutov

What

Add CI/CD platform detection to the scanner. When a repo uses GitHub Actions, GitLab CI, CircleCI, etc., report it in the scan results.

Why

Knowing the CI/CD platform helps Claude understand the deployment pipeline and write better skills (e.g., "tests run via GitHub Actions on PR" or "deploy triggered by GitLab CI merge to main").

How

Edit src/lib/scanner.js. Add a detectCICD(repoPath) function that checks for these files:

Platform Detection Signal
GitHub Actions .github/workflows/*.yml or .github/workflows/*.yaml (use readdirSync)
GitLab CI .gitlab-ci.yml at repo root
CircleCI .circleci/config.yml
Jenkins Jenkinsfile at repo root
Travis CI .travis.yml at repo root
Azure Pipelines azure-pipelines.yml at repo root
Bitbucket Pipelines bitbucket-pipelines.yml at repo root
Buildkite .buildkite/pipeline.yml

All checks are just existsSync() calls — no file content reading needed (except GitHub Actions which needs a readdirSync on the workflows directory).

Implementation steps

  1. Add detectCICD(repoPath) to src/lib/scanner.js:

    function detectCICD(repoPath) {
      const detected = [];
      // GitHub Actions — check if .github/workflows/ has any .yml/.yaml files
      const workflowsDir = join(repoPath, '.github', 'workflows');
      if (existsSync(workflowsDir)) {
        try {
          const files = readdirSync(workflowsDir);
          if (files.some(f => f.endsWith('.yml') || f.endsWith('.yaml'))) {
            detected.push('github-actions');
          }
        } catch {}
      }
      // GitLab CI
      if (existsSync(join(repoPath, '.gitlab-ci.yml'))) detected.push('gitlab-ci');
      // ... etc for each platform
      return detected;
    }
  2. Call it from scanRepo() and add to the result object:

    result.cicd = detectCICD(repoPath);
  3. Display in src/commands/scan.js — add after the Frameworks line:

    if (result.cicd && result.cicd.length > 0) {
      console.log(pc.cyan('  CI/CD: ') + result.cicd.join(', '));
    }
  4. Add tests in tests/scanner.test.js:

    describe('CI/CD detection', () => {
      it('detects GitHub Actions', () => {
        const dir = createFixture('cicd-gha', {
          '.github/workflows/ci.yml': 'name: CI',
        });
        const scan = scanRepo(dir);
        expect(scan.cicd).toContain('github-actions');
      });
    
      it('detects GitLab CI', () => {
        const dir = createFixture('cicd-gitlab', {
          '.gitlab-ci.yml': 'stages: [test]',
        });
        const scan = scanRepo(dir);
        expect(scan.cicd).toContain('gitlab-ci');
      });
    
      it('returns empty for no CI/CD', () => {
        const dir = createFixture('cicd-none', {
          'package.json': '{}',
        });
        const scan = scanRepo(dir);
        expect(scan.cicd).toEqual([]);
      });
    });

Files to change

  • src/lib/scanner.js — add detectCICD(), call from scanRepo()
  • src/commands/scan.js — display CI/CD in output
  • tests/scanner.test.js — add tests

Acceptance criteria

  • npm test passes
  • aspens scan on a repo with .github/workflows/ shows CI/CD: github-actions
  • At least 3 platforms tested (GitHub Actions, GitLab CI, and one other)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions