diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c6b8c77..87b6c45 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,17 +14,21 @@ jobs: steps: - uses: actions/checkout@v4 - run: | - g++ -Wall -Wextra -o test source.cpp > compilation.log 2>&1 + cmake -S . -B build + echo "#cppwarningnotifier commit=${{ github.sha }}" >> compilation.log + cmake --build build >> compilation.log 2>&1 - uses: actions/upload-artifact@v4 with: name: compilation_log path: compilation.log - - run: ./test + - run: ./build/hello_world run-notifier: needs: - compile runs-on: ubuntu-latest + environment: + name: MyEnvironment steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -38,3 +42,8 @@ jobs: - run: node dist/index.js env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + APP_ID: ${{ vars.APP_ID }} + PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} + INSTALLATION_ID: ${{ vars.INSTALLATION_ID }} + CLIENT_ID: ${{ vars.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET}} diff --git a/.gitignore b/.gitignore index 49fd833..0baf835 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ node_modules dist/* + +build/* diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..3677318 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.28) + +project(HelloWorld) + +set(WARNING_OPTIONS + $<$:/W4 + /WX> + $<$:-Wall + -Wextra + -pedantic> +) + +add_executable(hello_world source.cpp) +target_compile_options(hello_world PRIVATE ${WARNING_OPTIONS}) diff --git a/package-lock.json b/package-lock.json index 8cb90d9..83ecbee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,8 +6,7 @@ "": { "name": "cpp-warning-notifier", "dependencies": { - "@octokit/action": "^7.0.2", - "gcc-output-parser": "^0.0.5" + "octokit": "^4.1.3" }, "devDependencies": { "@octokit/tsconfig": "^4.0.0", @@ -15,31 +14,85 @@ "typescript": "^5.8.3" } }, - "node_modules/@octokit/action": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@octokit/action/-/action-7.0.2.tgz", - "integrity": "sha512-mM/NxCh5oviEhNB7NOwFR9SeGMx32TYR0N4lt+SdNsrQmm+ozKgHXZddQixrDzg0b4tWAsMi85nHLeIs5bM5jg==", + "node_modules/@octokit/app": { + "version": "15.1.6", + "resolved": "https://registry.npmjs.org/@octokit/app/-/app-15.1.6.tgz", + "integrity": "sha512-WELCamoCJo9SN0lf3SWZccf68CF0sBNPQuLYmZ/n87p5qvBJDe9aBtr5dHkh7T9nxWZ608pizwsUbypSzZAiUw==", "license": "MIT", "dependencies": { - "@octokit/auth-action": "^5.1.2", + "@octokit/auth-app": "^7.2.1", + "@octokit/auth-unauthenticated": "^6.1.3", "@octokit/core": "^6.1.5", + "@octokit/oauth-app": "^7.1.6", "@octokit/plugin-paginate-rest": "^12.0.0", - "@octokit/plugin-rest-endpoint-methods": "^14.0.0", "@octokit/types": "^14.0.0", - "undici": "^6.19.8" + "@octokit/webhooks": "^13.6.1" }, "engines": { "node": ">= 18" } }, - "node_modules/@octokit/auth-action": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/@octokit/auth-action/-/auth-action-5.1.2.tgz", - "integrity": "sha512-KgR3hIHz1iHytBrWdsVRN7elYtF6TP2fKIlnpjagT1rGY2WnALckO6aOUjwxGOyrnXd44j/QSKQilCnAswJg3A==", + "node_modules/@octokit/auth-app": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/@octokit/auth-app/-/auth-app-7.2.1.tgz", + "integrity": "sha512-4jaopCVOtWN0V8qCx/1s2pkRqC6tcvIQM3kFB99eIpsP53GfsoIKO08D94b83n/V3iGihHmxWR2lXzE0NicUGg==", "license": "MIT", "dependencies": { - "@octokit/auth-token": "^5.0.0", - "@octokit/types": "^14.0.0" + "@octokit/auth-oauth-app": "^8.1.4", + "@octokit/auth-oauth-user": "^5.1.4", + "@octokit/request": "^9.2.3", + "@octokit/request-error": "^6.1.8", + "@octokit/types": "^14.0.0", + "toad-cache": "^3.7.0", + "universal-github-app-jwt": "^2.2.0", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/auth-oauth-app": { + "version": "8.1.4", + "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-app/-/auth-oauth-app-8.1.4.tgz", + "integrity": "sha512-71iBa5SflSXcclk/OL3lJzdt4iFs56OJdpBGEBl1wULp7C58uiswZLV6TdRaiAzHP1LT8ezpbHlKuxADb+4NkQ==", + "license": "MIT", + "dependencies": { + "@octokit/auth-oauth-device": "^7.1.5", + "@octokit/auth-oauth-user": "^5.1.4", + "@octokit/request": "^9.2.3", + "@octokit/types": "^14.0.0", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/auth-oauth-device": { + "version": "7.1.5", + "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-device/-/auth-oauth-device-7.1.5.tgz", + "integrity": "sha512-lR00+k7+N6xeECj0JuXeULQ2TSBB/zjTAmNF2+vyGPDEFx1dgk1hTDmL13MjbSmzusuAmuJD8Pu39rjp9jH6yw==", + "license": "MIT", + "dependencies": { + "@octokit/oauth-methods": "^5.1.5", + "@octokit/request": "^9.2.3", + "@octokit/types": "^14.0.0", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/auth-oauth-user": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-user/-/auth-oauth-user-5.1.4.tgz", + "integrity": "sha512-4tJRofMHm6ZCd3O2PVgboBbQ/lNtacREeaihet0+wCATZmvPK+jjg2K6NjBfY69An3yzQdmkcMeiaOOoxOPr7Q==", + "license": "MIT", + "dependencies": { + "@octokit/auth-oauth-device": "^7.1.5", + "@octokit/oauth-methods": "^5.1.5", + "@octokit/request": "^9.2.3", + "@octokit/types": "^14.0.0", + "universal-user-agent": "^7.0.0" }, "engines": { "node": ">= 18" @@ -54,6 +107,19 @@ "node": ">= 18" } }, + "node_modules/@octokit/auth-unauthenticated": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/@octokit/auth-unauthenticated/-/auth-unauthenticated-6.1.3.tgz", + "integrity": "sha512-d5gWJla3WdSl1yjbfMpET+hUSFCE15qM0KVSB0H1shyuJihf/RL1KqWoZMIaonHvlNojkL9XtLFp8QeLe+1iwA==", + "license": "MIT", + "dependencies": { + "@octokit/request-error": "^6.1.8", + "@octokit/types": "^14.0.0" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/@octokit/core": { "version": "6.1.5", "resolved": "https://registry.npmjs.org/@octokit/core/-/core-6.1.5.tgz", @@ -99,12 +165,73 @@ "node": ">= 18" } }, + "node_modules/@octokit/oauth-app": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/@octokit/oauth-app/-/oauth-app-7.1.6.tgz", + "integrity": "sha512-OMcMzY2WFARg80oJNFwWbY51TBUfLH4JGTy119cqiDawSFXSIBujxmpXiKbGWQlvfn0CxE6f7/+c6+Kr5hI2YA==", + "license": "MIT", + "dependencies": { + "@octokit/auth-oauth-app": "^8.1.3", + "@octokit/auth-oauth-user": "^5.1.3", + "@octokit/auth-unauthenticated": "^6.1.2", + "@octokit/core": "^6.1.4", + "@octokit/oauth-authorization-url": "^7.1.1", + "@octokit/oauth-methods": "^5.1.4", + "@types/aws-lambda": "^8.10.83", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/oauth-authorization-url": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@octokit/oauth-authorization-url/-/oauth-authorization-url-7.1.1.tgz", + "integrity": "sha512-ooXV8GBSabSWyhLUowlMIVd9l1s2nsOGQdlP2SQ4LnkEsGXzeCvbSbCPdZThXhEFzleGPwbapT0Sb+YhXRyjCA==", + "license": "MIT", + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/oauth-methods": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/@octokit/oauth-methods/-/oauth-methods-5.1.5.tgz", + "integrity": "sha512-Ev7K8bkYrYLhoOSZGVAGsLEscZQyq7XQONCBBAl2JdMg7IT3PQn/y8P0KjloPoYpI5UylqYrLeUcScaYWXwDvw==", + "license": "MIT", + "dependencies": { + "@octokit/oauth-authorization-url": "^7.0.0", + "@octokit/request": "^9.2.3", + "@octokit/request-error": "^6.1.8", + "@octokit/types": "^14.0.0" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/@octokit/openapi-types": { "version": "25.0.0", "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-25.0.0.tgz", "integrity": "sha512-FZvktFu7HfOIJf2BScLKIEYjDsw6RKc7rBJCdvCTfKsVnx2GEB/Nbzjr29DUdb7vQhlzS/j8qDzdditP0OC6aw==", "license": "MIT" }, + "node_modules/@octokit/openapi-webhooks-types": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-webhooks-types/-/openapi-webhooks-types-10.4.0.tgz", + "integrity": "sha512-HMiF7FUiVBYfp8pPijMTkWuPELQB6XkPftrnSuK1C1YXaaq2+0ganiQkorEQfXTmhtwlgHJwXT6P8miVhIyjQA==", + "license": "MIT" + }, + "node_modules/@octokit/plugin-paginate-graphql": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-graphql/-/plugin-paginate-graphql-5.2.4.tgz", + "integrity": "sha512-pLZES1jWaOynXKHOqdnwZ5ULeVR6tVVCMm+AUbp0htdcyXDU95WbkYdU4R2ej1wKj5Tu94Mee2Ne0PjPO9cCyA==", + "license": "MIT", + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, "node_modules/@octokit/plugin-paginate-rest": { "version": "12.0.0", "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-12.0.0.tgz", @@ -135,6 +262,39 @@ "@octokit/core": ">=6" } }, + "node_modules/@octokit/plugin-retry": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-7.2.1.tgz", + "integrity": "sha512-wUc3gv0D6vNHpGxSaR3FlqJpTXGWgqmk607N9L3LvPL4QjaxDgX/1nY2mGpT37Khn+nlIXdljczkRnNdTTV3/A==", + "license": "MIT", + "dependencies": { + "@octokit/request-error": "^6.1.8", + "@octokit/types": "^14.0.0", + "bottleneck": "^2.15.3" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, + "node_modules/@octokit/plugin-throttling": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-throttling/-/plugin-throttling-10.0.0.tgz", + "integrity": "sha512-Kuq5/qs0DVYTHZuBAzCZStCzo2nKvVRo/TDNhCcpC2TKiOGz/DisXMCvjt3/b5kr6SCI1Y8eeeJTHBxxpFvZEg==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^14.0.0", + "bottleneck": "^2.15.3" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": "^6.1.3" + } + }, "node_modules/@octokit/request": { "version": "9.2.3", "resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.2.3.tgz", @@ -179,6 +339,35 @@ "@octokit/openapi-types": "^25.0.0" } }, + "node_modules/@octokit/webhooks": { + "version": "13.8.0", + "resolved": "https://registry.npmjs.org/@octokit/webhooks/-/webhooks-13.8.0.tgz", + "integrity": "sha512-3PCWyFBNbW2+Ox36VAkSqlPoIb96NZiPcICRYySHZrDTM2NuNxvrjPeaQDj2egqILs9EZFObRTHVMe4XxXJV7w==", + "license": "MIT", + "dependencies": { + "@octokit/openapi-webhooks-types": "10.4.0", + "@octokit/request-error": "^6.1.7", + "@octokit/webhooks-methods": "^5.1.1" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/webhooks-methods": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@octokit/webhooks-methods/-/webhooks-methods-5.1.1.tgz", + "integrity": "sha512-NGlEHZDseJTCj8TMMFehzwa9g7On4KJMPVHDSrHxCQumL6uSQR8wIkP/qesv52fXqV1BPf4pTxwtS31ldAt9Xg==", + "license": "MIT", + "engines": { + "node": ">= 18" + } + }, + "node_modules/@types/aws-lambda": { + "version": "8.10.149", + "resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.149.tgz", + "integrity": "sha512-NXSZIhfJjnXqJgtS7IwutqIF/SOy1Wz5Px4gUY1RWITp3AYTyuJS4xaXr/bIJY1v15XMzrJ5soGnPM+7uigZjA==", + "license": "MIT" + }, "node_modules/@types/node": { "version": "22.15.2", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.2.tgz", @@ -195,6 +384,12 @@ "integrity": "sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A==", "license": "Apache-2.0" }, + "node_modules/bottleneck": { + "version": "2.19.5", + "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz", + "integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==", + "license": "MIT" + }, "node_modules/fast-content-type-parse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fast-content-type-parse/-/fast-content-type-parse-2.0.1.tgz", @@ -211,11 +406,35 @@ ], "license": "MIT" }, - "node_modules/gcc-output-parser": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/gcc-output-parser/-/gcc-output-parser-0.0.5.tgz", - "integrity": "sha512-mNxr8otOo19gl61Snn4YkX+zBOwJGjckB+aAJZSVHZdWvTRcdUXBzu+5DWVQA/yFCrJviIeSrxYG+4FcV1tFkw==", - "license": "ISC" + "node_modules/octokit": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/octokit/-/octokit-4.1.3.tgz", + "integrity": "sha512-PP+EL8h4xPCE9NBo6jXq6I2/EiTXsn1cg9F0IZehHBv/qhuQpyGMFElEB17miWKciuT6vRHiFFiG9+FoXOmg6A==", + "license": "MIT", + "dependencies": { + "@octokit/app": "^15.1.6", + "@octokit/core": "^6.1.5", + "@octokit/oauth-app": "^7.1.6", + "@octokit/plugin-paginate-graphql": "^5.2.4", + "@octokit/plugin-paginate-rest": "^12.0.0", + "@octokit/plugin-rest-endpoint-methods": "^14.0.0", + "@octokit/plugin-retry": "^7.2.1", + "@octokit/plugin-throttling": "^10.0.0", + "@octokit/request-error": "^6.1.8", + "@octokit/types": "^14.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/toad-cache": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/toad-cache/-/toad-cache-3.7.0.tgz", + "integrity": "sha512-/m8M+2BJUpoJdgAHoG+baCwBT+tf2VraSfkBgl0Y00qIWt41DJ8R5B8nsEw0I58YwF5IZH6z24/2TobDKnqSWw==", + "license": "MIT", + "engines": { + "node": ">=12" + } }, "node_modules/typescript": { "version": "5.8.3", @@ -231,15 +450,6 @@ "node": ">=14.17" } }, - "node_modules/undici": { - "version": "6.21.2", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.21.2.tgz", - "integrity": "sha512-uROZWze0R0itiAKVPsYhFov9LxrPMHLMEQFszeI2gCN6bnIIZ8twzBCJcN2LJrBBLfrP0t1FW0g+JmKVl8Vk1g==", - "license": "MIT", - "engines": { - "node": ">=18.17" - } - }, "node_modules/undici-types": { "version": "6.21.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", @@ -247,6 +457,12 @@ "dev": true, "license": "MIT" }, + "node_modules/universal-github-app-jwt": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/universal-github-app-jwt/-/universal-github-app-jwt-2.2.2.tgz", + "integrity": "sha512-dcmbeSrOdTnsjGjUfAlqNDJrhxXizjAz94ija9Qw8YkZ1uu0d+GoZzyH+Jb9tIIqvGsadUfwg+22k5aDqqwzbw==", + "license": "MIT" + }, "node_modules/universal-user-agent": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz", diff --git a/package.json b/package.json index f534668..9b21391 100644 --- a/package.json +++ b/package.json @@ -6,12 +6,11 @@ "build": "tsc" }, "dependencies": { - "@octokit/action": "^7.0.2", - "gcc-output-parser": "^0.0.5" + "octokit": "^4.1.3" }, "devDependencies": { "@octokit/tsconfig": "^4.0.0", "@types/node": "^22.15.2", "typescript": "^5.8.3" } -} +} \ No newline at end of file diff --git a/source.cpp b/source.cpp index 12b9916..51a567f 100644 --- a/source.cpp +++ b/source.cpp @@ -1,5 +1,7 @@ #include +#warning "WARNNING: This is a warning message" + [[nodiscard]] int func() { return 42; } int main() { diff --git a/src/index.ts b/src/index.ts index 761b7bf..15af2f4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,25 +1,46 @@ -import { Octokit } from "@octokit/action"; -import { readFileSync } from "fs"; +import { readdirSync, readFileSync } from "fs"; +import { App } from "octokit"; -import { parseString } from "gcc-output-parser"; - -// if the action is triggered by not a pull request, exit if (!process.env.GITHUB_REF?.startsWith("refs/pull/")) { - console.log("Not a pull request, exiting."); + console.log("not a pull request, exiting."); process.exit(0); } -const octokit = new Octokit(); +const appId = parseInt(process.env.APP_ID!); +const privateKey = process.env.PRIVATE_KEY!; +const installationId = parseInt(process.env.INSTALLATION_ID!); +const clientId = process.env.CLIENT_ID!; +const clientSecret = process.env.CLIENT_SECRET!; + +console.log(appId, installationId, clientId); + +const app = new App({ appId, privateKey, oauth: { clientId, clientSecret } }); +const octokit = await app.getInstallationOctokit(installationId); const [owner, repo] = process.env.GITHUB_REPOSITORY?.split("/")!; const pull_request_number = parseInt(process.env.GITHUB_REF?.split("/")[2]!); -const compilation_output = readFileSync("compilation.log"); -const outputs = parseString(compilation_output); +let body = ""; + +for (const file of readdirSync(".")) { + if (!file.startsWith("compilation") || !file.endsWith(".log")) { + continue; + } + + const compilation_output = readFileSync(file).toString(); + + const regex = /warning( .\d+)?:/; + + const match_result = compilation_output.match(regex); + + if (match_result && match_result.length > 0) { + body += `detected warnings in the compilation output:
compilation output\n\n\`\`\`\n${compilation_output}\n\`\`\`\n
\n`; + } +} octokit.rest.issues.createComment({ owner, repo, issue_number: pull_request_number, - body: `compilation output is:\n\n\`\`\`\n${outputs}\n\`\`\``, + body, }); diff --git a/src/types.d.ts b/src/types.d.ts deleted file mode 100644 index 9a4c585..0000000 --- a/src/types.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -declare module "gcc-output-parser" { - export function parseString(input: string | Buffer): Array<{ - filename: string; - line: number; - column: number; - type: string; - text: string; - code: string; - adjustedColumn: number; - }>; -}