Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project structure and automation #23

Merged
merged 11 commits into from
Jun 23, 2023
Merged

Project structure and automation #23

merged 11 commits into from
Jun 23, 2023

Conversation

fk3
Copy link
Contributor

@fk3 fk3 commented Jun 20, 2023

  • Use of pyproject.toml to describe metadata and build information of pysweepme
    (modern way of setup.py/cfg and more)
  • Use of tox.ini to orchestrate various tests:
    • ruff (style and linting checks, including comparison to main)
    • mypy (type checking)
    • black (formatting, currently disabled)
    • pytest (unit tests)
      • including a test that checks for accidental FolderManager initialization on pysweepme import
    • build (wheel generation, just to check if it can be built, not used for publishing)
  • Github actions for
    • in Pull Requests:
      • Running all checks defined in the tox.ini
      • Check if the version number in the __init__.py has been adjusted (and does not yet exist on pypi)
      • Check if the completion of the PR will generate a semi-linear history (except for merges 1.5.5->1.5.6 etc.)
    • manually triggered:
      • Creating a pysweepme Build and upload it to (test.)pypi (manually triggered)

@fk3 fk3 force-pushed the project-structure branch 5 times, most recently from c4bd1b6 to c1b2fac Compare June 20, 2023 20:22
@fk3 fk3 force-pushed the project-structure branch 3 times, most recently from a691a7e to 834a604 Compare June 21, 2023 13:34
@fk3 fk3 force-pushed the project-structure branch 2 times, most recently from ce05dee to 11d373e Compare June 21, 2023 14:09
@fk3 fk3 temporarily deployed to testpypi June 21, 2023 14:09 — with GitHub Actions Inactive
@fk3 fk3 temporarily deployed to testpypi June 21, 2023 14:15 — with GitHub Actions Inactive
@fk3 fk3 force-pushed the project-structure branch 3 times, most recently from 5e67d59 to 6012f09 Compare June 21, 2023 14:45
fk3 added 3 commits June 21, 2023 17:21
With the beginning of more CI/CD, we should consistently
use the .github directory for github-specifics.
The condition for debug only prints previously used
the wrong variable, making the condition useless.
Now the correct variable that is passed as an argument
is used for evaluation of the condition.
PXIInstruments in PyVISA do not have the read() or write() methods.
Pysweepme cannot yet handle this case and would fail. Therefore
we raise an Exception telling the user that this is not implemented
and has to be written in the DC itself.
fk3 added 8 commits June 21, 2023 17:29
Address issues revealed by MyPy by fixing types that could not
be derived or were wrong. This commit does not yet address
missing function argument / return type annotations.
Fix issues revealed by ruff for easy-to-fix rules to create a
baseline that can be used from now on and should not fail.

Checking for open TCP/IP ports using the psutil.net_connections()
will not return IP addresses in case of Unix sockets. This case
must to be caught, ruff violations are ignored here.
Add project files with information and metadata about pysweepme
and its dependencies for building wheels,
as well as configurations for ruff, black, and mypy.
Include a script that runs ruff with a lot of rules enabled.
This currently creates a whole bunch of violations in pysweepme.
The script will compare the output to a reference run, which uses
the current code from master (and the rules from the current branch)
and raises an error if for any file-rule combination the amount of
violation increases. That way, we do not need to fix thousands of
violations in one go, and at the same time we ensure that we do
not incorporate more and more violations if we would not check those
rules.

Adding pytest for running unit tests and also include one test
that checks if the pysweepme import does not initialize the
FolderManager yet. This would lead to issues in the multi-instance
feature of SweepMe! and might not be spottet right away.

The tox.ini has the ruffregression in the first place, so that
when running two processes in parallel, it starts rightaway (has the
longest runtime).
Add a github workflow that will build and publish pysweepme.
After creating the wheel, pysweepme can be published to PyPI
or TestPyPI. Publishing to PyPI is only allowed from the main
branch. In case of the main branch / upload to PyPI, a tag is
added to the respective commit in the repository.

We do not add tags for TestPyPI or development branches, because
it is not strictly necessary and would just look bad in the
repository after rebases. In particular if multiple rebases
and publications are done alternating.

Credentials for publishing to (Test)PyPI are securely stored
as github Environment Secrets.
Add a script and a workflow that get the version of pysweepme
in the branch and check if this version is already online on
PyPI. If it is, the workflow will raise an error, reminding
the developer to update the version number of pysweepme.
@fk3
Copy link
Contributor Author

fk3 commented Jun 21, 2023

In "Run Checks" only the ruff-regression fails. This is expected, because this check compares existing linting violations to the main branch. However, as the checks are just introduced in this PR, the reference of the linting results from the main branch don't exist yet. This should work starting from the following PR, though.

@fk3 fk3 marked this pull request as ready for review June 21, 2023 16:33
@fk3 fk3 requested a review from a team as a code owner June 21, 2023 16:33
Copy link
Contributor

@afischer-sweepme afischer-sweepme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything looks very good

@fk3 fk3 merged commit 59ebbd5 into main Jun 23, 2023
@fk3 fk3 deleted the project-structure branch June 23, 2023 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants