mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-11-18 17:24:04 +01:00
Merge branch 'developer' into dev/test_num_frames_detail_err_msg
This commit is contained in:
7 files changed
+314
-18
No files matched your search
@@ -1,4 +1,4 @@
|
||||
# This workflow is triggered when opening/reopening PR, editing the PR description or changing labels. It ignores unrelated label changes. It runs PR type validation and if it succeeds, it runs PR milestone and detector labels workflow in parallel.
|
||||
# This workflow is triggered when opening/reopening PR, editing the PR description or changing labels. It ignores unrelated label changes. It runs PR type validation and if it succeeds, it runs PR milestone, release notes, file version and detector labels workflow in parallel.
|
||||
name: PR Edit Trigger
|
||||
|
||||
on:
|
||||
@@ -13,6 +13,7 @@ on:
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: read
|
||||
models: read
|
||||
|
||||
jobs:
|
||||
check-pr-trigger:
|
||||
@@ -102,7 +103,17 @@ jobs:
|
||||
contents: read
|
||||
|
||||
milestone:
|
||||
needs: validate-pr-type
|
||||
needs:
|
||||
- check-pr-trigger
|
||||
- validate-pr-type
|
||||
if: >-
|
||||
${{
|
||||
always() &&
|
||||
(
|
||||
needs.check-pr-trigger.outputs.require_validation == 'false' ||
|
||||
needs.validate-pr-type.result == 'success'
|
||||
)
|
||||
}}
|
||||
uses: ./.github/workflows/pr_milestone.yaml
|
||||
with:
|
||||
pr_number: ${{ github.event.pull_request.number }}
|
||||
@@ -111,7 +122,17 @@ jobs:
|
||||
contents: read
|
||||
|
||||
detector-labels:
|
||||
needs: validate-pr-type
|
||||
needs:
|
||||
- check-pr-trigger
|
||||
- validate-pr-type
|
||||
if: >-
|
||||
${{
|
||||
always() &&
|
||||
(
|
||||
needs.check-pr-trigger.outputs.require_validation == 'false' ||
|
||||
needs.validate-pr-type.result == 'success'
|
||||
)
|
||||
}}
|
||||
uses: ./.github/workflows/pr_detector_labels.yaml
|
||||
with:
|
||||
pr_number: ${{ github.event.pull_request.number }}
|
||||
@@ -119,6 +140,25 @@ jobs:
|
||||
pull-requests: write
|
||||
issues: read
|
||||
|
||||
release-notes:
|
||||
needs:
|
||||
- check-pr-trigger
|
||||
- detector-labels
|
||||
if: >-
|
||||
${{
|
||||
always() &&
|
||||
(
|
||||
needs.check-pr-trigger.outputs.require_validation == 'false' ||
|
||||
needs.detector-labels.result == 'success'
|
||||
)
|
||||
}}
|
||||
uses: ./.github/workflows/pr_release_notes.yaml
|
||||
with:
|
||||
pr_number: ${{ github.event.pull_request.number }}
|
||||
permissions:
|
||||
pull-requests: read
|
||||
contents: read
|
||||
|
||||
file-version:
|
||||
needs:
|
||||
- check-pr-trigger
|
||||
@@ -127,11 +167,11 @@ jobs:
|
||||
${{
|
||||
always() &&
|
||||
(
|
||||
needs.check-pr-trigger.outputs.file_label_change == 'true' ||
|
||||
(
|
||||
needs.check-pr-trigger.outputs.pr_edited == 'true' &&
|
||||
needs.validate-pr-type.result == 'success'
|
||||
)
|
||||
needs.check-pr-trigger.outputs.file_label_change == 'true'
|
||||
) ||
|
||||
(
|
||||
needs.check-pr-trigger.outputs.require_validation == 'false' ||
|
||||
needs.validate-pr-type.result == 'success'
|
||||
)
|
||||
}}
|
||||
uses: ./.github/workflows/pr_file_version.yaml
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
# This reusable workflow validates the PR release notes. It ignores comments and
|
||||
# <details> blocks, checks for notes under the "## Release notes" section. If
|
||||
# it is not an Infrastructure PR and release notes are not found, it should find
|
||||
# them in an equivalent PR or referenced PR, else validation fails. If it is an
|
||||
# Infrastructure PR and release notes are found, validation fails.
|
||||
|
||||
name: PR Release Notes
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
pr_number:
|
||||
required: true
|
||||
type: number
|
||||
|
||||
permissions:
|
||||
pull-requests: read
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check-release-notes:
|
||||
name: Check PR release notes
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
- name: Validate with labels
|
||||
id: validate-labels
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const prNumber = ${{ inputs.pr_number }};
|
||||
if (!prNumber) {
|
||||
core.setFailed('Unable to determine PR number.');
|
||||
return;
|
||||
}
|
||||
|
||||
core.setOutput('is_main_branch', 'false');
|
||||
core.setOutput('require_release_notes', 'true');
|
||||
|
||||
// base branch: main => no validation needed
|
||||
const { data: pr } = await github.rest.pulls.get({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: prNumber
|
||||
});
|
||||
const baseBranch = pr.base.ref;
|
||||
if (baseBranch === 'main') {
|
||||
core.info('PR targets main branch. Release notes validation is not required.');
|
||||
core.setOutput('is_main_branch', 'true');
|
||||
core.setOutput('require_release_notes', 'false');
|
||||
return;
|
||||
}
|
||||
|
||||
// get current PR labels
|
||||
const { data: labels } =
|
||||
await github.rest.issues.listLabelsOnIssue({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: prNumber
|
||||
});
|
||||
const labelNames = labels.map(label => label.name);
|
||||
|
||||
// infrastructure label
|
||||
const hasInfrastructure = labelNames.includes('Infrastructure');
|
||||
core.info('Infrastructure label: ' + hasInfrastructure);
|
||||
|
||||
// developer detector label
|
||||
const developingDetectorLabels = ['Ctb', 'Xilinx Ctb', 'Matterhorn'];
|
||||
const otherDetectorLabels = ['Eiger', 'Mythen3', 'Gotthard2', 'Jungfrau', 'Moench'];
|
||||
const hasDevelopingDetectorLabel = labelNames.some(
|
||||
label => developingDetectorLabels.includes(label)
|
||||
);
|
||||
const hasOtherDetectorLabel = labelNames.some(
|
||||
label => otherDetectorLabels.includes(label)
|
||||
);
|
||||
const hasOnlyDevelopingDetectors =
|
||||
hasDevelopingDetectorLabel && !hasOtherDetectorLabel;
|
||||
core.info('Only developing detector labels: ' + hasOnlyDevelopingDetectors + '\n');
|
||||
|
||||
if (hasInfrastructure || hasOnlyDevelopingDetectors) {
|
||||
core.setOutput('require_release_notes', 'false');
|
||||
core.info ('Release notes required: false');
|
||||
return;
|
||||
}
|
||||
|
||||
core.info('Release notes required: true');
|
||||
|
||||
|
||||
- name: Find release notes in current PR
|
||||
id: find-current
|
||||
if: steps.validate-labels.outputs.is_main_branch == 'false'
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const prNumber = ${{ inputs.pr_number }};
|
||||
core.setOutput('needs_further_action', 'false');
|
||||
|
||||
// some functions to help find release notes in current PR body
|
||||
const stripIgnoredContent = (text = '') => {
|
||||
return (text || '')
|
||||
.replace(/<!--.*?-->/gs, '\n')
|
||||
.replace(/<details\b[\s\S]*?<\/details>/gi, '\n')
|
||||
.trim();
|
||||
};
|
||||
const findReleaseNotesSection = (body = '') => {
|
||||
const sanitized = stripIgnoredContent(body || '');
|
||||
if (!sanitized) return '';
|
||||
|
||||
const match = sanitized.match(
|
||||
/(^|\n)#{1,6}\s*Release notes\s*\n([\s\S]*?)(?=\n#{1,6}\s+\S|\s*$)/i
|
||||
);
|
||||
if (!match) return '';
|
||||
|
||||
let section = (match[2] || '')
|
||||
.split('\n')
|
||||
.filter(line => !/^#{1,6}\s+/.test(line.trim()))
|
||||
.join('\n')
|
||||
.trim();
|
||||
|
||||
return section;
|
||||
};
|
||||
|
||||
const { data: pr } = await github.rest.pulls.get({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: prNumber
|
||||
});
|
||||
|
||||
// find release notes in the current PR body
|
||||
const releaseNotes = findReleaseNotesSection(pr.body || '');
|
||||
const hasReleaseNotesCurrent = Boolean(releaseNotes);
|
||||
core.info('Release notes in current PR: ' + (hasReleaseNotesCurrent ? 'Found\n' : 'Not found\n'));
|
||||
|
||||
// validate release notes requirement
|
||||
const requireReleaseNotes = '${{ steps.validate-labels.outputs.require_release_notes }}' === 'true';
|
||||
if (!requireReleaseNotes) {
|
||||
if (hasReleaseNotesCurrent) {
|
||||
core.setFailed('Release notes cannot be included for this PR ' +
|
||||
'(Infrastructure/developing detector). \n' +
|
||||
'To fix this, \n' +
|
||||
'\t - remove release notes or\n' +
|
||||
'\t - change PR type or\n' +
|
||||
'\t - add/remove detector labels.\n');
|
||||
return;
|
||||
}
|
||||
core.info('No further action required (Infrastructure/developing detector).');
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasReleaseNotesCurrent) {
|
||||
core.info('No further action required.');
|
||||
return;
|
||||
}
|
||||
|
||||
core.setOutput('needs_further_action', 'true');
|
||||
core.info('Further action required.');
|
||||
|
||||
- name: Find release notes in linked PRs
|
||||
if: >-
|
||||
${{
|
||||
steps.validate-labels.outputs.is_main_branch == 'false' &&
|
||||
steps.find-current.outputs.needs_further_action == 'true'
|
||||
}}
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const prNumber = ${{ inputs.pr_number }};
|
||||
|
||||
// functions to find release notes in linked PRs
|
||||
const stripIgnoredContent = (text = '') => {
|
||||
return (text || '')
|
||||
.replace(/<!--.*?-->/gs, '\n')
|
||||
.replace(/<details\b[\s\S]*?<\/details>/gi, '\n')
|
||||
.trim();
|
||||
};
|
||||
const findReleaseNotesSection = (body = '') => {
|
||||
const sanitized = stripIgnoredContent(body || '');
|
||||
if (!sanitized) return '';
|
||||
|
||||
const match = sanitized.match(
|
||||
/(^|\n)#{1,6}\s*Release notes\s*\n([\s\S]*?)(?=\n#{1,6}\s+\S|\s*$)/i
|
||||
);
|
||||
if (!match) return '';
|
||||
|
||||
return (match[2] || '')
|
||||
.split('\n')
|
||||
.filter(line => !/^#{1,6}\s+/.test(line.trim()))
|
||||
.join('\n')
|
||||
.trim();
|
||||
};
|
||||
const parseNumberList = (text) => {
|
||||
if (!text) {
|
||||
return [];
|
||||
}
|
||||
return Array.from(
|
||||
new Set(
|
||||
Array.from(text.matchAll(/#(\d+)/g), match => Number(match[1]))
|
||||
)
|
||||
);
|
||||
};
|
||||
const findReferencedPrNumbers = (body = '') => {
|
||||
if (!body) {
|
||||
return [];
|
||||
}
|
||||
const relevantSections = [
|
||||
'Equivalent PRs',
|
||||
'Referenced PRs'
|
||||
];
|
||||
const patterns = relevantSections.map(section =>
|
||||
new RegExp(
|
||||
`(^|\\n)#{1,6}\\s*${section.replace(/[.*+?^${}()|[\\]\\]/g, '\\$&')}\\s*\\n([\\s\\S]*?)(?=\\n#{1,6}\\s+\\S|\\s*$)`,
|
||||
'i'
|
||||
)
|
||||
);
|
||||
const numbers = [];
|
||||
for (const pattern of patterns) {
|
||||
const match = body.match(pattern);
|
||||
if (match && match[2]) {
|
||||
numbers.push(...parseNumberList(match[2]));
|
||||
}
|
||||
}
|
||||
return Array.from(new Set(numbers));
|
||||
};
|
||||
|
||||
// Loop thorough linked PRs to find release notes
|
||||
const { data: pr } = await github.rest.pulls.get({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: prNumber
|
||||
});
|
||||
|
||||
const equivalentAndReferencedPrNumbers = findReferencedPrNumbers(pr.body || '');
|
||||
for (const referencedPrNumber of equivalentAndReferencedPrNumbers) {
|
||||
if (referencedPrNumber === prNumber) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
const { data: referencedPr } =
|
||||
await github.rest.pulls.get({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: referencedPrNumber
|
||||
});
|
||||
const referencedNotes = findReleaseNotesSection(referencedPr.body || '');
|
||||
if (referencedNotes) {
|
||||
core.info(
|
||||
`Release notes found: In equivalent/referenced PR ` +
|
||||
`#${referencedPrNumber}. Using that as the source for this PR.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
core.warning(
|
||||
`Unable to inspect referenced PR #${referencedPrNumber}: ${error.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
core.setFailed(
|
||||
'No release notes were found in the PR body, equivalent PRs, or referenced PRs.'
|
||||
);
|
||||
Binary file not shown.
@@ -63,7 +63,6 @@
|
||||
#define DEFAULT_TIMING_INFO_DECODER (SWISSFEL)
|
||||
#define DEFAULT_ELECTRON_COLLECTION_MODE (0)
|
||||
|
||||
#define MAX_PEDESTAL_LOOPS (0xFF) // until fixed in firmware
|
||||
#define HIGHVOLTAGE_MIN (60)
|
||||
#define HIGHVOLTAGE_MAX (200)
|
||||
#define DAC_MIN_MV (0)
|
||||
|
||||
@@ -10745,13 +10745,6 @@ int set_pedestal_mode(int file_des) {
|
||||
"be 0. [%hhu, %hu].\n",
|
||||
frames, loops);
|
||||
LOG(logERROR, (mess));
|
||||
} else if (loops > MAX_PEDESTAL_LOOPS) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set pedestal mode. Loops [%hu] cannot be "
|
||||
"greater than %d.\n",
|
||||
loops, MAX_PEDESTAL_LOOPS);
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
setPedestalMode(enable, frames, loops);
|
||||
int retvalEnable = getPedestalMode();
|
||||
|
||||
@@ -524,10 +524,12 @@ TEST_CASE("pedestalmode", "[.detectorintegration]") {
|
||||
|
||||
REQUIRE_THROWS(caller.call("pedestalmode", {"256", "10"}, -1, PUT));
|
||||
REQUIRE_THROWS(caller.call("pedestalmode", {"-1", "10"}, 0, PUT));
|
||||
REQUIRE_THROWS(caller.call("pedestalmode", {"20", "1000"}, 0, PUT));
|
||||
REQUIRE_THROWS(caller.call("pedestalmode", {"20", "65536"}, 0, PUT));
|
||||
REQUIRE_THROWS(caller.call("pedestalmode", {"2000", "100"}, 0, PUT));
|
||||
REQUIRE_THROWS(caller.call("pedestalmode", {"20", "-1"}, 0, PUT));
|
||||
|
||||
REQUIRE_NOTHROW(caller.call("pedestalmode", {"20", "4000"}, 0, PUT));
|
||||
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("pedestalmode", {"30", "100"}, -1, PUT, oss);
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
#define APIMOENCH "0.0.0 0x260424"
|
||||
#define APIEIGER "0.0.0 0x260807"
|
||||
#define APIXILINXCTB "0.0.0 0x260813"
|
||||
#define APIJUNGFRAU "0.0.0 0x260814"
|
||||
#define APIJUNGFRAU "0.0.0 0x260902"
|
||||
#define APIMYTHEN3 "0.0.0 0x260506"
|
||||
#define APIMATTERHORN "0.0.0 0x260529"
|
||||
Reference in new issue
Block a user