Skip to content

Commit

Permalink
Support Swift for private beta (#1350)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Mercer <[email protected]>
  • Loading branch information
angelapwen and henrymercer authored Nov 14, 2022
1 parent af487b1 commit 0eacdb5
Show file tree
Hide file tree
Showing 21 changed files with 664 additions and 5 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/__ruby-autodetect.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions .github/workflows/__swift-autobuild.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions .github/workflows/__swift-custom-build.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion lib/codeql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/count-loc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/count-loc.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions pr-checks/checks/ruby-autodetect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This check should be combined into `multi-language-autodetect.yml` once Ruby is GA'ed
# and the `CODEQL_ENABLE_EXPERIMENTAL_FEATURES` environment variable is not needed.
name: "Ruby analysis using autodetect"
description: "Tests creation of a Ruby database when language isn't specified in init"
versions: ["latest", "cached", "nightly-latest"]
operatingSystems: ["ubuntu", "macos"]
env:
CODEQL_ENABLE_EXPERIMENTAL_FEATURES: "true"
steps:
- uses: ./../action/init
with:
tools: ${{ steps.prepare-test.outputs.tools-url }}
env:
TEST_MODE: true
- uses: ./../action/analyze
id: analysis
env:
TEST_MODE: true
- name: Check database
shell: bash
run: |
RUBY_DB="${{ fromJson(steps.analysis.outputs.db-locations).ruby }}"
if [[ ! -d "$RUBY_DB" ]]; then
echo "Did not create a database for Ruby."
exit 1
fi
File renamed without changes.
27 changes: 27 additions & 0 deletions pr-checks/checks/swift-autobuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Swift analysis using autobuild"
description: "Tests creation of a Swift database using autobuild"
versions: ["latest", "cached", "nightly-latest"]
# Swift autobuilder is only supported on MacOS for private beta
operatingSystems: ["macos"]
env:
CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT: "true"
steps:
- uses: ./../action/init
with:
languages: swift
tools: ${{ steps.prepare-test.outputs.tools-url }}
env:
TEST_MODE: true
- uses: ./../action/autobuild
- uses: ./../action/analyze
id: analysis
env:
TEST_MODE: true
- name: Check database
shell: bash
run: |
SWIFT_DB="${{ fromJson(steps.analysis.outputs.db-locations).swift }}"
if [[ ! -d "$SWIFT_DB" ]]; then
echo "Did not create a database for Swift."
exit 1
fi
29 changes: 29 additions & 0 deletions pr-checks/checks/swift-custom-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Swift analysis using a custom build command"
description: "Tests creation of a Swift database using custom build"
versions: ["latest", "cached", "nightly-latest"]
operatingSystems: ["ubuntu", "macos"]
env:
CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT: "true"
DOTNET_GENERATE_ASPNET_CERTIFICATE: "false"
steps:
- uses: ./../action/init
with:
languages: swift
tools: ${{ steps.prepare-test.outputs.tools-url }}
env:
TEST_MODE: true
- name: Build code
shell: bash
run: ./build.sh
- uses: ./../action/analyze
id: analysis
env:
TEST_MODE: true
- name: Check database
shell: bash
run: |
SWIFT_DB="${{ fromJson(steps.analysis.outputs.db-locations).swift }}"
if [[ ! -d "$SWIFT_DB" ]]; then
echo "Did not create a database for Swift."
exit 1
fi
6 changes: 6 additions & 0 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export interface QueriesStatusReport {
analyze_builtin_queries_python_duration_ms?: number;
/** Time taken in ms to run builtin queries for ruby (or undefined if this language was not analyzed). */
analyze_builtin_queries_ruby_duration_ms?: number;
/** Time taken in ms to run builtin queries for swift (or undefined if this language was not analyzed). */
analyze_builtin_queries_swift_duration_ms?: number;
/** Time taken in ms to run custom queries for cpp (or undefined if this language was not analyzed). */
analyze_custom_queries_cpp_duration_ms?: number;
/** Time taken in ms to run custom queries for csharp (or undefined if this language was not analyzed). */
Expand All @@ -63,6 +65,8 @@ export interface QueriesStatusReport {
analyze_custom_queries_python_duration_ms?: number;
/** Time taken in ms to run custom queries for ruby (or undefined if this language was not analyzed). */
analyze_custom_queries_ruby_duration_ms?: number;
/** Time taken in ms to run custom queries for swift (or undefined if this language was not analyzed). */
analyze_custom_queries_swift_duration_ms?: number;
/** Time taken in ms to interpret results for cpp (or undefined if this language was not analyzed). */
interpret_results_cpp_duration_ms?: number;
/** Time taken in ms to interpret results for csharp (or undefined if this language was not analyzed). */
Expand All @@ -77,6 +81,8 @@ export interface QueriesStatusReport {
interpret_results_python_duration_ms?: number;
/** Time taken in ms to interpret results for ruby (or undefined if this language was not analyzed). */
interpret_results_ruby_duration_ms?: number;
/** Time taken in ms to interpret results for swift (or undefined if this language was not analyzed). */
interpret_results_swift_duration_ms?: number;
/** Name of language that errored during analysis (or undefined if no language failed). */
analyze_failure_language?: string;
}
Expand Down
4 changes: 4 additions & 0 deletions src/codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,12 @@ async function getCodeQLForCmd(
async runAutobuild(language: Language) {
const cmdName =
process.platform === "win32" ? "autobuild.cmd" : "autobuild.sh";
// The autobuilder for Swift is located in the experimental/ directory.
const possibleExperimentalDir =
language === Language.swift ? "experimental" : "";
const autobuildCmd = path.join(
path.dirname(cmd),
possibleExperimentalDir,
language,
"tools",
cmdName
Expand Down
1 change: 1 addition & 0 deletions src/count-loc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const linguistToMetrics: Record<string, Language> = {
javascript: Language.javascript,
python: Language.python,
ruby: Language.ruby,
swift: Language.swift,
typescript: Language.javascript,
};

Expand Down
Loading

0 comments on commit 0eacdb5

Please sign in to comment.