diff --git a/.github/actions/python_requirements/save_pip_cache/action.yml b/.github/actions/python_requirements/save_pip_cache/action.yml index 218e508..165bcf4 100644 --- a/.github/actions/python_requirements/save_pip_cache/action.yml +++ b/.github/actions/python_requirements/save_pip_cache/action.yml @@ -12,8 +12,6 @@ inputs: runs: using: "composite" steps: - # TODO non posso usare l'hash del file perchè quando vado ad aggiornare i requirements - # l'hash cambia e sicuramente non trovo la cache salvata - name: Generate random UUID id: generate_random_uuid run: | diff --git a/.github/workflows/_release_and_tag.yml b/.github/workflows/_release_and_tag.yml index e899456..92bf029 100644 --- a/.github/workflows/_release_and_tag.yml +++ b/.github/workflows/_release_and_tag.yml @@ -81,7 +81,7 @@ jobs: - name: Create Tag and Release id: create-release if: steps.check-tag.outputs.match == 'true' - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: tag_name: ${{ github.event.pull_request.title }} name: Version ${{ github.event.pull_request.title }} @@ -97,7 +97,7 @@ jobs: with: fetch-depth: 0 # otherwise, you do not retrieve the tags - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi) with: python-version: "3.x" diff --git a/.github/workflows/create_apt_cache.yaml b/.github/workflows/create_apt_cache.yaml index 7cd6937..06f26cc 100644 --- a/.github/workflows/create_apt_cache.yaml +++ b/.github/workflows/create_apt_cache.yaml @@ -13,6 +13,10 @@ on: # Path to APT requirements file - '.github/test/python_test/packages.txt' +# discard previous execution if you commit to a branch that is already running +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: create-cache: @@ -25,15 +29,15 @@ jobs: - name: Install APT dependencies run: | sudo apt-get update - sudo apt-get -y install --no-install-recommends $(tr '\n' ' ' < apt_packages.txt) + sudo apt-get -y install --no-install-recommends $(tr '\n' ' ' < .github/test/python_test/packages.txt) - name: Compute apt_packages.txt SHA256 hash id: compute_apt_packages_sha256_hash - run: | - COMPUTED_HASH=$(sha256sum apt_packages.txt | cut -d ' ' -f 1) - echo "cache_key=$COMPUTED_HASH" >> $GITHUB_OUTPUT + uses: ./.github/actions/misc/compute_files_hash + with: + file_paths: .github/test/python_test/packages.txt - uses: actions/cache/save@v4 with: path: /var/cache/apt/archives/*.deb - key: ${{ github.ref_name }}-${{ steps.compute_apt_packages_sha256_hash.outputs.cache_key }} + key: ${{ github.ref_name }}-${{ steps.compute_apt_packages_sha256_hash.outputs.computed_hash }} diff --git a/.github/workflows/create_python_cache.yaml b/.github/workflows/create_python_cache.yaml new file mode 100644 index 0000000..a6b65b5 --- /dev/null +++ b/.github/workflows/create_python_cache.yaml @@ -0,0 +1,50 @@ +name: Create Python cache + +# GitHub will remove any cache entries that have not been accessed in over 7 days. + +# Only project dependencies will be cached here + +on: + push: + branches: + - main + - master + - develop + - dev + paths: + - '.github/test/python_test/requirements.txt' + +# discard previous execution if you commit to a branch that is already running +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + create-python-cache: + name: Create cache for Python dependencies + runs-on: ubuntu-latest + steps: + - name: Check out latest commit + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Set up Python's virtual environment + uses: ./.github/actions/python_requirements/create_virtualenv + + - name: Install Python dependencies + run: | + pip install -r .github/test/python_test/requirements.txt + working-directory: "." + + - name: Save pip cache + uses: ./.github/actions/python_requirements/save_pip_cache + + - name: Create virtual environment cache + uses: ./.github/actions/python_requirements/save_virtualenv + with: + requirements_paths: .github/test/python_test/requirements.txt + diff --git a/CHANGELOG.md b/CHANGELOG.md index aa1d0af..9ff6f6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,3 +27,6 @@ * Removed `setup-python-dependencies` from `codeql/action.yml` since it has no effect anymore. See [this](https://github.blog/changelog/2024-01-23-codeql-2-16-python-dependency-installation-disabled-new-queries-and-bug-fixes/) for more information. * Linters versions in step `Create requirements-linters.txt` of `_python.yml` action are now computed according to `configurations/python_linters/requirements-linters.txt`. As of now, linter updates are only required in `configurations/python_linters/requirements-linters.txt`. * Reworked Python requirements caching. +* Updated some Github actions: + * setup-python v4 -> v5 + * action-gh-release v1 -> v2 diff --git a/actions/python_requirements/save_pip_cache/action.yml b/actions/python_requirements/save_pip_cache/action.yml index 218e508..165bcf4 100644 --- a/actions/python_requirements/save_pip_cache/action.yml +++ b/actions/python_requirements/save_pip_cache/action.yml @@ -12,8 +12,6 @@ inputs: runs: using: "composite" steps: - # TODO non posso usare l'hash del file perchè quando vado ad aggiornare i requirements - # l'hash cambia e sicuramente non trovo la cache salvata - name: Generate random UUID id: generate_random_uuid run: | diff --git a/workflows/_release_and_tag.yml b/workflows/_release_and_tag.yml index e899456..92bf029 100644 --- a/workflows/_release_and_tag.yml +++ b/workflows/_release_and_tag.yml @@ -81,7 +81,7 @@ jobs: - name: Create Tag and Release id: create-release if: steps.check-tag.outputs.match == 'true' - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: tag_name: ${{ github.event.pull_request.title }} name: Version ${{ github.event.pull_request.title }} @@ -97,7 +97,7 @@ jobs: with: fetch-depth: 0 # otherwise, you do not retrieve the tags - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 if: steps.check-tag.outputs.match == 'true' && (inputs.publish_on_pypi || inputs.publish_on_test_pypi) with: python-version: "3.x"