Skip to content
Parse Clang Static Analyzer messages and pass them to Slack
Swift
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Callisto.xcodeproj
Callisto change analyzer count from error to warning Apr 5, 2018
CallistoTest remove staticAnalyzerMessages.count from exit number Apr 5, 2018
Documentation update README Jun 9, 2017
.gitignore do not crash if GitHub is temporarily unavailable Jan 12, 2018
.swiftlint.yml add swiftlint yml Apr 4, 2018
LICENSE Initial commit Jun 1, 2017
README.md Improve code sample Jun 28, 2017

README.md

Callisto

Twitter: @PatrickKladek License alt text

Logo

Clang Static Analyzer is great, it catches lots of potential bugs and errors in your code. It has one downside though: running the Clang Static Analyzer every time you build your project takes a lot of time, and we all could use some shorter build times. Callisto solves this problem, as it allows you to run the Clang Static Analyzer on your build server (e.g. BuildKite) and posts the results to our favorite messaging tool Slack.

#!/bin/bash

fastlane ios static_analyze 2>&1 | tee /tmp/fastlane_iOS_Output.txt
Callisto -fastlane "/tmp/fastlane_iOS_Output.txt" \
-slack "<SLACK_WEBHOOK_URL>" \
-branch "$BUILDKITE_BRANCH" \
-githubUsername "<GITHUB_USERNAME>" \
-githubToken "<GITHUB_TOKEN>" \
-githubOrganisation "<GITHUB_ORGANISATION>" \
-githubRepository "<GITHUB_REPOSITORY>" \
-ignore "todo, -Wpragma"

fastlane static_analyze lane:

The important thing here is xcargs: "analyze". If you don't want to run the static analyzer and only post build errors & warnings to slack just remove the "analyze" from xcargs.

platform :ios do
  desc "Build and run the static Analyzer"
  lane :staticAnalyze do
    scan(
      devices: [
        "iPhone 6s"
      ],
      clean: true,
      workspace: "MyWorkspace.xcworkspace",
      scheme: "MyProject for iOS",
      xcargs: "analyze"
    )
  end
end

Parameters

  • -slack: create a Slack Webhook URL and pass it as a parameter to Callisto, to enable posting to Slack
  • -branch: when using BuildKite you can simply pass the environment variable "$BUILDKITE_BRANCH"
  • -githubUsername: The username of a GitHub account that has access to your repository
  • -githubToken: The recommended way to safely connect to GitHub: create a token for your user
  • -githubOrganisation: needed to create the correct URL for communicating with GitHub
  • -githubRepository: needed to create the correct URL for communicating with GitHub
  • -ignore: pass keywords which should be excluded from your Slack report, e.g. you can exclude "todo"

How does it work?

Callisto simply parses the output from fastlane, which mostly pipes through the Clang Static Analyzer messages from the compiler. By filtering these messages and reformatting them Callisto is able to post only the relevant information to Slack. In addition to that, if you enable GitHub-Checks you can also block Pull Request from being merged, if Callisto finds an issue in your code.

Callisto is brought to you by IdeasOnCanvas, the creator of MindNode for iOS, macOS & watchOS.

You can’t perform that action at this time.