diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 4e9a2c9a..7b4b4df5 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -104,30 +104,47 @@ jobs: matrix: os: [ubuntu-latest] directory: [ - 'tests/dotnet', - 'tests/duplicates', - 'tests/go', - 'tests/java', - 'tests/js', - 'tests/py_error', - 'tests/dotnet', + 'tests/dotnet', 'tests/duplicates', 'tests/go', 'tests/java', 'tests/js', 'tests/py_error' ] arguments: [''] pr: [ 'true', 'false' ] include: - directory: 'tests/java' arguments: '-l,jetbrains/qodana-jvm-community' + os: 'ubuntu-latest' + pr: 'true' + - directory: 'tests/java' + arguments: '-l,jetbrains/qodana-jvm-community' + os: 'ubuntu-latest' + pr: 'false' - directory: 'tests/java' arguments: '-l,jetbrains/qodana-jvm-android' + os: 'ubuntu-latest' + pr: 'true' + - directory: 'tests/java' + arguments: '-l,jetbrains/qodana-jvm-android' + os: 'ubuntu-latest' + pr: 'false' - directory: 'tests/py_error' arguments: '-l,jetbrains/qodana-python-community' + os: 'ubuntu-latest' + pr: 'true' + - directory: 'tests/py_error' + arguments: '-l,jetbrains/qodana-python-community' + os: 'ubuntu-latest' + pr: 'false' + - directory: 'tests/dotnet' + arguments: '--ide,QDNET' + os: 'windows-latest' + pr: 'false' - directory: 'tests/dotnet' arguments: '--ide,QDNET' os: 'windows-latest' + pr: 'true' - directory: 'tests/dotnet' os: 'ubuntu-latest' - arguments: '-l,jetbrains/qodana-cdnet' - pr: 'false' # TODO: remove when fixed + arguments: '-l,jetbrains/qodana-cdnet:2024.1-eap' + pr: 'false' # TODO: set to true steps: - uses: actions/checkout@v4 with: @@ -139,28 +156,32 @@ jobs: path: 'tests' - name: Emulate pull request run: | - git config user.name qodana-bot - git config user.email qodana-support@jetbrains.com + git config --global user.name qodana-bot + git config --global user.email qodana-support@jetbrains.com git init git remote add origin https://github.com/JetBrains/code-analytics-examples.git echo "test" > README.md git add README.md git commit -m "Initial commit" - export BASE_COMMIT=$(git rev-parse HEAD) + QODANA_PR_SHA=$(git rev-parse HEAD) + echo "QODANA_PR_SHA=$QODANA_PR_SHA" >> $GITHUB_ENV git checkout -b new-feature git add . git commit -m "Add new feature" - export HEAD_COMMIT=$(git rev-parse HEAD) working-directory: '${{ matrix.directory }}' + shell: bash - name: Qodana uses: ./ with: - args: '${{ matrix.arguments }}' - pr-mode: false + args: ${{ format('-i,{0},{1}', matrix.directory, matrix.arguments) }} + pr-mode: ${{ matrix.pr }} post-pr-comment: false use-annotations: false + use-caches: false + use-nightly: true env: QODANA_TOKEN: ${{ secrets.QODANA_PROJECT_TESTS_TOKEN }} + QODANA_PR_SHA: ${{ env.QODANA_PR_SHA }} azure-dev-release: runs-on: ubuntu-latest diff --git a/scan/dist/index.js b/scan/dist/index.js index c141ff75..218552d8 100644 --- a/scan/dist/index.js +++ b/scan/dist/index.js @@ -125196,13 +125196,25 @@ var require_utils9 = __commonJS({ } __name(getInputs, "getInputs"); exports2.getInputs = getInputs; + function getPrSha() { + if (process.env.QODANA_PR_SHA) { + return process.env.QODANA_PR_SHA; + } + if (github2.context.payload.pull_request !== void 0) { + return github2.context.payload.pull_request.base.sha; + } + return ""; + } + __name(getPrSha, "getPrSha"); function qodana(inputs_1) { return __awaiter3(this, arguments, void 0, function* (inputs, args = []) { if (args.length === 0) { args = (0, qodana_12.getQodanaScanArgs)(inputs.args, inputs.resultsDir, inputs.cacheDir); - if (inputs.prMode && github2.context.payload.pull_request !== void 0) { - const pr = github2.context.payload.pull_request; - args.push("--commit", `CI${pr.base.sha}`); + if (inputs.prMode) { + const sha = getPrSha(); + if (sha !== "") { + args.push("--commit", sha); + } } } return (yield exec.getExecOutput(qodana_12.EXECUTABLE, args, { diff --git a/scan/src/utils.ts b/scan/src/utils.ts index 051fc628..652d1a15 100644 --- a/scan/src/utils.ts +++ b/scan/src/utils.ts @@ -74,6 +74,16 @@ export function getInputs(): Inputs { } } +function getPrSha(): string { + if (process.env.QODANA_PR_SHA) { + return process.env.QODANA_PR_SHA + } + if (github.context.payload.pull_request !== undefined) { + return github.context.payload.pull_request.base.sha + } + return '' +} + /** * Runs the qodana command with the given arguments. * @param inputs the action inputs. @@ -86,9 +96,11 @@ export async function qodana( ): Promise { if (args.length === 0) { args = getQodanaScanArgs(inputs.args, inputs.resultsDir, inputs.cacheDir) - if (inputs.prMode && github.context.payload.pull_request !== undefined) { - const pr = github.context.payload.pull_request - args.push('--commit', `CI${pr.base.sha}`) + if (inputs.prMode) { + const sha = getPrSha() + if (sha !== '') { + args.push('--commit', sha) + } } } return (