fix github cache in workflow

This commit is contained in:
Ulf Gebhardt 2023-07-18 17:39:50 +02:00
parent 3dab3c2faa
commit a9835288e2
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
3 changed files with 15 additions and 31 deletions

View File

@ -10,7 +10,6 @@ jobs:
outputs:
backend: ${{ steps.changes.outputs.backend }}
docker: ${{ steps.changes.outputs.docker }}
pr-number: ${{ steps.pr.outputs.number }}
steps:
- uses: actions/checkout@v3.3.0
@ -22,10 +21,6 @@ jobs:
filters: .github/file-filters.yml
list-files: shell
- name: Get pr number
id: pr
uses: 8BitJonny/gh-get-current-pr@2.2.0
build_test_neo4j:
name: Docker Build Test - Neo4J
if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.docker == 'true'
@ -45,7 +40,7 @@ jobs:
uses: actions/cache/save@v3.3.1
with:
path: /tmp/neo4j.tar
key: backend-neo4j-cache-pr${{ needs.files-changed.outputs.pr-number }}
key: backend-neo4j-cache-${{ GITHUB_RUN_NUMBER }}
build_test_backend:
name: Docker Build Test - Backend
@ -66,7 +61,7 @@ jobs:
uses: actions/cache/save@v3.3.1
with:
path: /tmp/backend.tar
key: backend-cache-pr${{ needs.files-changed.outputs.pr-number }}
key: backend-cache-${{ GITHUB_RUN_NUMBER }}
lint_backend:
name: Lint Backend
@ -95,14 +90,14 @@ jobs:
uses: actions/cache/restore@v3.3.1
with:
path: /tmp/neo4j.tar
key: backend-neo4j-cache-pr${{ needs.files-changed.outputs.pr-number }}
key: backend-neo4j-cache-${{ GITHUB_RUN_NUMBER }}
fail-on-cache-miss: true
- name: Restore Backend cache
uses: actions/cache/restore@v3.3.1
with:
path: /tmp/backend.tar
key: backend-cache-pr${{ needs.files-changed.outputs.pr-number }}
key: backend-cache-${{ GITHUB_RUN_NUMBER }}
fail-on-cache-miss: true
- name: Load Docker Images
@ -132,14 +127,14 @@ jobs:
if: always()
needs: [files-changed, unit_test_backend]
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Delete cache
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh extension install actions/gh-actions-cache
set +e
KEY="backend-neo4j-cache-pr${{ needs.files-changed.outputs.pr-number }}"
KEY="backend-neo4j-cache-${{ GITHUB_RUN_NUMBER }}"
gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm
KEY="backend-cache-pr${{ needs.files-changed.outputs.pr-number }}"
KEY="backend-cache-${{ GITHUB_RUN_NUMBER }}"
gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm

View File

@ -5,8 +5,6 @@ jobs:
docker_preparation:
name: Fullstack test preparation
runs-on: ubuntu-latest
outputs:
pr-number: ${{ steps.pr.outputs.number }}
steps:
- name: Checkout code
uses: actions/checkout@v3
@ -34,10 +32,6 @@ jobs:
yarn build
cd ..
yarn install
- name: Get pr number
id: pr
uses: 8BitJonny/gh-get-current-pr@2.2.0
- name: Cache docker images
id: cache
@ -48,7 +42,7 @@ jobs:
/home/runner/.cache/Cypress
/home/runner/work/Ocelot-Social/Ocelot-Social
/tmp/images/
key: e2e-preparation-cache-pr${{ steps.pr.outputs.number }}
key: e2e-preparation-cache-${{ GITHUB_RUN_NUMBER }}
fullstack_tests:
name: Fullstack tests
@ -71,7 +65,7 @@ jobs:
/home/runner/.cache/Cypress
/home/runner/work/Ocelot-Social/Ocelot-Social
/tmp/images/
key: e2e-preparation-cache-pr${{ needs.docker_preparation.outputs.pr-number }}
key: e2e-preparation-cache-${{ GITHUB_RUN_NUMBER }}
fail-on-cache-miss: true
- name: Boot up test system | docker-compose
@ -107,12 +101,12 @@ jobs:
if: always()
needs: [docker_preparation, fullstack_tests]
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Delete cache
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh extension install actions/gh-actions-cache
set +e
KEY="e2e-preparation-cache-pr${{ needs.docker_preparation.outputs.pr-number }}"
KEY="e2e-preparation-cache-${{ GITHUB_RUN_NUMBER }}"
gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm

View File

@ -9,7 +9,6 @@ jobs:
runs-on: ubuntu-latest
outputs:
docker: ${{ steps.changes.outputs.docker }}
pr-number: ${{ steps.pr.outputs.number }}
webapp: ${{ steps.changes.outputs.webapp }}
steps:
- uses: actions/checkout@v3.3.0
@ -22,10 +21,6 @@ jobs:
filters: .github/file-filters.yml
list-files: shell
- name: Get pr number
id: pr
uses: 8BitJonny/gh-get-current-pr@2.2.0
prepare:
name: Prepare
if: needs.files-changed.outputs.webapp == 'true'
@ -58,7 +53,7 @@ jobs:
uses: actions/cache/save@v3.3.1
with:
path: /tmp/webapp.tar
key: webapp-cache-pr${{ needs.files-changed.outputs.pr-number }}
key: webapp-cache-${{ GITHUB_RUN_NUMBER }}
lint_webapp:
name: Lint Webapp
@ -87,7 +82,7 @@ jobs:
uses: actions/cache/restore@v3.3.1
with:
path: /tmp/webapp.tar
key: webapp-cache-pr${{ needs.files-changed.outputs.pr-number }}
key: webapp-cache-${{ GITHUB_RUN_NUMBER }}
- name: Load Docker Image
run: docker load < /tmp/webapp.tar
@ -108,13 +103,13 @@ jobs:
if: always()
needs: [files-changed, unit_test_webapp]
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Delete cache
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh extension install actions/gh-actions-cache
set +e
KEY="webapp-cache-pr${{ needs.files-changed.outputs.pr-number }}"
KEY="webapp-cache-${{ GITHUB_RUN_NUMBER }}"
gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm