-
Notifications
You must be signed in to change notification settings - Fork 0
Revert "CI: rework caching and build/test environment" #31
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,43 +6,49 @@ inputs: | |
| description: "Python version to setup" | ||
| required: true | ||
| default: "3.13" | ||
| poetry_version: | ||
| description: "Poetry version to setup" | ||
| required: true | ||
| default: "2.1.3" | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Install Poetry | ||
| run: pipx install poetry==${{ inputs.poetry_version }} | ||
| shell: bash | ||
| - name: Set up Python 🐍 | ||
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | ||
| with: | ||
| python-version: ${{ inputs.python_version }} | ||
|
|
||
| - name: Default shell | ||
| run: | | ||
| if [ "$RUNNER_OS" == "Linux" ]; then | ||
| echo shellos=bash >> $GITHUB_ENV | ||
| elif [ "$RUNNER_OS" == "Windows" ]; then | ||
| echo shellos=powershell >> $GITHUB_ENV | ||
| else | ||
| echo "$RUNNER_OS not supported" | ||
| exit 1 | ||
| fi | ||
| shell: bash | ||
|
|
||
| - name: Set up Python 🐍 | ||
| id: setup-python | ||
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | ||
| with: | ||
| python-version: ${{ inputs.python_version }} | ||
| cache: poetry | ||
| cache-dependency-path: poetry.lock | ||
| - name: Install Poetry | ||
| uses: abatilo/actions-poetry@65c61eae400c65c9510a584af85138c1ae19bbc0 # v3.0.2 | ||
| with: | ||
| poetry-version: 2.1.3 | ||
|
|
||
| - name: Set Poetry environment | ||
| run: poetry env use ${{ inputs.python_version }} | ||
| shell: bash | ||
| # Cache your dependencies (i.e. all the stuff in your `pyproject.toml`). Note the cache | ||
| # key: if you're using multiple Python versions, or multiple OSes, you'd need to include | ||
| # them in the cache key. I'm not, so it can be simple and just depend on the poetry.lock. | ||
| - name: cache deps | ||
| id: cache-deps | ||
| uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | ||
| with: | ||
| path: ~/.cache/pypoetry | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The cache To fix this, you should dynamically determine the cache directory after Poetry is installed. For example, you could add a step before this one to get the path: - name: Get poetry cache directory
id: poetry-cache
run: echo "dir=$(poetry config cache-dir)" >> $GITHUB_OUTPUT
shell: bashThen, you can use |
||
| key: pydeps-${{ inputs.python_version }}-${{ env.shellos }}-${{ hashFiles('**/poetry.lock') }} | ||
|
|
||
| - name: Default shell | ||
| run: | | ||
| if [ "$RUNNER_OS" == "Linux" ]; then | ||
| echo shellos=bash >> $GITHUB_ENV | ||
| elif [ "$RUNNER_OS" == "Windows" ]; then | ||
| echo shellos=powershell >> $GITHUB_ENV | ||
| else | ||
| echo "$RUNNER_OS not supported" | ||
| exit 1 | ||
| fi | ||
| shell: bash | ||
| # Install dependencies. `--no-root` means "install all dependencies but not the project | ||
| # itself", which is what you want to avoid caching _your_ code. The `if` statement | ||
| # ensures this only runs on a cache miss. | ||
| - name: Install dependencies | ||
| run: poetry install --no-interaction --no-root | ||
| shell: ${{ env.shellos }} | ||
| if: steps.cache-deps.outputs.cache-hit != 'true' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This This logic is flawed:
Consider removing this condition to make the workflow more robust and efficient. |
||
|
|
||
| # The 'setup-python' action with 'cache: poetry' installs dependencies but not the project | ||
| # itself. This step installs the project package into the created virtual environment. | ||
| - name: Install project | ||
| run: poetry install --no-interaction | ||
| shell: ${{ env.shellos }} | ||
| - name: Install project | ||
| run: poetry install --no-interaction | ||
| shell: ${{ env.shellos }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
poetry.lockfile indicates it was generated with Poetry version2.1.1, but this step installs version2.1.3. Using a different version of Poetry than the one used to generate the lock file can lead to unexpected behavior or dependency resolution issues. It's best practice to use the same version to ensure consistency and avoid potential problems.