uv/scripts/sync_scenarios.sh
sobolevn 56521937b7
Add shellcheck CI (#7888)
<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

I started learning `uv` by inspecting the source code.
I've noticed that your shell scripts are very good! Which is rare!

## Test Plan

I propose to add `shellcheck` to the CI.
It is a great tool to help finding bugs and style issues in shell code.

Techincal details:
- This CI job will only run when any `.sh` files are changed (or the job
definition file)
- It takes just several seconds even on local machine:
```
» time shellcheck -S style **/*.sh
shellcheck -S style **/*.sh  0.02s user 0.05s system 61% cpu 0.123 total
```

- It is easy to use, for example: I just fixed the single problem you
had in your code with `# shellcheck disable=SC1091`
- I am using this tool for around 8 years now and didn't have any
issues. Examples:
ca899f3b69/.github/workflows/test.yml (L22-L27)
and
https://github.com/wemake-services/wemake-django-template/blob/master/.github/workflows/shellcheck.yml

But, I understand that build / lint tools are very subjective. So, feel
free to close :)
2024-10-08 13:58:00 -05:00

39 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# Sync test scenarios with the pinned version of packse.
#
# Usage:
#
# Install the pinned packse version in a temporary virtual environment, fetch scenarios, and regenerate test cases and snapshots:
#
# $ ./scripts/sync_scenarios.sh
#
# Additional arguments are passed to `./scripts/scenarios/generate.py`, for example:
#
# $ ./scripts/sync_scenarios.sh --verbose --no-snapshot-update
#
# For development purposes, the `./scripts/scenarios/generate.py` script can be used directly to generate
# test cases from a local set of scenarios.
#
# See `scripts/scenarios/` for supporting files.
set -eu
script_root="$(realpath "$(dirname "$0")")"
cd "$script_root/scenarios"
echo "Setting up a temporary environment..."
uv venv
# shellcheck disable=SC1091
source ".venv/bin/activate"
uv pip install -r requirements.txt --refresh-package packse
echo "Fetching packse scenarios..."
packse fetch --dest "$script_root/scenarios/.downloads" --force
unset VIRTUAL_ENV # Avoid warning due to venv mismatch
.venv/bin/python "$script_root/scenarios/generate.py" "$script_root/scenarios/.downloads" "$@"
# Cleanup
rm -r "$script_root/scenarios/.downloads"