mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge pull request #6604 from Ocelot-Social-Community/fix-runner
fix(other): github cache in workflow
This commit is contained in:
commit
4d703586f4
42
.github/workflows/cleanup-cache-at-pr-closing.yml
vendored
Normal file
42
.github/workflows/cleanup-cache-at-pr-closing.yml
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
###############################################################################
|
||||||
|
# A Github repo has max 10 GB of cache.
|
||||||
|
# https://github.blog/changelog/2021-11-23-github-actions-cache-size-is-now-increased-to-10gb-per-repository/
|
||||||
|
#
|
||||||
|
# To avoid "cache thrashing" by their cache eviction policy it is recommended
|
||||||
|
# to apply a cache cleanup workflow at PR closing to dele cache leftovers of
|
||||||
|
# the current branch:
|
||||||
|
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
name: ocelot.social cache cleanup on pr closing
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- closed
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
clean-branch-cache:
|
||||||
|
name: Cleanup branch cache
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Cleanup
|
||||||
|
run: |
|
||||||
|
gh extension install actions/gh-actions-cache
|
||||||
|
REPO=${{ github.repository }}
|
||||||
|
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
|
||||||
|
echo "Fetching list of cache key"
|
||||||
|
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
|
||||||
|
set +e
|
||||||
|
echo "Deleting caches..."
|
||||||
|
for cacheKey in $cacheKeysForPR
|
||||||
|
do
|
||||||
|
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
|
||||||
|
done
|
||||||
|
echo "Done"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
23
.github/workflows/test-backend.yml
vendored
23
.github/workflows/test-backend.yml
vendored
@ -1,7 +1,7 @@
|
|||||||
name: ocelot.social backend test CI
|
name: ocelot.social backend test CI
|
||||||
|
|
||||||
|
|
||||||
on: [push]
|
on: push
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
files-changed:
|
files-changed:
|
||||||
@ -10,7 +10,6 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
backend: ${{ steps.changes.outputs.backend }}
|
backend: ${{ steps.changes.outputs.backend }}
|
||||||
docker: ${{ steps.changes.outputs.docker }}
|
docker: ${{ steps.changes.outputs.docker }}
|
||||||
pr-number: ${{ steps.pr.outputs.number }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.3.0
|
- uses: actions/checkout@v3.3.0
|
||||||
|
|
||||||
@ -22,10 +21,6 @@ jobs:
|
|||||||
filters: .github/file-filters.yml
|
filters: .github/file-filters.yml
|
||||||
list-files: shell
|
list-files: shell
|
||||||
|
|
||||||
- name: Get pr number
|
|
||||||
id: pr
|
|
||||||
uses: 8BitJonny/gh-get-current-pr@2.2.0
|
|
||||||
|
|
||||||
build_test_neo4j:
|
build_test_neo4j:
|
||||||
name: Docker Build Test - Neo4J
|
name: Docker Build Test - Neo4J
|
||||||
if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.docker == 'true'
|
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
|
uses: actions/cache/save@v3.3.1
|
||||||
with:
|
with:
|
||||||
path: /tmp/neo4j.tar
|
path: /tmp/neo4j.tar
|
||||||
key: backend-neo4j-cache-pr${{ needs.files-changed.outputs.pr-number }}
|
key: ${{ github.run_id }}-backend-neo4j-cache
|
||||||
|
|
||||||
build_test_backend:
|
build_test_backend:
|
||||||
name: Docker Build Test - Backend
|
name: Docker Build Test - Backend
|
||||||
@ -66,7 +61,7 @@ jobs:
|
|||||||
uses: actions/cache/save@v3.3.1
|
uses: actions/cache/save@v3.3.1
|
||||||
with:
|
with:
|
||||||
path: /tmp/backend.tar
|
path: /tmp/backend.tar
|
||||||
key: backend-cache-pr${{ needs.files-changed.outputs.pr-number }}
|
key: ${{ github.run_id }}-backend-cache
|
||||||
|
|
||||||
lint_backend:
|
lint_backend:
|
||||||
name: Lint Backend
|
name: Lint Backend
|
||||||
@ -95,14 +90,14 @@ jobs:
|
|||||||
uses: actions/cache/restore@v3.3.1
|
uses: actions/cache/restore@v3.3.1
|
||||||
with:
|
with:
|
||||||
path: /tmp/neo4j.tar
|
path: /tmp/neo4j.tar
|
||||||
key: backend-neo4j-cache-pr${{ needs.files-changed.outputs.pr-number }}
|
key: ${{ github.run_id }}-backend-neo4j-cache
|
||||||
fail-on-cache-miss: true
|
fail-on-cache-miss: true
|
||||||
|
|
||||||
- name: Restore Backend cache
|
- name: Restore Backend cache
|
||||||
uses: actions/cache/restore@v3.3.1
|
uses: actions/cache/restore@v3.3.1
|
||||||
with:
|
with:
|
||||||
path: /tmp/backend.tar
|
path: /tmp/backend.tar
|
||||||
key: backend-cache-pr${{ needs.files-changed.outputs.pr-number }}
|
key: ${{ github.run_id }}-backend-cache
|
||||||
fail-on-cache-miss: true
|
fail-on-cache-miss: true
|
||||||
|
|
||||||
- name: Load Docker Images
|
- name: Load Docker Images
|
||||||
@ -129,17 +124,17 @@ jobs:
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
name: Cleanup
|
name: Cleanup
|
||||||
if: always()
|
if: ${{ needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.docker == 'true' }}
|
||||||
needs: [files-changed, unit_test_backend]
|
needs: [files-changed, unit_test_backend]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
steps:
|
steps:
|
||||||
- name: Delete cache
|
- name: Delete cache
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
gh extension install actions/gh-actions-cache
|
gh extension install actions/gh-actions-cache
|
||||||
set +e
|
KEY="${{ github.run_id }}-backend-neo4j-cache"
|
||||||
KEY="backend-neo4j-cache-pr${{ needs.files-changed.outputs.pr-number }}"
|
|
||||||
gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm
|
gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm
|
||||||
KEY="backend-cache-pr${{ needs.files-changed.outputs.pr-number }}"
|
KEY="${{ github.run_id }}-backend-cache"
|
||||||
gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm
|
gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm
|
||||||
|
|||||||
16
.github/workflows/test-e2e.yml
vendored
16
.github/workflows/test-e2e.yml
vendored
@ -1,12 +1,11 @@
|
|||||||
name: ocelot.social end-to-end test CI
|
name: ocelot.social end-to-end test CI
|
||||||
|
|
||||||
on: push
|
on: push
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker_preparation:
|
docker_preparation:
|
||||||
name: Fullstack test preparation
|
name: Fullstack test preparation
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
|
||||||
pr-number: ${{ steps.pr.outputs.number }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@ -34,10 +33,6 @@ jobs:
|
|||||||
yarn build
|
yarn build
|
||||||
cd ..
|
cd ..
|
||||||
yarn install
|
yarn install
|
||||||
|
|
||||||
- name: Get pr number
|
|
||||||
id: pr
|
|
||||||
uses: 8BitJonny/gh-get-current-pr@2.2.0
|
|
||||||
|
|
||||||
- name: Cache docker images
|
- name: Cache docker images
|
||||||
id: cache
|
id: cache
|
||||||
@ -48,7 +43,7 @@ jobs:
|
|||||||
/home/runner/.cache/Cypress
|
/home/runner/.cache/Cypress
|
||||||
/home/runner/work/Ocelot-Social/Ocelot-Social
|
/home/runner/work/Ocelot-Social/Ocelot-Social
|
||||||
/tmp/images/
|
/tmp/images/
|
||||||
key: e2e-preparation-cache-pr${{ steps.pr.outputs.number }}
|
key: ${{ github.run_id }}-e2e-preparation-cache
|
||||||
|
|
||||||
fullstack_tests:
|
fullstack_tests:
|
||||||
name: Fullstack tests
|
name: Fullstack tests
|
||||||
@ -71,7 +66,7 @@ jobs:
|
|||||||
/home/runner/.cache/Cypress
|
/home/runner/.cache/Cypress
|
||||||
/home/runner/work/Ocelot-Social/Ocelot-Social
|
/home/runner/work/Ocelot-Social/Ocelot-Social
|
||||||
/tmp/images/
|
/tmp/images/
|
||||||
key: e2e-preparation-cache-pr${{ needs.docker_preparation.outputs.pr-number }}
|
key: ${{ github.run_id }}-e2e-preparation-cache
|
||||||
fail-on-cache-miss: true
|
fail-on-cache-miss: true
|
||||||
|
|
||||||
- name: Boot up test system | docker-compose
|
- name: Boot up test system | docker-compose
|
||||||
@ -104,15 +99,14 @@ jobs:
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
name: Cleanup
|
name: Cleanup
|
||||||
if: always()
|
|
||||||
needs: [docker_preparation, fullstack_tests]
|
needs: [docker_preparation, fullstack_tests]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
steps:
|
steps:
|
||||||
- name: Delete cache
|
- name: Delete cache
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
gh extension install actions/gh-actions-cache
|
gh extension install actions/gh-actions-cache
|
||||||
set +e
|
KEY="${{ github.run_id }}-e2e-preparation-cache"
|
||||||
KEY="e2e-preparation-cache-pr${{ needs.docker_preparation.outputs.pr-number }}"
|
|
||||||
gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm
|
gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm
|
||||||
17
.github/workflows/test-webapp.yml
vendored
17
.github/workflows/test-webapp.yml
vendored
@ -1,7 +1,7 @@
|
|||||||
name: ocelot.social webapp test CI
|
name: ocelot.social webapp test CI
|
||||||
|
|
||||||
|
|
||||||
on: [push]
|
on: push
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
files-changed:
|
files-changed:
|
||||||
@ -9,7 +9,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
docker: ${{ steps.changes.outputs.docker }}
|
docker: ${{ steps.changes.outputs.docker }}
|
||||||
pr-number: ${{ steps.pr.outputs.number }}
|
|
||||||
webapp: ${{ steps.changes.outputs.webapp }}
|
webapp: ${{ steps.changes.outputs.webapp }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.3.0
|
- uses: actions/checkout@v3.3.0
|
||||||
@ -22,10 +21,6 @@ jobs:
|
|||||||
filters: .github/file-filters.yml
|
filters: .github/file-filters.yml
|
||||||
list-files: shell
|
list-files: shell
|
||||||
|
|
||||||
- name: Get pr number
|
|
||||||
id: pr
|
|
||||||
uses: 8BitJonny/gh-get-current-pr@2.2.0
|
|
||||||
|
|
||||||
prepare:
|
prepare:
|
||||||
name: Prepare
|
name: Prepare
|
||||||
if: needs.files-changed.outputs.webapp == 'true'
|
if: needs.files-changed.outputs.webapp == 'true'
|
||||||
@ -58,7 +53,7 @@ jobs:
|
|||||||
uses: actions/cache/save@v3.3.1
|
uses: actions/cache/save@v3.3.1
|
||||||
with:
|
with:
|
||||||
path: /tmp/webapp.tar
|
path: /tmp/webapp.tar
|
||||||
key: webapp-cache-pr${{ needs.files-changed.outputs.pr-number }}
|
key: ${{ github.run_id }}-webapp-cache
|
||||||
|
|
||||||
lint_webapp:
|
lint_webapp:
|
||||||
name: Lint Webapp
|
name: Lint Webapp
|
||||||
@ -87,7 +82,7 @@ jobs:
|
|||||||
uses: actions/cache/restore@v3.3.1
|
uses: actions/cache/restore@v3.3.1
|
||||||
with:
|
with:
|
||||||
path: /tmp/webapp.tar
|
path: /tmp/webapp.tar
|
||||||
key: webapp-cache-pr${{ needs.files-changed.outputs.pr-number }}
|
key: ${{ github.run_id }}-webapp-cache
|
||||||
|
|
||||||
- name: Load Docker Image
|
- name: Load Docker Image
|
||||||
run: docker load < /tmp/webapp.tar
|
run: docker load < /tmp/webapp.tar
|
||||||
@ -105,16 +100,16 @@ jobs:
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
name: Cleanup
|
name: Cleanup
|
||||||
if: always()
|
if: ${{ needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true' }}
|
||||||
needs: [files-changed, unit_test_webapp]
|
needs: [files-changed, unit_test_webapp]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
steps:
|
steps:
|
||||||
- name: Delete cache
|
- name: Delete cache
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
gh extension install actions/gh-actions-cache
|
gh extension install actions/gh-actions-cache
|
||||||
set +e
|
KEY="${{ github.run_id }}-webapp-cache"
|
||||||
KEY="webapp-cache-pr${{ needs.files-changed.outputs.pr-number }}"
|
|
||||||
gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm
|
gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user