From b1e53583d373f5d1a4094014bb8a544d07ba3c8b Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Tue, 14 Mar 2023 14:10:30 +0100 Subject: [PATCH 01/26] Split cache step into two, always save cache --- composite/action.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/composite/action.yml b/composite/action.yml index 1cc72b06..fc96d258 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -175,8 +175,9 @@ runs: esac shell: bash - - name: Cache PIP Packages - uses: actions/cache@v3 + - name: Restore PIP packages cache + id: cache + uses: actions/cache/restore@v3 continue-on-error: true with: path: ${{ steps.os.outputs.pip-cache }} @@ -238,6 +239,14 @@ runs: LOG_LEVEL: ${{ inputs.log_level }} shell: bash + - name: Save PIP packages cache + uses: actions/cache/save@v3 + if: always() + continue-on-error: true + with: + path: ${{ steps.os.outputs.pip-cache }} + key: ${{ steps.cache.outputs.cache-primary-key }} + branding: icon: 'check-circle' color: 'green' From b2f032edb0636296ed95329d388a04db30e8158f Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Tue, 14 Mar 2023 14:29:46 +0100 Subject: [PATCH 02/26] Save only on cache-miss --- composite/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composite/action.yml b/composite/action.yml index fc96d258..6ea494a3 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -241,7 +241,7 @@ runs: - name: Save PIP packages cache uses: actions/cache/save@v3 - if: always() + if: always() && ! steps.cache.outputs.cache-hit continue-on-error: true with: path: ${{ steps.os.outputs.pip-cache }} From 2b6fa8a58bd92b7720be037a08bbfac44df04338 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Tue, 14 Mar 2023 14:50:34 +0100 Subject: [PATCH 03/26] Use path to composite action to hash files --- composite/action.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/composite/action.yml b/composite/action.yml index 6ea494a3..3fd142bf 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -132,6 +132,10 @@ outputs: runs: using: 'composite' steps: + - name: List files + run: find "$GITHUB_ACTION_PATH" + shell: bash + - name: Check for Python3 id: python run: | @@ -181,7 +185,7 @@ runs: continue-on-error: true with: path: ${{ steps.os.outputs.pip-cache }} - key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles('**/requirements.txt', 'composite/action.yml') }} + key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles('$GITHUB_ACTION_PATH/**/requirements.txt', '$GITHUB_ACTION_PATH/composite/action.yml') }} - name: Install Python dependencies run: | From f3d26d2d8b95308804c4d02d7b0a48a660460592 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Tue, 14 Mar 2023 14:51:23 +0100 Subject: [PATCH 04/26] Reduce test space to speedup testing --- .github/workflows/ci-cd.yml | 43 ------------------------------------- 1 file changed, 43 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 01f97b6e..4053af65 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -37,52 +37,9 @@ jobs: fail-fast: false matrix: os: - - macos-11 - - macos-12 - - macos-latest - - ubuntu-20.04 - - ubuntu-22.04 - ubuntu-latest - - windows-2019 - - windows-2022 - - windows-latest python-version: ["3.8"] - include: - - os: macos-latest - python-version: "3.11" - - os: ubuntu-latest - python-version: "3.11" - # installing lxml fails for Python 3.11 on Windows - - - os: macos-latest - python-version: "3.10" - - os: ubuntu-latest - python-version: "3.10" - - os: windows-latest - python-version: "3.10" - - - os: macos-latest - python-version: "3.9" - - os: ubuntu-latest - python-version: "3.9" - - os: windows-latest - python-version: "3.9" - - - os: macos-latest - python-version: "3.7" - - os: ubuntu-latest - python-version: "3.7" - - os: windows-latest - python-version: "3.7" - - - os: macos-latest - python-version: "3.6" - - os: ubuntu-20.04 - python-version: "3.6" - - os: windows-latest - python-version: "3.6" - steps: - name: Setup Ubuntu if: startsWith(matrix.os, 'ubuntu') From 39cb97af9c41a7d437ee5625a4d4446af3e17f48 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Tue, 14 Mar 2023 15:11:32 +0100 Subject: [PATCH 05/26] Fix path to hash files --- composite/action.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/composite/action.yml b/composite/action.yml index 3fd142bf..97d78c0f 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -132,10 +132,6 @@ outputs: runs: using: 'composite' steps: - - name: List files - run: find "$GITHUB_ACTION_PATH" - shell: bash - - name: Check for Python3 id: python run: | @@ -185,7 +181,7 @@ runs: continue-on-error: true with: path: ${{ steps.os.outputs.pip-cache }} - key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles('$GITHUB_ACTION_PATH/**/requirements.txt', '$GITHUB_ACTION_PATH/composite/action.yml') }} + key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles(format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH), format('{0}/action.yml', env.GITHUB_ACTION_PATH)) }} - name: Install Python dependencies run: | From b1ffd81c239ec9786687e4cad4d0ab6838dfb501 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Tue, 14 Mar 2023 19:46:09 +0100 Subject: [PATCH 06/26] Debug key expression --- composite/action.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/composite/action.yml b/composite/action.yml index 97d78c0f..9e98b5a5 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -156,11 +156,12 @@ runs: fi fi echo "version=$(python3 -V)" >> $GITHUB_OUTPUT + echo "$GITHUB_ACTION_PATH" echo '##[endgroup]' shell: bash - - name: Detect OS - id: os + - name: Configure + id: config run: | case "$RUNNER_OS" in Linux*) @@ -173,6 +174,19 @@ runs: echo "pip-cache=~\\AppData\\Local\\pip\\Cache" >> $GITHUB_OUTPUT ;; esac + echo "action-path=$GITHUB_ACTION_PATH" >> $GITHUB_OUTPUT + shell: bash + + - name: Debug + with: + env_debug: ${{ toJSON(env) }} + run: true + shell: bash + + - name: Debug 2 + with: + expr_debug: ${{ format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH) }} + run: true shell: bash - name: Restore PIP packages cache @@ -180,8 +194,8 @@ runs: uses: actions/cache/restore@v3 continue-on-error: true with: - path: ${{ steps.os.outputs.pip-cache }} - key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles(format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH), format('{0}/action.yml', env.GITHUB_ACTION_PATH)) }} + path: ${{ steps.config.outputs.pip-cache }} + key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles(format('{0}/../python/requirements.txt', steps.config.outputs.action-path), format('{0}/action.yml', steps.config.outputs.action-path)) }} - name: Install Python dependencies run: | @@ -244,7 +258,7 @@ runs: if: always() && ! steps.cache.outputs.cache-hit continue-on-error: true with: - path: ${{ steps.os.outputs.pip-cache }} + path: ${{ steps.config.outputs.pip-cache }} key: ${{ steps.cache.outputs.cache-primary-key }} branding: From 8c1adbf3790f576288f243beeef967bc50ba8cc5 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Tue, 14 Mar 2023 20:41:49 +0100 Subject: [PATCH 07/26] Debug yaml --- composite/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composite/action.yml b/composite/action.yml index 9e98b5a5..9dc6dec8 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -180,13 +180,13 @@ runs: - name: Debug with: env_debug: ${{ toJSON(env) }} - run: true + run: "true" shell: bash - name: Debug 2 with: expr_debug: ${{ format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH) }} - run: true + run: "true" shell: bash - name: Restore PIP packages cache @@ -195,7 +195,7 @@ runs: continue-on-error: true with: path: ${{ steps.config.outputs.pip-cache }} - key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles(format('{0}/../python/requirements.txt', steps.config.outputs.action-path), format('{0}/action.yml', steps.config.outputs.action-path)) }} + key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles('../python/requirements.txt', 'action.yml') }} - name: Install Python dependencies run: | From 2f75a52cf7d3979a850c8faa3ebf91a808c99bda Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Tue, 14 Mar 2023 20:45:29 +0100 Subject: [PATCH 08/26] Debug yaml --- composite/action.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/composite/action.yml b/composite/action.yml index 9dc6dec8..cd59da0b 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -177,18 +177,6 @@ runs: echo "action-path=$GITHUB_ACTION_PATH" >> $GITHUB_OUTPUT shell: bash - - name: Debug - with: - env_debug: ${{ toJSON(env) }} - run: "true" - shell: bash - - - name: Debug 2 - with: - expr_debug: ${{ format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH) }} - run: "true" - shell: bash - - name: Restore PIP packages cache id: cache uses: actions/cache/restore@v3 From a5f203ad387a2f70a19f6f1a590a797af4861c03 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Tue, 14 Mar 2023 20:46:13 +0100 Subject: [PATCH 09/26] Debug yaml --- composite/action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/composite/action.yml b/composite/action.yml index cd59da0b..92e29c21 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -177,6 +177,13 @@ runs: echo "action-path=$GITHUB_ACTION_PATH" >> $GITHUB_OUTPUT shell: bash + - name: Debug + with: + env_debug: ${{ toJSON(env) }} + run: | + true + shell: bash + - name: Restore PIP packages cache id: cache uses: actions/cache/restore@v3 From 9fd2ff689ecf8894bf9077924d1b5b24185ee48a Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Tue, 14 Mar 2023 20:46:33 +0100 Subject: [PATCH 10/26] Debug yaml --- composite/action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/composite/action.yml b/composite/action.yml index 92e29c21..8547aa4b 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -184,6 +184,13 @@ runs: true shell: bash + - name: Debug 2 + with: + expr_debug: ${{ format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH) }} + run: | + true + shell: bash + - name: Restore PIP packages cache id: cache uses: actions/cache/restore@v3 From 25e55d2dc47a568293a29b7cb0ff2daba9b40aca Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Tue, 14 Mar 2023 21:27:07 +0100 Subject: [PATCH 11/26] Debug yaml --- composite/action.yml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/composite/action.yml b/composite/action.yml index 8547aa4b..9af6bf05 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -157,6 +157,7 @@ runs: fi echo "version=$(python3 -V)" >> $GITHUB_OUTPUT echo "$GITHUB_ACTION_PATH" + echo "${{ format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH) }}" echo '##[endgroup]' shell: bash @@ -177,27 +178,13 @@ runs: echo "action-path=$GITHUB_ACTION_PATH" >> $GITHUB_OUTPUT shell: bash - - name: Debug - with: - env_debug: ${{ toJSON(env) }} - run: | - true - shell: bash - - - name: Debug 2 - with: - expr_debug: ${{ format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH) }} - run: | - true - shell: bash - - name: Restore PIP packages cache id: cache uses: actions/cache/restore@v3 continue-on-error: true with: path: ${{ steps.config.outputs.pip-cache }} - key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles('../python/requirements.txt', 'action.yml') }} + key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles(format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH), 'action.yml') }} - name: Install Python dependencies run: | From 31cd456485dd32be519872c7aaa2e744a3d71956 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Wed, 15 Mar 2023 10:29:26 +0100 Subject: [PATCH 12/26] Debug yaml --- composite/action.yml | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/composite/action.yml b/composite/action.yml index 9af6bf05..feb11ee4 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -161,6 +161,38 @@ runs: echo '##[endgroup]' shell: bash + - name: debug + continue-on-error: true + with: + value: ${{ format('{0}/../python/requirements.txt', 'abc') }} + run: | + true + shell: bash + + - name: debug 2 + continue-on-error: true + with: + value: ${{ format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH) }} + run: | + true + shell: bash + + - name: debug 3 + continue-on-error: true + with: + value: ${{ hashFiles(format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH)) }} + run: | + true + shell: bash + + - name: debug 4 + continue-on-error: true + with: + value: ${{ hashFiles(format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH), format('{0}/action.yml', env.GITHUB_ACTION_PATH)) }} + run: | + true + shell: bash + - name: Configure id: config run: | @@ -184,7 +216,7 @@ runs: continue-on-error: true with: path: ${{ steps.config.outputs.pip-cache }} - key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles(format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH), 'action.yml') }} + key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles(format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH), format('{0}/action.yml', env.GITHUB_ACTION_PATH)) }} - name: Install Python dependencies run: | From 414424f4efe036ee70ff9764f274d7ba02db0fbc Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Wed, 15 Mar 2023 10:55:27 +0100 Subject: [PATCH 13/26] Inject path via output --- composite/action.yml | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/composite/action.yml b/composite/action.yml index feb11ee4..aad29bfa 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -161,38 +161,6 @@ runs: echo '##[endgroup]' shell: bash - - name: debug - continue-on-error: true - with: - value: ${{ format('{0}/../python/requirements.txt', 'abc') }} - run: | - true - shell: bash - - - name: debug 2 - continue-on-error: true - with: - value: ${{ format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH) }} - run: | - true - shell: bash - - - name: debug 3 - continue-on-error: true - with: - value: ${{ hashFiles(format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH)) }} - run: | - true - shell: bash - - - name: debug 4 - continue-on-error: true - with: - value: ${{ hashFiles(format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH), format('{0}/action.yml', env.GITHUB_ACTION_PATH)) }} - run: | - true - shell: bash - - name: Configure id: config run: | @@ -211,12 +179,12 @@ runs: shell: bash - name: Restore PIP packages cache - id: cache uses: actions/cache/restore@v3 + id: cache continue-on-error: true with: path: ${{ steps.config.outputs.pip-cache }} - key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles(format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH), format('{0}/action.yml', env.GITHUB_ACTION_PATH)) }} + key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles(format('{0}/../python/requirements.txt', steps.config.outputs.action-path), format('{0}/action.yml', steps.config.outputs.action-path)) }} - name: Install Python dependencies run: | From 0945f03222d5d7893472441b48b050c623bab1ca Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Wed, 15 Mar 2023 11:03:14 +0100 Subject: [PATCH 14/26] Investigate content of action path --- composite/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/composite/action.yml b/composite/action.yml index aad29bfa..98f1c851 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -176,6 +176,8 @@ runs: ;; esac echo "action-path=$GITHUB_ACTION_PATH" >> $GITHUB_OUTPUT + echo "$GITHUB_ACTION_PATH" + find "$GITHUB_ACTION_PATH/.." shell: bash - name: Restore PIP packages cache From 8ca89f32a2ad08cdd5d1e2d0f26f75f406f4954c Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Wed, 15 Mar 2023 11:13:31 +0100 Subject: [PATCH 15/26] Parent dir .. is not allowed in hashFiles --- composite/action.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/composite/action.yml b/composite/action.yml index 98f1c851..b6d06f61 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -156,8 +156,6 @@ runs: fi fi echo "version=$(python3 -V)" >> $GITHUB_OUTPUT - echo "$GITHUB_ACTION_PATH" - echo "${{ format('{0}/../python/requirements.txt', env.GITHUB_ACTION_PATH) }}" echo '##[endgroup]' shell: bash @@ -175,9 +173,7 @@ runs: echo "pip-cache=~\\AppData\\Local\\pip\\Cache" >> $GITHUB_OUTPUT ;; esac - echo "action-path=$GITHUB_ACTION_PATH" >> $GITHUB_OUTPUT - echo "$GITHUB_ACTION_PATH" - find "$GITHUB_ACTION_PATH/.." + echo "action-path=$(dirname "$GITHUB_ACTION_PATH")" >> $GITHUB_OUTPUT shell: bash - name: Restore PIP packages cache @@ -186,7 +182,7 @@ runs: continue-on-error: true with: path: ${{ steps.config.outputs.pip-cache }} - key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles(format('{0}/../python/requirements.txt', steps.config.outputs.action-path), format('{0}/action.yml', steps.config.outputs.action-path)) }} + key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles(format('{0}/python/requirements.txt', steps.config.outputs.action-path), format('{0}/composite/action.yml', steps.config.outputs.action-path)) }} - name: Install Python dependencies run: | From dea52adb0565e4f5982a93d125aa468295d989ba Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Wed, 15 Mar 2023 13:17:54 +0100 Subject: [PATCH 16/26] hashFiles does not like . either --- composite/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composite/action.yml b/composite/action.yml index b6d06f61..30837cf3 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -173,7 +173,7 @@ runs: echo "pip-cache=~\\AppData\\Local\\pip\\Cache" >> $GITHUB_OUTPUT ;; esac - echo "action-path=$(dirname "$GITHUB_ACTION_PATH")" >> $GITHUB_OUTPUT + echo "action-path=$(cd "$GITHUB_ACTION_PATH"; cd ..; pwd)" >> $GITHUB_OUTPUT shell: bash - name: Restore PIP packages cache From c71661094654cebe567641035ec577b1d1ddbec1 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Wed, 15 Mar 2023 15:21:23 +0100 Subject: [PATCH 17/26] Revert "Reduce test space to speedup testing" This reverts commit f3d26d2d8b95308804c4d02d7b0a48a660460592. --- .github/workflows/ci-cd.yml | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 4053af65..01f97b6e 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -37,9 +37,52 @@ jobs: fail-fast: false matrix: os: + - macos-11 + - macos-12 + - macos-latest + - ubuntu-20.04 + - ubuntu-22.04 - ubuntu-latest + - windows-2019 + - windows-2022 + - windows-latest python-version: ["3.8"] + include: + - os: macos-latest + python-version: "3.11" + - os: ubuntu-latest + python-version: "3.11" + # installing lxml fails for Python 3.11 on Windows + + - os: macos-latest + python-version: "3.10" + - os: ubuntu-latest + python-version: "3.10" + - os: windows-latest + python-version: "3.10" + + - os: macos-latest + python-version: "3.9" + - os: ubuntu-latest + python-version: "3.9" + - os: windows-latest + python-version: "3.9" + + - os: macos-latest + python-version: "3.7" + - os: ubuntu-latest + python-version: "3.7" + - os: windows-latest + python-version: "3.7" + + - os: macos-latest + python-version: "3.6" + - os: ubuntu-20.04 + python-version: "3.6" + - os: windows-latest + python-version: "3.6" + steps: - name: Setup Ubuntu if: startsWith(matrix.os, 'ubuntu') From 7dd29b2987b1693b418ba1c6fa89b0a324ebdde5 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Wed, 15 Mar 2023 15:25:07 +0100 Subject: [PATCH 18/26] Save cache on success and failure, not always --- composite/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composite/action.yml b/composite/action.yml index 30837cf3..c29fc85c 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -242,7 +242,7 @@ runs: - name: Save PIP packages cache uses: actions/cache/save@v3 - if: always() && ! steps.cache.outputs.cache-hit + if: ( success() || failure() ) && ! steps.cache.outputs.cache-hit continue-on-error: true with: path: ${{ steps.config.outputs.pip-cache }} From 9f163042f109c60b1d0e741c69a3895a90368303 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Wed, 15 Mar 2023 19:26:51 +0100 Subject: [PATCH 19/26] Debug env --- composite/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/composite/action.yml b/composite/action.yml index c29fc85c..90db3f59 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -174,6 +174,7 @@ runs: ;; esac echo "action-path=$(cd "$GITHUB_ACTION_PATH"; cd ..; pwd)" >> $GITHUB_OUTPUT + env shell: bash - name: Restore PIP packages cache From 5caa81777fa225626d45fbe3de026cd965df58bd Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Wed, 15 Mar 2023 19:28:24 +0100 Subject: [PATCH 20/26] List action path --- composite/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/composite/action.yml b/composite/action.yml index 90db3f59..5eca3192 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -174,6 +174,7 @@ runs: ;; esac echo "action-path=$(cd "$GITHUB_ACTION_PATH"; cd ..; pwd)" >> $GITHUB_OUTPUT + find "$GITHUB_ACTION_PATH/.." env shell: bash From f5f5603816c5a05ba8adf0db650ba1ea746c9667 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Thu, 16 Mar 2023 15:25:20 +0100 Subject: [PATCH 21/26] Debug hashed files --- composite/action.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/composite/action.yml b/composite/action.yml index 5eca3192..8b5a9152 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -178,6 +178,12 @@ runs: env shell: bash + - name: Ls hashed files + run: | + ls -lah "${{ format('{0}/python/requirements.txt', steps.config.outputs.action-path) }}" + ls -lah "${{ format('{0}/composite/action.yml', steps.config.outputs.action-path) }}" + shell: bash + - name: Restore PIP packages cache uses: actions/cache/restore@v3 id: cache From 1781604b0b33afa277c3fb7338a5198d7421864c Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Thu, 16 Mar 2023 15:29:57 +0100 Subject: [PATCH 22/26] Debug hash --- composite/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/composite/action.yml b/composite/action.yml index 8b5a9152..838f0223 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -182,6 +182,8 @@ runs: run: | ls -lah "${{ format('{0}/python/requirements.txt', steps.config.outputs.action-path) }}" ls -lah "${{ format('{0}/composite/action.yml', steps.config.outputs.action-path) }}" + ls -lah '/home/runner/work/_actions/EnricoMi/publish-unit-test-result-action/branch-composite-cache-pip-packages-2/python/requirements.txt' '/home/runner/work/_actions/EnricoMi/publish-unit-test-result-action/branch-composite-cache-pip-packages-2/composite/action.yml' + echo ${{ hashFiles('/home/runner/work/_actions/EnricoMi/publish-unit-test-result-action/branch-composite-cache-pip-packages-2/python/requirements.txt', '/home/runner/work/_actions/EnricoMi/publish-unit-test-result-action/branch-composite-cache-pip-packages-2/composite/action.yml') }} shell: bash - name: Restore PIP packages cache From b33cf99077d0f680deceee09e238b8db847d0e4c Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Thu, 16 Mar 2023 15:40:48 +0100 Subject: [PATCH 23/26] More debug --- composite/action.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composite/action.yml b/composite/action.yml index 838f0223..0db6f0b7 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -175,6 +175,7 @@ runs: esac echo "action-path=$(cd "$GITHUB_ACTION_PATH"; cd ..; pwd)" >> $GITHUB_OUTPUT find "$GITHUB_ACTION_PATH/.." + touch file env shell: bash @@ -183,7 +184,9 @@ runs: ls -lah "${{ format('{0}/python/requirements.txt', steps.config.outputs.action-path) }}" ls -lah "${{ format('{0}/composite/action.yml', steps.config.outputs.action-path) }}" ls -lah '/home/runner/work/_actions/EnricoMi/publish-unit-test-result-action/branch-composite-cache-pip-packages-2/python/requirements.txt' '/home/runner/work/_actions/EnricoMi/publish-unit-test-result-action/branch-composite-cache-pip-packages-2/composite/action.yml' - echo ${{ hashFiles('/home/runner/work/_actions/EnricoMi/publish-unit-test-result-action/branch-composite-cache-pip-packages-2/python/requirements.txt', '/home/runner/work/_actions/EnricoMi/publish-unit-test-result-action/branch-composite-cache-pip-packages-2/composite/action.yml') }} + echo "hash: ${{ hashFiles('/home/runner/work/_actions/EnricoMi/publish-unit-test-result-action/branch-composite-cache-pip-packages-2/python/requirements.txt', '/home/runner/work/_actions/EnricoMi/publish-unit-test-result-action/branch-composite-cache-pip-packages-2/composite/action.yml') }}" + ls -lah file + echo "hash: ${{ hashFiles('file') }}" shell: bash - name: Restore PIP packages cache From 5051b23a3e0708c1c0cb9c57708cbca59ec47ac6 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Thu, 16 Mar 2023 16:05:57 +0100 Subject: [PATCH 24/26] Scratch hashFiles, does not work for file in composite action path --- composite/action.yml | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/composite/action.yml b/composite/action.yml index 0db6f0b7..54bf884f 100644 --- a/composite/action.yml +++ b/composite/action.yml @@ -159,8 +159,8 @@ runs: echo '##[endgroup]' shell: bash - - name: Configure - id: config + - name: Detect OS + id: os run: | case "$RUNNER_OS" in Linux*) @@ -173,20 +173,6 @@ runs: echo "pip-cache=~\\AppData\\Local\\pip\\Cache" >> $GITHUB_OUTPUT ;; esac - echo "action-path=$(cd "$GITHUB_ACTION_PATH"; cd ..; pwd)" >> $GITHUB_OUTPUT - find "$GITHUB_ACTION_PATH/.." - touch file - env - shell: bash - - - name: Ls hashed files - run: | - ls -lah "${{ format('{0}/python/requirements.txt', steps.config.outputs.action-path) }}" - ls -lah "${{ format('{0}/composite/action.yml', steps.config.outputs.action-path) }}" - ls -lah '/home/runner/work/_actions/EnricoMi/publish-unit-test-result-action/branch-composite-cache-pip-packages-2/python/requirements.txt' '/home/runner/work/_actions/EnricoMi/publish-unit-test-result-action/branch-composite-cache-pip-packages-2/composite/action.yml' - echo "hash: ${{ hashFiles('/home/runner/work/_actions/EnricoMi/publish-unit-test-result-action/branch-composite-cache-pip-packages-2/python/requirements.txt', '/home/runner/work/_actions/EnricoMi/publish-unit-test-result-action/branch-composite-cache-pip-packages-2/composite/action.yml') }}" - ls -lah file - echo "hash: ${{ hashFiles('file') }}" shell: bash - name: Restore PIP packages cache @@ -194,8 +180,8 @@ runs: id: cache continue-on-error: true with: - path: ${{ steps.config.outputs.pip-cache }} - key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-${{ hashFiles(format('{0}/python/requirements.txt', steps.config.outputs.action-path), format('{0}/composite/action.yml', steps.config.outputs.action-path)) }} + path: ${{ steps.os.outputs.pip-cache }} + key: enricomi-publish-action-${{ runner.os }}-${{ runner.arch }}-pip-${{ steps.python.outputs.version }}-f3f2c295046c91ed612b4efb6c9fb352 - name: Install Python dependencies run: | @@ -258,7 +244,7 @@ runs: if: ( success() || failure() ) && ! steps.cache.outputs.cache-hit continue-on-error: true with: - path: ${{ steps.config.outputs.pip-cache }} + path: ${{ steps.os.outputs.pip-cache }} key: ${{ steps.cache.outputs.cache-primary-key }} branding: From 7b5508852a86f291eb8df7dfaa9cd16c4633c8e7 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Thu, 16 Mar 2023 16:17:26 +0100 Subject: [PATCH 25/26] Check cache hash is up-to-date in unit test --- python/test/test_action_yml.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python/test/test_action_yml.py b/python/test/test_action_yml.py index b8fc9cec..d016858d 100644 --- a/python/test/test_action_yml.py +++ b/python/test/test_action_yml.py @@ -1,3 +1,4 @@ +import hashlib import pathlib import unittest @@ -28,6 +29,15 @@ def test_composite_action(self): self.assertEqual(dockerfile_action_wo_runs, composite_action_wo_runs) self.assertIn(('using', 'composite'), composite_action.get('runs', {}).items()) + # check cache key hash is up-to-date in composite action + with open(project_root / 'python' / 'requirements.txt', mode='rb') as r: + expected_hash = hashlib.md5(r.read()).hexdigest() + cache_hash = next(step.get('with', {}).get('key', '').split('-')[-1] + for step in composite_action.get('runs', {}).get('steps', []) + if step.get('uses', '').startswith('actions/cache/restore@')) + self.assertEqual(expected_hash, cache_hash, msg='Changing python/requirements.txt requires ' + 'to update the MD5 hash in composite/action.yaml') + def test_composite_inputs(self): with open(project_root / 'composite/action.yml', encoding='utf-8') as r: action = yaml.safe_load(r) From 3b245f4efe70fd48ff98aa88ae3d274e54609bb4 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Thu, 16 Mar 2023 18:12:25 +0100 Subject: [PATCH 26/26] Skip the cache hash check on Windows --- python/test/test_action_yml.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/python/test/test_action_yml.py b/python/test/test_action_yml.py index d016858d..d700f27b 100644 --- a/python/test/test_action_yml.py +++ b/python/test/test_action_yml.py @@ -1,5 +1,6 @@ import hashlib import pathlib +import sys import unittest import yaml @@ -30,13 +31,15 @@ def test_composite_action(self): self.assertIn(('using', 'composite'), composite_action.get('runs', {}).items()) # check cache key hash is up-to-date in composite action - with open(project_root / 'python' / 'requirements.txt', mode='rb') as r: - expected_hash = hashlib.md5(r.read()).hexdigest() - cache_hash = next(step.get('with', {}).get('key', '').split('-')[-1] - for step in composite_action.get('runs', {}).get('steps', []) - if step.get('uses', '').startswith('actions/cache/restore@')) - self.assertEqual(expected_hash, cache_hash, msg='Changing python/requirements.txt requires ' - 'to update the MD5 hash in composite/action.yaml') + # this md5 is linux-based (on Windows, git uses different newlines, which changes the hash) + if sys.platform != 'win32': + with open(project_root / 'python' / 'requirements.txt', mode='rb') as r: + expected_hash = hashlib.md5(r.read()).hexdigest() + cache_hash = next(step.get('with', {}).get('key', '').split('-')[-1] + for step in composite_action.get('runs', {}).get('steps', []) + if step.get('uses', '').startswith('actions/cache/restore@')) + self.assertEqual(expected_hash, cache_hash, msg='Changing python/requirements.txt requires ' + 'to update the MD5 hash in composite/action.yaml') def test_composite_inputs(self): with open(project_root / 'composite/action.yml', encoding='utf-8') as r: