mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
refactor: add pr-relation to all caching actions in worklfows
This commit is contained in:
parent
8a0b7e49cd
commit
56acb2cb94
@ -20,23 +20,37 @@ jobs:
|
||||
name: Cleanup branch cache
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
permissions:
|
||||
actions: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.7
|
||||
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f # v4.2.2
|
||||
|
||||
- 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"
|
||||
PR_NUMBER="${{ github.event.pull_request.number }}"
|
||||
echo "Cache cleanup for PR $PR_NUMBER"
|
||||
|
||||
echo "Search for caches with prefix '$PR_NUMBER-'..."
|
||||
cacheKeys=$(gh cache list --json key --jq '.[] | select(.key | startswith("'"$PR_NUMBER-"'")) | .key')
|
||||
|
||||
if [ -z "$cacheKeys" ]; then
|
||||
echo "No caches found with prefix '$PR_NUMBER-'. Nothing to do."
|
||||
else
|
||||
echo "Delete caches..."
|
||||
for cacheKey in $cacheKeys
|
||||
do
|
||||
echo "Deleting cache: $cacheKey"
|
||||
gh cache delete "$cacheKey" --confirm
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Successfully deleted cache: $cacheKey"
|
||||
else
|
||||
echo "Failed to delete cache: $cacheKey"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Cache cleanup completed"
|
||||
fi
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
25
.github/workflows/test-e2e.yml
vendored
25
.github/workflows/test-e2e.yml
vendored
@ -10,6 +10,11 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.7
|
||||
|
||||
- uses: 8BitJonny/gh-get-current-pr@bccb4d0785d00a707b5c31c2c03410b01bb4658c # v3.0.0
|
||||
id: PR
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build docker image
|
||||
run: |
|
||||
docker build --target community -t "ocelotsocialnetwork/neo4j-community:test" neo4j/
|
||||
@ -19,7 +24,7 @@ jobs:
|
||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||
with:
|
||||
path: /tmp/neo4j.tar
|
||||
key: ${{ github.run_id }}-e2e-neo4j-cache
|
||||
key: ${{ steps.PR.outputs.number }}-${{ github.run_id }}-e2e-neo4j-cache
|
||||
|
||||
prepare_backend_image:
|
||||
name: Fullstack | prepare backend image
|
||||
@ -37,7 +42,7 @@ jobs:
|
||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||
with:
|
||||
path: /tmp/backend.tar
|
||||
key: ${{ github.run_id }}-e2e-backend-cache
|
||||
key: ${{ steps.PR.outputs.number }}-${{ github.run_id }}-e2e-backend-cache
|
||||
|
||||
prepare_webapp_image:
|
||||
name: Fullstack | prepare webapp image
|
||||
@ -55,7 +60,7 @@ jobs:
|
||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||
with:
|
||||
path: /tmp/webapp.tar
|
||||
key: ${{ github.run_id }}-e2e-webapp-cache
|
||||
key: ${{ steps.PR.outputs.number }}-${{ github.run_id }}-e2e-webapp-cache
|
||||
|
||||
prepare_cypress:
|
||||
name: Fullstack | prepare cypress
|
||||
@ -86,7 +91,7 @@ jobs:
|
||||
/opt/cucumber-json-formatter
|
||||
/home/runner/.cache/Cypress
|
||||
/home/runner/work/Ocelot-Social/Ocelot-Social
|
||||
key: ${{ github.run_id }}-e2e-cypress
|
||||
key: ${{ steps.PR.outputs.number }}-${{ github.run_id }}-e2e-cypress
|
||||
|
||||
fullstack_tests:
|
||||
name: Fullstack | tests
|
||||
@ -107,26 +112,26 @@ jobs:
|
||||
/opt/cucumber-json-formatter
|
||||
/home/runner/.cache/Cypress
|
||||
/home/runner/work/Ocelot-Social/Ocelot-Social
|
||||
key: ${{ github.run_id }}-e2e-cypress
|
||||
restore-keys: ${{ github.run_id }}-e2e-cypress
|
||||
key: ${{ steps.PR.outputs.number }}-${{ github.run_id }}-e2e-cypress
|
||||
restore-keys: ${{ steps.PR.outputs.number }}-${{ github.run_id }}-e2e-cypress
|
||||
|
||||
- name: Restore neo4j cache
|
||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||
with:
|
||||
path: /tmp/neo4j.tar
|
||||
key: ${{ github.run_id }}-e2e-neo4j-cache
|
||||
key: ${{ steps.PR.outputs.number }}-${{ github.run_id }}-e2e-neo4j-cache
|
||||
|
||||
- name: Restore backend cache
|
||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||
with:
|
||||
path: /tmp/backend.tar
|
||||
key: ${{ github.run_id }}-e2e-backend-cache
|
||||
key: ${{ steps.PR.outputs.number }}-${{ github.run_id }}-e2e-backend-cache
|
||||
|
||||
- name: Restore webapp cache
|
||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||
with:
|
||||
path: /tmp/webapp.tar
|
||||
key: ${{ github.run_id }}-e2e-webapp-cache
|
||||
key: ${{ steps.PR.outputs.number }}-${{ github.run_id }}-e2e-webapp-cache
|
||||
|
||||
- name: Boot up test system | docker compose
|
||||
run: |
|
||||
@ -167,7 +172,7 @@ jobs:
|
||||
|
||||
- name: Full stack tests | cleanup cache
|
||||
run: |
|
||||
cacheKeys=$(gh cache list --json key --jq '.[] | select(.key | startswith("${{ github.run_id }}-e2e-")) | .key')
|
||||
cacheKeys=$(gh cache list --json key --jq '.[] | select(.key | startswith("${{ steps.PR.outputs.number }}-${{ github.run_id }}-e2e-")) | .key')
|
||||
set +e
|
||||
echo "Deleting caches..."
|
||||
for cacheKey in $cacheKeys
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user