From a43ae63beb26178a3c85e4afdb825959a65504cd Mon Sep 17 00:00:00 2001
From: Val Lorentz <progval+github@progval.net>
Date: Mon, 9 Aug 2021 20:42:36 +0200
Subject: [PATCH] Fix CI cache (#92)

it didn't work so far because you can't use variable in the path...
---
 .github/workflows/test-devel.yml         | 49 +++++++++++++-------
 .github/workflows/test-devel_release.yml |  9 ++++
 .github/workflows/test-stable.yml        | 59 ++++++++++++++++--------
 make_workflows.py                        | 12 ++++-
 4 files changed, 91 insertions(+), 38 deletions(-)

diff --git a/.github/workflows/test-devel.yml b/.github/workflows/test-devel.yml
index 2c6c4aa..01c8812 100644
--- a/.github/workflows/test-devel.yml
+++ b/.github/workflows/test-devel.yml
@@ -8,6 +8,15 @@ jobs:
     - uses: actions/checkout@v2
     - name: Create directories
       run: cd ~/; mkdir -p .local/ go/
+    - name: Cache Anope
+      uses: actions/cache@v2
+      with:
+        key: 3-${{ runner.os }}-anope-2.0.9
+        path: '~/.cache
+
+          ${{ github.workspace }}/anope
+
+          '
     - name: Checkout Anope
       uses: actions/checkout@v2
       with:
@@ -37,10 +46,12 @@ jobs:
     - name: Cache dependencies
       uses: actions/cache@v2
       with:
-        key: ${{ runner.os }}-hybrid-devel
-        path: |-
-          ~/.cache
-          $GITHUB_WORKSPACE/ircd-hybrid
+        key: 3-${{ runner.os }}-hybrid-devel
+        path: '~/.cache
+
+          ${ github.workspace }/ircd-hybrid
+
+          '
     - uses: actions/checkout@v2
     - name: Set up Python 3.7
       uses: actions/setup-python@v2
@@ -105,10 +116,12 @@ jobs:
     - name: Cache dependencies
       uses: actions/cache@v2
       with:
-        key: ${{ runner.os }}-plexus4-devel
-        path: |-
-          ~/.cache
-          $GITHUB_WORKSPACE/placeholder
+        key: 3-${{ runner.os }}-plexus4-devel
+        path: '~/.cache
+
+          ${ github.workspace }/placeholder
+
+          '
     - uses: actions/checkout@v2
     - name: Set up Python 3.7
       uses: actions/setup-python@v2
@@ -145,10 +158,12 @@ jobs:
     - name: Cache dependencies
       uses: actions/cache@v2
       with:
-        key: ${{ runner.os }}-solanum-devel
-        path: |-
-          ~/.cache
-          $GITHUB_WORKSPACE/solanum
+        key: 3-${{ runner.os }}-solanum-devel
+        path: '~/.cache
+
+          ${ github.workspace }/solanum
+
+          '
     - uses: actions/checkout@v2
     - name: Set up Python 3.7
       uses: actions/setup-python@v2
@@ -183,10 +198,12 @@ jobs:
     - name: Cache dependencies
       uses: actions/cache@v2
       with:
-        key: ${{ runner.os }}-unrealircd-devel
-        path: |-
-          ~/.cache
-          $GITHUB_WORKSPACE/unrealircd
+        key: 3-${{ runner.os }}-unrealircd-devel
+        path: '~/.cache
+
+          ${ github.workspace }/unrealircd
+
+          '
     - uses: actions/checkout@v2
     - name: Set up Python 3.7
       uses: actions/setup-python@v2
diff --git a/.github/workflows/test-devel_release.yml b/.github/workflows/test-devel_release.yml
index 526caff..ced3b9c 100644
--- a/.github/workflows/test-devel_release.yml
+++ b/.github/workflows/test-devel_release.yml
@@ -8,6 +8,15 @@ jobs:
     - uses: actions/checkout@v2
     - name: Create directories
       run: cd ~/; mkdir -p .local/ go/
+    - name: Cache Anope
+      uses: actions/cache@v2
+      with:
+        key: 3-${{ runner.os }}-anope-2.0.9
+        path: '~/.cache
+
+          ${{ github.workspace }}/anope
+
+          '
     - name: Checkout Anope
       uses: actions/checkout@v2
       with:
diff --git a/.github/workflows/test-stable.yml b/.github/workflows/test-stable.yml
index 7e35210..31963b8 100644
--- a/.github/workflows/test-stable.yml
+++ b/.github/workflows/test-stable.yml
@@ -8,6 +8,15 @@ jobs:
     - uses: actions/checkout@v2
     - name: Create directories
       run: cd ~/; mkdir -p .local/ go/
+    - name: Cache Anope
+      uses: actions/cache@v2
+      with:
+        key: 3-${{ runner.os }}-anope-2.0.9
+        path: '~/.cache
+
+          ${{ github.workspace }}/anope
+
+          '
     - name: Checkout Anope
       uses: actions/checkout@v2
       with:
@@ -37,10 +46,12 @@ jobs:
     - name: Cache dependencies
       uses: actions/cache@v2
       with:
-        key: ${{ runner.os }}-charybdis-stable
-        path: |-
-          ~/.cache
-          $GITHUB_WORKSPACE/charybdis
+        key: 3-${{ runner.os }}-charybdis-stable
+        path: '~/.cache
+
+          ${ github.workspace }/charybdis
+
+          '
     - uses: actions/checkout@v2
     - name: Set up Python 3.7
       uses: actions/setup-python@v2
@@ -75,10 +86,12 @@ jobs:
     - name: Cache dependencies
       uses: actions/cache@v2
       with:
-        key: ${{ runner.os }}-hybrid-stable
-        path: |-
-          ~/.cache
-          $GITHUB_WORKSPACE/ircd-hybrid
+        key: 3-${{ runner.os }}-hybrid-stable
+        path: '~/.cache
+
+          ${ github.workspace }/ircd-hybrid
+
+          '
     - uses: actions/checkout@v2
     - name: Set up Python 3.7
       uses: actions/setup-python@v2
@@ -143,10 +156,12 @@ jobs:
     - name: Cache dependencies
       uses: actions/cache@v2
       with:
-        key: ${{ runner.os }}-plexus4-stable
-        path: |-
-          ~/.cache
-          $GITHUB_WORKSPACE/placeholder
+        key: 3-${{ runner.os }}-plexus4-stable
+        path: '~/.cache
+
+          ${ github.workspace }/placeholder
+
+          '
     - uses: actions/checkout@v2
     - name: Set up Python 3.7
       uses: actions/setup-python@v2
@@ -183,10 +198,12 @@ jobs:
     - name: Cache dependencies
       uses: actions/cache@v2
       with:
-        key: ${{ runner.os }}-solanum-stable
-        path: |-
-          ~/.cache
-          $GITHUB_WORKSPACE/solanum
+        key: 3-${{ runner.os }}-solanum-stable
+        path: '~/.cache
+
+          ${ github.workspace }/solanum
+
+          '
     - uses: actions/checkout@v2
     - name: Set up Python 3.7
       uses: actions/setup-python@v2
@@ -221,10 +238,12 @@ jobs:
     - name: Cache dependencies
       uses: actions/cache@v2
       with:
-        key: ${{ runner.os }}-unrealircd-stable
-        path: |-
-          ~/.cache
-          $GITHUB_WORKSPACE/unrealircd
+        key: 3-${{ runner.os }}-unrealircd-stable
+        path: '~/.cache
+
+          ${ github.workspace }/unrealircd
+
+          '
     - uses: actions/checkout@v2
     - name: Set up Python 3.7
       uses: actions/setup-python@v2
diff --git a/make_workflows.py b/make_workflows.py
index eb716a2..2a78a59 100644
--- a/make_workflows.py
+++ b/make_workflows.py
@@ -96,8 +96,8 @@ def get_build_job(*, software_config, software_id, version_flavor):
                 "name": "Cache dependencies",
                 "uses": "actions/cache@v2",
                 "with": {
-                    "path": script("~/.cache", f"$GITHUB_WORKSPACE/{path}"),
-                    "key": "${{ runner.os }}-"
+                    "path": f"~/.cache\n${{ github.workspace }}/{path}\n",
+                    "key": "3-${{ runner.os }}-"
                     + software_id
                     + "-"
                     + version_flavor.value,
@@ -249,6 +249,14 @@ def get_build_job_anope():
                 "name": "Create directories",
                 "run": "cd ~/; mkdir -p .local/ go/",
             },
+            {
+                "name": "Cache Anope",
+                "uses": "actions/cache@v2",
+                "with": {
+                    "path": "~/.cache\n${{ github.workspace }}/anope\n",
+                    "key": "3-${{ runner.os }}-anope-2.0.9",
+                },
+            },
             {
                 "name": "Checkout Anope",
                 "uses": "actions/checkout@v2",