Skip to content

Commit

Permalink
🧱 Include more options into test matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
tiulpin committed May 14, 2024
1 parent 24381a6 commit 3c1919b
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 21 deletions.
51 changes: 36 additions & 15 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
18 changes: 15 additions & 3 deletions scan/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
18 changes: 15 additions & 3 deletions scan/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -86,9 +96,11 @@ export async function qodana(
): Promise<number> {
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 (
Expand Down

0 comments on commit 3c1919b

Please sign in to comment.