Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: PCDS pre-commit Testing

on:
push:
pull_request:
release:
types:
- created

jobs:
pre_commit:
uses: pcdshub/pcds-ci-helpers/.github/workflows/pre-commit.yml@master
with:
args: "--all-files"

test:
name: "Python 3.12: pip"
runs-on: ubuntu-latest

defaults:
run:
# The following allows for each run step to utilize ~/.bash_profile
# for setting up the per-step initial state.
# --login: a login shell. Source ~/.bash_profile
# -e: exit on first error
# -o pipefail: piped processes are important; fail if they fail
shell: bash --login -eo pipefail {0}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'

- name: Check version to be built
run: |
# NOTE: If you run CI on your own fork, you may not have the right version
# number for the package. Synchronize your tags with the upstream,
# otherwise cross-dependencies may result in confusing build failure.
(echo "Package version: $(git describe --tags)" | tee "$GITHUB_STEP_SUMMARY") || \
echo "::warning::Git tags not found in repository. Build may fail!"

- name: Check environment variables for issues
run: |
echo "* Package to be built: pre-commit"

- name: Prepare for log files
run: |
mkdir $HOME/logs

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Upgrade pip
run: |
pip install --upgrade pip

- name: Install package
run: |
python -m pip install .

- name: Check the pip packages in the test env
run: |
pip list

- name: Run tests
run: |
pytest -v \
--log-file="$HOME/logs/debug_log.txt" \
--log-format='%(asctime)s.%(msecs)03d %(module)-15s %(levelname)-8s %(threadName)-10s %(message)s' \
--log-file-date-format='%H:%M:%S' \
--log-level=DEBUG \
2>&1 | tee "$HOME/logs/pytest_log.txt"
20 changes: 12 additions & 8 deletions pre_commit_hooks/check_fixed_library_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ def check_file(filename):
non_fixed_library_versions = added_libraries - fixed_version_libraries

if len(non_fixed_library_versions) == 1:
raise PreCommitException((
f"Library version of {list(non_fixed_library_versions)[0]} is "
f"not fixed! File parsed: {filename}"
))
raise PreCommitException(
(
f"Library version of {list(non_fixed_library_versions)[0]} is "
f"not fixed! File parsed: {filename}"
)
)
elif len(non_fixed_library_versions) > 1:
raise PreCommitException((
f"Library version of {', '.join(non_fixed_library_versions)} "
f"are not fixed! File parsed: {filename}"
))
raise PreCommitException(
(
f"Library version of {', '.join(non_fixed_library_versions)} "
f"are not fixed! File parsed: {filename}"
)
)


def main(args=None):
Expand Down
4 changes: 3 additions & 1 deletion pre_commit_hooks/check_twincat_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def main(args=None):
if args is None:
parser = argparse.ArgumentParser()
parser.add_argument(
"filenames", nargs="+", help="List of tsproj and tspproj filenames to process."
"filenames",
nargs="+",
help="List of tsproj and tspproj filenames to process.",
)
parser.add_argument(
"--target-version", type=str, help="Target TwinCAT version to enforce."
Expand Down