mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Swift: Emit a diagnostic when attempting to use the autobuilder on Linux.
This commit is contained in:
@@ -57,6 +57,12 @@ pkg_runfiles(
|
||||
prefix = "tools/" + codeql_platform,
|
||||
)
|
||||
|
||||
pkg_runfiles(
|
||||
name = "incompatible-os",
|
||||
srcs = ["//swift/tools/autobuilder-diagnostics:incompatible-os"],
|
||||
prefix = "tools/" + codeql_platform,
|
||||
)
|
||||
|
||||
pkg_files(
|
||||
name = "swift-test-sdk-arch",
|
||||
srcs = ["//swift/third_party/swift-llvm-support:swift-test-sdk"],
|
||||
@@ -70,7 +76,9 @@ pkg_filegroup(
|
||||
":extractor",
|
||||
":swift-test-sdk-arch",
|
||||
] + select({
|
||||
"@platforms//os:linux": [],
|
||||
"@platforms//os:linux": [
|
||||
":incompatible-os",
|
||||
],
|
||||
"@platforms//os:macos": [
|
||||
":xcode-autobuilder",
|
||||
],
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"helpLinks": [
|
||||
"https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on",
|
||||
"https://docs.github.com/en/enterprise-server/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning",
|
||||
"https://docs.github.com/en/enterprise-server/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language"
|
||||
],
|
||||
"plaintextMessage": "CodeQL Swift analysis is currently only officially supported on macOS.\n\nChange the action runner to a macOS one. Analysis on Linux might work, but requires setting up a custom build command.",
|
||||
"severity": "error",
|
||||
"source": {
|
||||
"extractorName": "swift",
|
||||
"id": "swift/autobuilder/incompatible-os",
|
||||
"name": "Incompatible operating system for autobuild (expected macOS)"
|
||||
},
|
||||
"visibility": {
|
||||
"cliSummaryTable": true,
|
||||
"statusPage": true,
|
||||
"telemetry": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
run_codeql_database_create([], lang='swift', keep_trap=True, db=None, runFunction=runUnsuccessfully)
|
||||
check_diagnostics()
|
||||
@@ -3,6 +3,5 @@
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
exec "${CODEQL_EXTRACTOR_SWIFT_ROOT}/tools/${CODEQL_PLATFORM}/xcode-autobuilder"
|
||||
else
|
||||
echo "Not implemented yet"
|
||||
exit 1
|
||||
exec "${CODEQL_EXTRACTOR_SWIFT_ROOT}/tools/${CODEQL_PLATFORM}/incompatible-os"
|
||||
fi
|
||||
|
||||
17
swift/tools/autobuilder-diagnostics/BUILD.bazel
Normal file
17
swift/tools/autobuilder-diagnostics/BUILD.bazel
Normal file
@@ -0,0 +1,17 @@
|
||||
load("//swift:rules.bzl", "swift_cc_binary")
|
||||
load("//misc/bazel/cmake:cmake.bzl", "generate_cmake")
|
||||
|
||||
swift_cc_binary(
|
||||
name = "incompatible-os",
|
||||
srcs = ["IncompatibleOs.cpp"],
|
||||
visibility = ["//swift:__subpackages__"],
|
||||
deps = [
|
||||
"//swift/logging",
|
||||
],
|
||||
)
|
||||
|
||||
generate_cmake(
|
||||
name = "cmake",
|
||||
targets = [":incompatible-os"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
35
swift/tools/autobuilder-diagnostics/IncompatibleOs.cpp
Normal file
35
swift/tools/autobuilder-diagnostics/IncompatibleOs.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
// Unconditionally emits a diagnostic about running the autobuilder on an incompatible, non-macOS OS
|
||||
// and exits with an error code.
|
||||
//
|
||||
// This is implemented as a C++ binary instead of a hardcoded JSON file so we can leverage existing
|
||||
// diagnostic machinery for emitting correct timestamps, generating correct file names, etc.
|
||||
|
||||
#include "swift/logging/SwiftLogging.h"
|
||||
|
||||
const std::string_view codeql::programName = "autobuilder";
|
||||
|
||||
namespace codeql_diagnostics {
|
||||
constexpr codeql::SwiftDiagnosticsSource incompatible_os{
|
||||
"incompatible_os", "Incompatible operating system for autobuild (expected macOS)",
|
||||
"Change the action runner to a macOS one. Analysis on Linux might work, but requires setting "
|
||||
"up a custom build command",
|
||||
"https://docs.github.com/en/actions/using-workflows/"
|
||||
"workflow-syntax-for-github-actions#jobsjob_idruns-on "
|
||||
"https://docs.github.com/en/enterprise-server/code-security/code-scanning/"
|
||||
"automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning "
|
||||
"https://docs.github.com/en/enterprise-server/code-security/code-scanning/"
|
||||
"automatically-scanning-your-code-for-vulnerabilities-and-errors/"
|
||||
"configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-"
|
||||
"language"};
|
||||
} // namespace codeql_diagnostics
|
||||
|
||||
static codeql::Logger& logger() {
|
||||
static codeql::Logger ret{"main"};
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main() {
|
||||
DIAGNOSE_ERROR(incompatible_os,
|
||||
"CodeQL Swift analysis is currently only officially supported on macOS");
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user