From 8ad8388412b3e4acb829d34577de68ce87a3acaa Mon Sep 17 00:00:00 2001 From: Abel Soares Siqueira Date: Fri, 13 Sep 2024 13:49:50 +0200 Subject: [PATCH] Add Python version to workflows in package and template Add python-version: 3.11 to workflows. Use a hack to manage setup-python looking for requirements.txt. Refs: actions/setup-python#807 Closes #448 --- .github/workflows/Lint.yml | 5 +++++ .github/workflows/PreCommitUpdate.yml | 5 +++++ .github/workflows/ReusableTest.yml | 5 +++++ .github/workflows/TestGeneratedPkg.yml | 5 +++++ template/.github/workflows/Lint.yml.jinja | 5 +++++ .../{% if AddCopierCI %}Copier.yml{% endif %}.jinja | 5 +++++ ...{% if AddPrecommit %}PreCommitUpdate.yml{% endif %}.jinja | 5 +++++ 7 files changed, 35 insertions(+) diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml index 388a8ffc..d2ca8ab9 100644 --- a/.github/workflows/Lint.yml +++ b/.github/workflows/Lint.yml @@ -28,10 +28,15 @@ jobs: uses: julia-actions/cache@v2 - name: Install JuliaFormatter.jl run: julia -e 'using Pkg; pkg"add JuliaFormatter"' + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: touch requirements.txt - name: Setup Python uses: actions/setup-python@v5 with: cache: "pip" + python-version: "3.11" + - name: Un-Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: rm requirements.txt - name: Cache pre-commit uses: actions/cache@v4 with: diff --git a/.github/workflows/PreCommitUpdate.yml b/.github/workflows/PreCommitUpdate.yml index 01bb4c28..35a48a24 100644 --- a/.github/workflows/PreCommitUpdate.yml +++ b/.github/workflows/PreCommitUpdate.yml @@ -10,10 +10,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: touch requirements.txt - name: Setup Python uses: actions/setup-python@v5 with: cache: pip + python-version: "3.11" + - name: Un-Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: rm requirements.txt - name: Install pre-commit run: pip install pre-commit - name: Run pre-commit's autoupdate diff --git a/.github/workflows/ReusableTest.yml b/.github/workflows/ReusableTest.yml index e87f320a..53caee1d 100644 --- a/.github/workflows/ReusableTest.yml +++ b/.github/workflows/ReusableTest.yml @@ -53,10 +53,15 @@ jobs: arch: ${{ inputs.arch }} - name: Use Julia cache uses: julia-actions/cache@v2 + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: touch requirements.txt - name: Setup Python uses: actions/setup-python@v5 with: cache: "pip" + python-version: "3.11" + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: rm requirements.txt - name: Cache pre-commit uses: actions/cache@v4 with: diff --git a/.github/workflows/TestGeneratedPkg.yml b/.github/workflows/TestGeneratedPkg.yml index 2413e3a2..21655b9c 100644 --- a/.github/workflows/TestGeneratedPkg.yml +++ b/.github/workflows/TestGeneratedPkg.yml @@ -52,10 +52,15 @@ jobs: uses: julia-actions/julia-buildpkg@v1 - name: Install JuliaFormatter.jl run: julia -e 'using Pkg; pkg"add JuliaFormatter"' + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: touch requirements.txt - name: Setup Python uses: actions/setup-python@v5 with: cache: "pip" + python-version: "3.11" + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: rm requirements.txt - name: Cache pre-commit uses: actions/cache@v4 with: diff --git a/template/.github/workflows/Lint.yml.jinja b/template/.github/workflows/Lint.yml.jinja index c4b0283b..4585f2ef 100644 --- a/template/.github/workflows/Lint.yml.jinja +++ b/template/.github/workflows/Lint.yml.jinja @@ -29,10 +29,15 @@ jobs: uses: julia-actions/cache@v2 - name: Install JuliaFormatter.jl run: julia -e 'using Pkg; pkg"add JuliaFormatter"' + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: touch requirements.txt - name: Setup Python uses: actions/setup-python@v5 with: cache: "pip" + python-version: "3.11" + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: rm requirements.txt - name: Cache pre-commit uses: actions/cache@v4 with: diff --git a/template/.github/workflows/{% if AddCopierCI %}Copier.yml{% endif %}.jinja b/template/.github/workflows/{% if AddCopierCI %}Copier.yml{% endif %}.jinja index d3875a68..dfa8f207 100644 --- a/template/.github/workflows/{% if AddCopierCI %}Copier.yml{% endif %}.jinja +++ b/template/.github/workflows/{% if AddCopierCI %}Copier.yml{% endif %}.jinja @@ -19,10 +19,15 @@ jobs: uses: julia-actions/cache@v2 - name: Install JuliaFormatter.jl run: julia -e 'using Pkg; pkg"add JuliaFormatter"' + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: touch requirements.txt - name: Setup Python uses: actions/setup-python@v5 with: cache: 'pip' + python-version: "3.11" + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: rm requirements.txt - name: Check for update in the template run: | pip install copier diff --git a/template/.github/workflows/{% if AddPrecommit %}PreCommitUpdate.yml{% endif %}.jinja b/template/.github/workflows/{% if AddPrecommit %}PreCommitUpdate.yml{% endif %}.jinja index 79e0571e..306e6b60 100644 --- a/template/.github/workflows/{% if AddPrecommit %}PreCommitUpdate.yml{% endif %}.jinja +++ b/template/.github/workflows/{% if AddPrecommit %}PreCommitUpdate.yml{% endif %}.jinja @@ -10,10 +10,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: touch requirements.txt - name: Setup Python uses: actions/setup-python@v5 with: cache: pip + python-version: "3.11" + - name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 + run: rm requirements.txt - name: Install pre-commit run: pip install pre-commit - name: Run pre-commit's autoupdate