Skip to content

Commit

Permalink
ci: added codql analysis job (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
soumyamahunt authored Dec 4, 2023
1 parent c9468e9 commit 12784b2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 48 deletions.
54 changes: 26 additions & 28 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,30 @@ concurrency:
cancel-in-progress: true

jobs:
# analyze:
# name: Analyze
# if: github.event_name != 'workflow_dispatch'
# uses: SwiftyLab/ci/.github/workflows/analyze.yml@main
# permissions:
# actions: read
# contents: read
# security-events: write
# with:
# matrix: >
# {
# "include": [
# {
# "os": "ubuntu-latest",
# "language": "swift",
# "swift": "latest"
# },
# {
# "os": "macos-13",
# "language": "swift",
# "xcode": "15"
# }
# ]
# }
analyze:
name: Analyze
if: github.event_name != 'workflow_dispatch'
uses: SwiftyLab/ci/.github/workflows/analyze.yml@main
permissions:
actions: read
contents: read
security-events: write
with:
matrix: >
{
"include": [
{
"os": "ubuntu-latest",
"language": "swift",
"swift": "latest"
},
{
"os": "macos-13",
"language": "swift",
"xcode": "latest"
}
]
}
spell-check:
name: Run spell check
Expand Down Expand Up @@ -81,8 +81,7 @@ jobs:
ci:
name: CI
if: github.event_name == 'push'
needs: [swift-package-test, spell-check]
# needs: [analyze, swift-package-test]
needs: [analyze, spell-check, swift-package-test]
uses: SwiftyLab/ci/.github/workflows/ci.yml@main

cd:
Expand All @@ -93,8 +92,7 @@ jobs:
github.event.inputs.release == 'true' &&
(needs.ci.result == 'success' || needs.ci.result == 'skipped') &&
(needs.swift-package-test.result == 'success' || needs.swift-package-test.result == 'skipped')
needs: [swift-package-test, spell-check, ci]
# needs: [analyze, swift-package-test, ci]
needs: [analyze, spell-check, swift-package-test, ci]
uses: SwiftyLab/ci/.github/workflows/cd.yml@main
with:
version: ${{ github.event.inputs.version }}
Expand Down
44 changes: 24 additions & 20 deletions Tests/MetaCodableTests/CodableTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#if SWIFT_SYNTAX_EXTENSION_MACRO_FIXED
import SwiftDiagnostics
import SwiftSyntax
import SwiftSyntaxMacros
import SwiftSyntaxMacroExpansion
import SwiftSyntaxMacrosTestSupport
import XCTest

Expand Down Expand Up @@ -146,7 +148,7 @@ final class CodableTests: XCTestCase {
}
}
""",
conformsTo: ["Codable": ["Decodable"]]
conformsTo: ["Decodable"]
)
}

Expand Down Expand Up @@ -185,7 +187,7 @@ final class CodableTests: XCTestCase {
}
}
""",
conformsTo: ["Codable": ["Encodable"]]
conformsTo: ["Encodable"]
)
}

Expand Down Expand Up @@ -217,7 +219,7 @@ final class CodableTests: XCTestCase {
}
}
""",
conformsTo: ["Codable": []]
conformsTo: []
)
}
}
Expand All @@ -226,32 +228,34 @@ func assertMacroExpansion(
_ originalSource: String,
expandedSource: String,
diagnostics: [DiagnosticSpec] = [],
conformsTo conformanceMap: [String: [TypeSyntax]] = [
"Codable": ["Decodable", "Encodable"]
],
conformsTo conformances: [TypeSyntax] = ["Decodable", "Encodable"],
testModuleName: String = "TestModule",
testFileName: String = "test.swift",
indentationWidth: Trivia = .spaces(4),
file: StaticString = #file,
line: UInt = #line
) {
let macros: [String: Macro.Type] = [
"CodedAt": CodedAt.self,
"CodedIn": CodedIn.self,
"Default": Default.self,
"CodedBy": CodedBy.self,
"IgnoreCoding": IgnoreCoding.self,
"IgnoreDecoding": IgnoreDecoding.self,
"IgnoreEncoding": IgnoreEncoding.self,
"Codable": Codable.self,
"MemberInit": MemberInit.self,
"CodingKeys": CodingKeys.self,
"IgnoreCodingInitialized": IgnoreCodingInitialized.self,
]
assertMacroExpansion(
originalSource, expandedSource: expandedSource,
diagnostics: diagnostics,
macros: [
"CodedAt": CodedAt.self,
"CodedIn": CodedIn.self,
"Default": Default.self,
"CodedBy": CodedBy.self,
"IgnoreCoding": IgnoreCoding.self,
"IgnoreDecoding": IgnoreDecoding.self,
"IgnoreEncoding": IgnoreEncoding.self,
"Codable": Codable.self,
"MemberInit": MemberInit.self,
"CodingKeys": CodingKeys.self,
"IgnoreCodingInitialized": IgnoreCodingInitialized.self,
],
conformsTo: conformanceMap,
macroSpecs: Dictionary(
uniqueKeysWithValues: macros.map { key, value in
(key, MacroSpec(type: value, conformances: conformances))
}
),
testModuleName: testModuleName, testFileName: testFileName,
indentationWidth: indentationWidth,
file: file, line: line
Expand Down

0 comments on commit 12784b2

Please sign in to comment.