From 4ad87965a4a417881e74e755e632db4dc4b58cbe Mon Sep 17 00:00:00 2001 From: perl_d Date: Fri, 27 Feb 2026 12:10:20 +0100 Subject: [PATCH 1/3] Update repo with template version v1.2.7 --- .copier-answers.yml | 2 +- .gitea/workflows/ci.yml | 22 ++++++---- .gitea/workflows/create_update_pr.yml | 62 +++++++++++++++++++++++++++ .gitlab-ci.yml | 7 --- pyproject.toml | 2 +- 5 files changed, 77 insertions(+), 18 deletions(-) create mode 100644 .gitea/workflows/create_update_pr.yml delete mode 100644 .gitlab-ci.yml diff --git a/.copier-answers.yml b/.copier-answers.yml index 3f8d06c..fa74426 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -2,7 +2,7 @@ # It is needed to track the repo template version, and editing may break things. # This file will be overwritten by copier on template updates. -_commit: v1.2.2 +_commit: v1.2.7 _src_path: https://github.com/bec-project/plugin_copier_template.git make_commit: true project_name: xil_bec diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 4ace55e..ba4f60e 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -28,7 +28,7 @@ on: description: "Python version to use" required: false type: string - default: "3.11" + default: "3.12" permissions: pull-requests: write @@ -44,7 +44,18 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: "${{ inputs.PYTHON_VERSION || '3.11' }}" + python-version: "${{ inputs.PYTHON_VERSION || '3.12' }}" + + - name: Checkout BEC Plugin Repository + uses: actions/checkout@v4 + with: + repository: bec/xil_bec + ref: "${{ inputs.BEC_PLUGIN_REPO_BRANCH || github.head_ref || github.sha }}" + path: ./xil_bec + + - name: Lint for merge conflicts + run: | + - name: Checkout BEC Core uses: actions/checkout@v4 @@ -67,13 +78,6 @@ jobs: ref: "${{ inputs.BEC_WIDGETS_BRANCH || 'main' }}" path: ./bec_widgets - - name: Checkout BEC Plugin Repository - uses: actions/checkout@v4 - with: - repository: bec/xil_bec - ref: "${{ inputs.BEC_PLUGIN_REPO_BRANCH || github.head_ref || github.sha }}" - path: ./xil_bec - - name: Install dependencies shell: bash run: | diff --git a/.gitea/workflows/create_update_pr.yml b/.gitea/workflows/create_update_pr.yml new file mode 100644 index 0000000..75ce587 --- /dev/null +++ b/.gitea/workflows/create_update_pr.yml @@ -0,0 +1,62 @@ +name: Create template upgrade PR for xil_bec +on: + workflow_dispatch: + +permissions: + pull-requests: write + +jobs: + create_update_branch_and_pr: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install tools + run: | + pip install copier PySide6 + + - name: Checkout + uses: actions/checkout@v4 + + - name: Perform update + run: | + git config --global user.email "bec_ci_staging@psi.ch" + git config --global user.name "BEC automated CI" + + branch="chore/update-template-$(python -m uuid)" + echo "switching to branch $branch" + git checkout -b $branch + + echo "Running copier update..." + output="$(copier update --trust --defaults --conflict inline 2>&1)" + echo "$output" + msg="$(printf '%s\n' "$output" | head -n 1)" + + if ! grep -q "make_commit: true" .copier-answers.yml ; then + echo "Autocommit not made, committing..." + git add -A + git commit -a -m "$msg" + fi + + if diff-index --quiet HEAD ; then + echo "No changes detected" + exit 0 + fi + + git push -u origin $branch + curl -X POST "https://gitea.psi.ch/api/v1/repos/${{ gitea.repository }}/pulls" \ + -H "Authorization: token ${{ secrets.CI_REPO_WRITE }}" \ + -H "Content-Type: application/json" \ + -d "{ + \"title\": \"Template: $(echo $msg)\", + \"body\": \"This PR was created by Gitea Actions\", + \"head\": \"$(echo $branch)\", + \"base\": \"main\" + }" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 720c141..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,7 +0,0 @@ -include: -- file: /templates/plugin-repo-template.yml - inputs: - name: xil_bec - target: xil_bec - branch: $CHILD_PIPELINE_BRANCH - project: bec/awi_utils diff --git a/pyproject.toml b/pyproject.toml index 334fd03..3614b5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "xil_bec" version = "0.0.0" description = "A plugin repository for BEC" -requires-python = ">=3.10" +requires-python = ">=3.11" classifiers = [ "Development Status :: 3 - Alpha", "Programming Language :: Python :: 3", -- 2.52.0 From b3a1339aa191662ab16895da450b9874c19c65b6 Mon Sep 17 00:00:00 2001 From: perl_d Date: Fri, 27 Feb 2026 15:48:46 +0100 Subject: [PATCH 2/3] Update repo with template version v1.2.8 --- .copier-answers.yml | 2 +- .gitea/workflows/ci.yml | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.copier-answers.yml b/.copier-answers.yml index fa74426..d43b8de 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -2,7 +2,7 @@ # It is needed to track the repo template version, and editing may break things. # This file will be overwritten by copier on template updates. -_commit: v1.2.7 +_commit: v1.2.8 _src_path: https://github.com/bec-project/plugin_copier_template.git make_commit: true project_name: xil_bec diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index ba4f60e..9469728 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -53,9 +53,10 @@ jobs: ref: "${{ inputs.BEC_PLUGIN_REPO_BRANCH || github.head_ref || github.sha }}" path: ./xil_bec - - name: Lint for merge conflicts - run: | - + - name: Lint for merge conflicts from template updates + shell: bash + # Find all Copier conflicts except this line + run: '! grep -r "<<<<<<< before updating" | grep -v "grep -r \"<<<<<<< before updating"' - name: Checkout BEC Core uses: actions/checkout@v4 -- 2.52.0 From 08a93b1470415623250493aeaaa479d2e996ed34 Mon Sep 17 00:00:00 2001 From: perl_d Date: Fri, 27 Feb 2026 16:01:02 +0100 Subject: [PATCH 3/3] Recopy template to generate tests dir --- tests/tests_bec_ipython_client/README.md | 34 ++++++++++++++++++++++++ tests/tests_bec_widgets/README.md | 34 ++++++++++++++++++++++++ tests/tests_dap_services/README.md | 34 ++++++++++++++++++++++++ tests/tests_devices/README.md | 34 ++++++++++++++++++++++++ tests/tests_file_writer/README.md | 34 ++++++++++++++++++++++++ tests/tests_scans/README.md | 34 ++++++++++++++++++++++++ 6 files changed, 204 insertions(+) create mode 100644 tests/tests_bec_ipython_client/README.md create mode 100644 tests/tests_bec_widgets/README.md create mode 100644 tests/tests_dap_services/README.md create mode 100644 tests/tests_devices/README.md create mode 100644 tests/tests_file_writer/README.md create mode 100644 tests/tests_scans/README.md diff --git a/tests/tests_bec_ipython_client/README.md b/tests/tests_bec_ipython_client/README.md new file mode 100644 index 0000000..63d535f --- /dev/null +++ b/tests/tests_bec_ipython_client/README.md @@ -0,0 +1,34 @@ +# Getting Started with Testing using pytest + +BEC is using the [pytest](https://docs.pytest.org/en/latest/) framework. +It can be installed via + +```bash +pip install pytest +``` + +in your _python environment_. +We note that pytest is part of the optional-dependencies `[dev]` of the plugin package. + +## Introduction + +Tests in this package should be stored in the `tests` directory. +We suggest to sort tests of different submodules, i.e. `scans` or `devices` in the respective folder structure, and to folow a naming convention of ``. +It is mandatory for test files to begin with `test_` for pytest to discover them. + +To run all tests, navigate to the directory of the plugin from the command line, and run the command + +```bash +pytest -v --random-order ./tests +``` + +Note, the python environment needs to be active. +The additional arg `-v` allows pytest to run in verbose mode which provides more detailed information about the tests being run. +The argument `--random-order` instructs pytest to run the tests in random order, which is the default in the CI pipelines. + +## Test examples + +Writing tests can be quite specific for the given function. +We recommend writing tests as isolated as possible, i.e. try to test single functions instead of full classes. +A very useful class to enable isolated testing is [MagicMock](https://docs.python.org/3/library/unittest.mock.html). +In addition, we also recommend to take a look at the [How-to guides from pytest](https://docs.pytest.org/en/8.0.x/how-to/index.html). diff --git a/tests/tests_bec_widgets/README.md b/tests/tests_bec_widgets/README.md new file mode 100644 index 0000000..63d535f --- /dev/null +++ b/tests/tests_bec_widgets/README.md @@ -0,0 +1,34 @@ +# Getting Started with Testing using pytest + +BEC is using the [pytest](https://docs.pytest.org/en/latest/) framework. +It can be installed via + +```bash +pip install pytest +``` + +in your _python environment_. +We note that pytest is part of the optional-dependencies `[dev]` of the plugin package. + +## Introduction + +Tests in this package should be stored in the `tests` directory. +We suggest to sort tests of different submodules, i.e. `scans` or `devices` in the respective folder structure, and to folow a naming convention of ``. +It is mandatory for test files to begin with `test_` for pytest to discover them. + +To run all tests, navigate to the directory of the plugin from the command line, and run the command + +```bash +pytest -v --random-order ./tests +``` + +Note, the python environment needs to be active. +The additional arg `-v` allows pytest to run in verbose mode which provides more detailed information about the tests being run. +The argument `--random-order` instructs pytest to run the tests in random order, which is the default in the CI pipelines. + +## Test examples + +Writing tests can be quite specific for the given function. +We recommend writing tests as isolated as possible, i.e. try to test single functions instead of full classes. +A very useful class to enable isolated testing is [MagicMock](https://docs.python.org/3/library/unittest.mock.html). +In addition, we also recommend to take a look at the [How-to guides from pytest](https://docs.pytest.org/en/8.0.x/how-to/index.html). diff --git a/tests/tests_dap_services/README.md b/tests/tests_dap_services/README.md new file mode 100644 index 0000000..63d535f --- /dev/null +++ b/tests/tests_dap_services/README.md @@ -0,0 +1,34 @@ +# Getting Started with Testing using pytest + +BEC is using the [pytest](https://docs.pytest.org/en/latest/) framework. +It can be installed via + +```bash +pip install pytest +``` + +in your _python environment_. +We note that pytest is part of the optional-dependencies `[dev]` of the plugin package. + +## Introduction + +Tests in this package should be stored in the `tests` directory. +We suggest to sort tests of different submodules, i.e. `scans` or `devices` in the respective folder structure, and to folow a naming convention of ``. +It is mandatory for test files to begin with `test_` for pytest to discover them. + +To run all tests, navigate to the directory of the plugin from the command line, and run the command + +```bash +pytest -v --random-order ./tests +``` + +Note, the python environment needs to be active. +The additional arg `-v` allows pytest to run in verbose mode which provides more detailed information about the tests being run. +The argument `--random-order` instructs pytest to run the tests in random order, which is the default in the CI pipelines. + +## Test examples + +Writing tests can be quite specific for the given function. +We recommend writing tests as isolated as possible, i.e. try to test single functions instead of full classes. +A very useful class to enable isolated testing is [MagicMock](https://docs.python.org/3/library/unittest.mock.html). +In addition, we also recommend to take a look at the [How-to guides from pytest](https://docs.pytest.org/en/8.0.x/how-to/index.html). diff --git a/tests/tests_devices/README.md b/tests/tests_devices/README.md new file mode 100644 index 0000000..63d535f --- /dev/null +++ b/tests/tests_devices/README.md @@ -0,0 +1,34 @@ +# Getting Started with Testing using pytest + +BEC is using the [pytest](https://docs.pytest.org/en/latest/) framework. +It can be installed via + +```bash +pip install pytest +``` + +in your _python environment_. +We note that pytest is part of the optional-dependencies `[dev]` of the plugin package. + +## Introduction + +Tests in this package should be stored in the `tests` directory. +We suggest to sort tests of different submodules, i.e. `scans` or `devices` in the respective folder structure, and to folow a naming convention of ``. +It is mandatory for test files to begin with `test_` for pytest to discover them. + +To run all tests, navigate to the directory of the plugin from the command line, and run the command + +```bash +pytest -v --random-order ./tests +``` + +Note, the python environment needs to be active. +The additional arg `-v` allows pytest to run in verbose mode which provides more detailed information about the tests being run. +The argument `--random-order` instructs pytest to run the tests in random order, which is the default in the CI pipelines. + +## Test examples + +Writing tests can be quite specific for the given function. +We recommend writing tests as isolated as possible, i.e. try to test single functions instead of full classes. +A very useful class to enable isolated testing is [MagicMock](https://docs.python.org/3/library/unittest.mock.html). +In addition, we also recommend to take a look at the [How-to guides from pytest](https://docs.pytest.org/en/8.0.x/how-to/index.html). diff --git a/tests/tests_file_writer/README.md b/tests/tests_file_writer/README.md new file mode 100644 index 0000000..63d535f --- /dev/null +++ b/tests/tests_file_writer/README.md @@ -0,0 +1,34 @@ +# Getting Started with Testing using pytest + +BEC is using the [pytest](https://docs.pytest.org/en/latest/) framework. +It can be installed via + +```bash +pip install pytest +``` + +in your _python environment_. +We note that pytest is part of the optional-dependencies `[dev]` of the plugin package. + +## Introduction + +Tests in this package should be stored in the `tests` directory. +We suggest to sort tests of different submodules, i.e. `scans` or `devices` in the respective folder structure, and to folow a naming convention of ``. +It is mandatory for test files to begin with `test_` for pytest to discover them. + +To run all tests, navigate to the directory of the plugin from the command line, and run the command + +```bash +pytest -v --random-order ./tests +``` + +Note, the python environment needs to be active. +The additional arg `-v` allows pytest to run in verbose mode which provides more detailed information about the tests being run. +The argument `--random-order` instructs pytest to run the tests in random order, which is the default in the CI pipelines. + +## Test examples + +Writing tests can be quite specific for the given function. +We recommend writing tests as isolated as possible, i.e. try to test single functions instead of full classes. +A very useful class to enable isolated testing is [MagicMock](https://docs.python.org/3/library/unittest.mock.html). +In addition, we also recommend to take a look at the [How-to guides from pytest](https://docs.pytest.org/en/8.0.x/how-to/index.html). diff --git a/tests/tests_scans/README.md b/tests/tests_scans/README.md new file mode 100644 index 0000000..63d535f --- /dev/null +++ b/tests/tests_scans/README.md @@ -0,0 +1,34 @@ +# Getting Started with Testing using pytest + +BEC is using the [pytest](https://docs.pytest.org/en/latest/) framework. +It can be installed via + +```bash +pip install pytest +``` + +in your _python environment_. +We note that pytest is part of the optional-dependencies `[dev]` of the plugin package. + +## Introduction + +Tests in this package should be stored in the `tests` directory. +We suggest to sort tests of different submodules, i.e. `scans` or `devices` in the respective folder structure, and to folow a naming convention of ``. +It is mandatory for test files to begin with `test_` for pytest to discover them. + +To run all tests, navigate to the directory of the plugin from the command line, and run the command + +```bash +pytest -v --random-order ./tests +``` + +Note, the python environment needs to be active. +The additional arg `-v` allows pytest to run in verbose mode which provides more detailed information about the tests being run. +The argument `--random-order` instructs pytest to run the tests in random order, which is the default in the CI pipelines. + +## Test examples + +Writing tests can be quite specific for the given function. +We recommend writing tests as isolated as possible, i.e. try to test single functions instead of full classes. +A very useful class to enable isolated testing is [MagicMock](https://docs.python.org/3/library/unittest.mock.html). +In addition, we also recommend to take a look at the [How-to guides from pytest](https://docs.pytest.org/en/8.0.x/how-to/index.html). -- 2.52.0