From a9835288e205d39560493d1633b6cbc917cfb940 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 18 Jul 2023 17:39:50 +0200 Subject: [PATCH 01/21] fix github cache in workflow --- .github/workflows/test-backend.yml | 19 +++++++------------ .github/workflows/test-e2e.yml | 14 ++++---------- .github/workflows/test-webapp.yml | 13 ++++--------- 3 files changed, 15 insertions(+), 31 deletions(-) diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index af53e1fbc..50c24441e 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -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 diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index e37b9fed0..49b4877fa 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/test-webapp.yml b/.github/workflows/test-webapp.yml index 421ce5187..9bd588420 100644 --- a/.github/workflows/test-webapp.yml +++ b/.github/workflows/test-webapp.yml @@ -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 From 45c70f7910ba6596d42cda4903e7805f82c701fa Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 18 Jul 2023 17:55:22 +0200 Subject: [PATCH 02/21] corrected var reference --- .github/workflows/test-backend.yml | 12 ++++++------ .github/workflows/test-e2e.yml | 6 +++--- .github/workflows/test-webapp.yml | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index 50c24441e..366196978 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -40,7 +40,7 @@ jobs: uses: actions/cache/save@v3.3.1 with: path: /tmp/neo4j.tar - key: backend-neo4j-cache-${{ GITHUB_RUN_NUMBER }} + key: backend-neo4j-cache-${{ env.GITHUB_RUN_NUMBER }} build_test_backend: name: Docker Build Test - Backend @@ -61,7 +61,7 @@ jobs: uses: actions/cache/save@v3.3.1 with: path: /tmp/backend.tar - key: backend-cache-${{ GITHUB_RUN_NUMBER }} + key: backend-cache-${{ env.GITHUB_RUN_NUMBER }} lint_backend: name: Lint Backend @@ -90,14 +90,14 @@ jobs: uses: actions/cache/restore@v3.3.1 with: path: /tmp/neo4j.tar - key: backend-neo4j-cache-${{ GITHUB_RUN_NUMBER }} + key: backend-neo4j-cache-${{ env.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-${{ GITHUB_RUN_NUMBER }} + key: backend-cache-${{ env.GITHUB_RUN_NUMBER }} fail-on-cache-miss: true - name: Load Docker Images @@ -134,7 +134,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh extension install actions/gh-actions-cache - KEY="backend-neo4j-cache-${{ GITHUB_RUN_NUMBER }}" + KEY="backend-neo4j-cache-${{ env.GITHUB_RUN_NUMBER }}" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm - KEY="backend-cache-${{ GITHUB_RUN_NUMBER }}" + KEY="backend-cache-${{ env.GITHUB_RUN_NUMBER }}" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 49b4877fa..09c6f3136 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -42,7 +42,7 @@ jobs: /home/runner/.cache/Cypress /home/runner/work/Ocelot-Social/Ocelot-Social /tmp/images/ - key: e2e-preparation-cache-${{ GITHUB_RUN_NUMBER }} + key: e2e-preparation-cache-${{ env.GITHUB_RUN_NUMBER }} fullstack_tests: name: Fullstack tests @@ -65,7 +65,7 @@ jobs: /home/runner/.cache/Cypress /home/runner/work/Ocelot-Social/Ocelot-Social /tmp/images/ - key: e2e-preparation-cache-${{ GITHUB_RUN_NUMBER }} + key: e2e-preparation-cache-${{ env.GITHUB_RUN_NUMBER }} fail-on-cache-miss: true - name: Boot up test system | docker-compose @@ -108,5 +108,5 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh extension install actions/gh-actions-cache - KEY="e2e-preparation-cache-${{ GITHUB_RUN_NUMBER }}" + KEY="e2e-preparation-cache-${{ env.GITHUB_RUN_NUMBER }}" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm \ No newline at end of file diff --git a/.github/workflows/test-webapp.yml b/.github/workflows/test-webapp.yml index 9bd588420..d468d0859 100644 --- a/.github/workflows/test-webapp.yml +++ b/.github/workflows/test-webapp.yml @@ -53,7 +53,7 @@ jobs: uses: actions/cache/save@v3.3.1 with: path: /tmp/webapp.tar - key: webapp-cache-${{ GITHUB_RUN_NUMBER }} + key: webapp-cache-${{ env.GITHUB_RUN_NUMBER }} lint_webapp: name: Lint Webapp @@ -82,7 +82,7 @@ jobs: uses: actions/cache/restore@v3.3.1 with: path: /tmp/webapp.tar - key: webapp-cache-${{ GITHUB_RUN_NUMBER }} + key: webapp-cache-${{ env.GITHUB_RUN_NUMBER }} - name: Load Docker Image run: docker load < /tmp/webapp.tar @@ -110,6 +110,6 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh extension install actions/gh-actions-cache - KEY="webapp-cache-${{ GITHUB_RUN_NUMBER }}" + KEY="webapp-cache-${{ env.GITHUB_RUN_NUMBER }}" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm From 6ccd4dde543759cb2d99bddb20fdf60f4f827f04 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 18 Jul 2023 18:34:13 +0200 Subject: [PATCH 03/21] reference GITHUB_RUN_NUMBER differently --- .github/workflows/test-backend.yml | 12 ++++++------ .github/workflows/test-e2e.yml | 6 +++--- .github/workflows/test-webapp.yml | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index 366196978..e9a05b998 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -40,7 +40,7 @@ jobs: uses: actions/cache/save@v3.3.1 with: path: /tmp/neo4j.tar - key: backend-neo4j-cache-${{ env.GITHUB_RUN_NUMBER }} + key: backend-neo4j-cache-$GITHUB_RUN_NUMBER build_test_backend: name: Docker Build Test - Backend @@ -61,7 +61,7 @@ jobs: uses: actions/cache/save@v3.3.1 with: path: /tmp/backend.tar - key: backend-cache-${{ env.GITHUB_RUN_NUMBER }} + key: backend-cache-$GITHUB_RUN_NUMBER lint_backend: name: Lint Backend @@ -90,14 +90,14 @@ jobs: uses: actions/cache/restore@v3.3.1 with: path: /tmp/neo4j.tar - key: backend-neo4j-cache-${{ env.GITHUB_RUN_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-${{ env.GITHUB_RUN_NUMBER }} + key: backend-cache-$GITHUB_RUN_NUMBER fail-on-cache-miss: true - name: Load Docker Images @@ -134,7 +134,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh extension install actions/gh-actions-cache - KEY="backend-neo4j-cache-${{ env.GITHUB_RUN_NUMBER }}" + KEY="backend-neo4j-cache-$GITHUB_RUN_NUMBER" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm - KEY="backend-cache-${{ env.GITHUB_RUN_NUMBER }}" + KEY="backend-cache-$GITHUB_RUN_NUMBER" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 09c6f3136..6bad6fb4f 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -42,7 +42,7 @@ jobs: /home/runner/.cache/Cypress /home/runner/work/Ocelot-Social/Ocelot-Social /tmp/images/ - key: e2e-preparation-cache-${{ env.GITHUB_RUN_NUMBER }} + key: e2e-preparation-cache-$GITHUB_RUN_NUMBER fullstack_tests: name: Fullstack tests @@ -65,7 +65,7 @@ jobs: /home/runner/.cache/Cypress /home/runner/work/Ocelot-Social/Ocelot-Social /tmp/images/ - key: e2e-preparation-cache-${{ env.GITHUB_RUN_NUMBER }} + key: e2e-preparation-cache-$GITHUB_RUN_NUMBER fail-on-cache-miss: true - name: Boot up test system | docker-compose @@ -108,5 +108,5 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh extension install actions/gh-actions-cache - KEY="e2e-preparation-cache-${{ env.GITHUB_RUN_NUMBER }}" + KEY="e2e-preparation-cache-$GITHUB_RUN_NUMBER" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm \ No newline at end of file diff --git a/.github/workflows/test-webapp.yml b/.github/workflows/test-webapp.yml index d468d0859..f89437317 100644 --- a/.github/workflows/test-webapp.yml +++ b/.github/workflows/test-webapp.yml @@ -53,7 +53,7 @@ jobs: uses: actions/cache/save@v3.3.1 with: path: /tmp/webapp.tar - key: webapp-cache-${{ env.GITHUB_RUN_NUMBER }} + key: webapp-cache-$GITHUB_RUN_NUMBER lint_webapp: name: Lint Webapp @@ -82,7 +82,7 @@ jobs: uses: actions/cache/restore@v3.3.1 with: path: /tmp/webapp.tar - key: webapp-cache-${{ env.GITHUB_RUN_NUMBER }} + key: webapp-cache-$GITHUB_RUN_NUMBER - name: Load Docker Image run: docker load < /tmp/webapp.tar @@ -110,6 +110,6 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh extension install actions/gh-actions-cache - KEY="webapp-cache-${{ env.GITHUB_RUN_NUMBER }}" + KEY="webapp-cache-$GITHUB_RUN_NUMBER" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm From bf7d4e13c81ab408a4279847fb0b24a5d79ea85e Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 18:33:25 +0200 Subject: [PATCH 04/21] run cache deletion job only, if needed jobs were successful --- .github/workflows/test-backend.yml | 2 +- .github/workflows/test-e2e.yml | 2 +- .github/workflows/test-webapp.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index e9a05b998..b963a9e45 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -124,7 +124,7 @@ jobs: cleanup: name: Cleanup - if: always() + if: success() needs: [files-changed, unit_test_backend] runs-on: ubuntu-latest continue-on-error: true diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 6bad6fb4f..c4ddc620f 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -98,7 +98,7 @@ jobs: cleanup: name: Cleanup - if: always() + if: success() needs: [docker_preparation, fullstack_tests] runs-on: ubuntu-latest continue-on-error: true diff --git a/.github/workflows/test-webapp.yml b/.github/workflows/test-webapp.yml index f89437317..8e59bdf10 100644 --- a/.github/workflows/test-webapp.yml +++ b/.github/workflows/test-webapp.yml @@ -100,7 +100,7 @@ jobs: cleanup: name: Cleanup - if: always() + if: success() needs: [files-changed, unit_test_webapp] runs-on: ubuntu-latest continue-on-error: true From 4d611638687426518235290778bf67cc7791d0e5 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 18:41:16 +0200 Subject: [PATCH 05/21] run cache deletion job only, if file change condition is true --- .github/workflows/test-backend.yml | 2 +- .github/workflows/test-webapp.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index b963a9e45..0e8b7f3e6 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -124,7 +124,7 @@ jobs: cleanup: name: Cleanup - if: success() + if: (needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.docker == 'true') || success() needs: [files-changed, unit_test_backend] runs-on: ubuntu-latest continue-on-error: true diff --git a/.github/workflows/test-webapp.yml b/.github/workflows/test-webapp.yml index 8e59bdf10..32cd563ef 100644 --- a/.github/workflows/test-webapp.yml +++ b/.github/workflows/test-webapp.yml @@ -100,7 +100,7 @@ jobs: cleanup: name: Cleanup - if: success() + if: (needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true') || success() needs: [files-changed, unit_test_webapp] runs-on: ubuntu-latest continue-on-error: true From b1feca35d6e34b642d344dbad1162930f00105d9 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 18 Jul 2023 18:53:50 +0200 Subject: [PATCH 06/21] another try fixing run id --- .github/workflows/test-backend.yml | 12 ++++++------ .github/workflows/test-e2e.yml | 6 +++--- .github/workflows/test-webapp.yml | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index 0e8b7f3e6..9fd6adb49 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -40,7 +40,7 @@ jobs: uses: actions/cache/save@v3.3.1 with: path: /tmp/neo4j.tar - key: backend-neo4j-cache-$GITHUB_RUN_NUMBER + key: backend-neo4j-cache-${{github.run_id}} build_test_backend: name: Docker Build Test - Backend @@ -61,7 +61,7 @@ jobs: uses: actions/cache/save@v3.3.1 with: path: /tmp/backend.tar - key: backend-cache-$GITHUB_RUN_NUMBER + key: backend-cache-${{github.run_id}} lint_backend: name: Lint Backend @@ -90,14 +90,14 @@ jobs: uses: actions/cache/restore@v3.3.1 with: path: /tmp/neo4j.tar - key: backend-neo4j-cache-$GITHUB_RUN_NUMBER + key: backend-neo4j-cache-${{github.run_id}} fail-on-cache-miss: true - name: Restore Backend cache uses: actions/cache/restore@v3.3.1 with: path: /tmp/backend.tar - key: backend-cache-$GITHUB_RUN_NUMBER + key: backend-cache-${{github.run_id}} fail-on-cache-miss: true - name: Load Docker Images @@ -134,7 +134,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh extension install actions/gh-actions-cache - KEY="backend-neo4j-cache-$GITHUB_RUN_NUMBER" + KEY="backend-neo4j-cache-$(($GITHUB_RUN_NUMBER))" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm - KEY="backend-cache-$GITHUB_RUN_NUMBER" + KEY="backend-cache-$(($GITHUB_RUN_NUMBER))" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index c4ddc620f..4d25ef5fe 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -42,7 +42,7 @@ jobs: /home/runner/.cache/Cypress /home/runner/work/Ocelot-Social/Ocelot-Social /tmp/images/ - key: e2e-preparation-cache-$GITHUB_RUN_NUMBER + key: e2e-preparation-cache-${{github.run_id}} fullstack_tests: name: Fullstack tests @@ -65,7 +65,7 @@ jobs: /home/runner/.cache/Cypress /home/runner/work/Ocelot-Social/Ocelot-Social /tmp/images/ - key: e2e-preparation-cache-$GITHUB_RUN_NUMBER + key: e2e-preparation-cache-${{github.run_id}} fail-on-cache-miss: true - name: Boot up test system | docker-compose @@ -108,5 +108,5 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh extension install actions/gh-actions-cache - KEY="e2e-preparation-cache-$GITHUB_RUN_NUMBER" + KEY="e2e-preparation-cache-$(($GITHUB_RUN_NUMBER))" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm \ No newline at end of file diff --git a/.github/workflows/test-webapp.yml b/.github/workflows/test-webapp.yml index 32cd563ef..5c6cce0f6 100644 --- a/.github/workflows/test-webapp.yml +++ b/.github/workflows/test-webapp.yml @@ -53,7 +53,7 @@ jobs: uses: actions/cache/save@v3.3.1 with: path: /tmp/webapp.tar - key: webapp-cache-$GITHUB_RUN_NUMBER + key: "webapp-cache-${{ github.run_id }}" lint_webapp: name: Lint Webapp @@ -82,7 +82,7 @@ jobs: uses: actions/cache/restore@v3.3.1 with: path: /tmp/webapp.tar - key: webapp-cache-$GITHUB_RUN_NUMBER + key: "webapp-cache-${{ github.run_id }}" - name: Load Docker Image run: docker load < /tmp/webapp.tar @@ -110,6 +110,6 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh extension install actions/gh-actions-cache - KEY="webapp-cache-$GITHUB_RUN_NUMBER" + KEY="webapp-cache-$(($GITHUB_RUN_NUMBER))" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm From d468af8104a8fac439de8f14bdffb34e36b0c23a Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 19:18:38 +0200 Subject: [PATCH 07/21] fix cache naming --- .github/workflows/test-backend.yml | 12 ++++++------ .github/workflows/test-e2e.yml | 6 +++--- .github/workflows/test-webapp.yml | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index 9fd6adb49..fa43c9b81 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -40,7 +40,7 @@ jobs: uses: actions/cache/save@v3.3.1 with: path: /tmp/neo4j.tar - key: backend-neo4j-cache-${{github.run_id}} + key: ${{ github.run_id }}-backend-neo4j-cache build_test_backend: name: Docker Build Test - Backend @@ -61,7 +61,7 @@ jobs: uses: actions/cache/save@v3.3.1 with: path: /tmp/backend.tar - key: backend-cache-${{github.run_id}} + key: ${{ github.run_id }}-backend-cache lint_backend: name: Lint Backend @@ -90,14 +90,14 @@ jobs: uses: actions/cache/restore@v3.3.1 with: path: /tmp/neo4j.tar - key: backend-neo4j-cache-${{github.run_id}} + key: ${{ github.run_id }}-backend-neo4j-cache fail-on-cache-miss: true - name: Restore Backend cache uses: actions/cache/restore@v3.3.1 with: path: /tmp/backend.tar - key: backend-cache-${{github.run_id}} + key: ${{ github.run_id }}backend-cache fail-on-cache-miss: true - name: Load Docker Images @@ -134,7 +134,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh extension install actions/gh-actions-cache - KEY="backend-neo4j-cache-$(($GITHUB_RUN_NUMBER))" + KEY="${{ github.run_id }}-backend-neo4j-cache" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm - KEY="backend-cache-$(($GITHUB_RUN_NUMBER))" + KEY="${{ github.run_id }}-backend-cache" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 4d25ef5fe..921fb4fc8 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -42,7 +42,7 @@ jobs: /home/runner/.cache/Cypress /home/runner/work/Ocelot-Social/Ocelot-Social /tmp/images/ - key: e2e-preparation-cache-${{github.run_id}} + key: ${{ github.run_id }}-e2e-preparation-cache fullstack_tests: name: Fullstack tests @@ -65,7 +65,7 @@ jobs: /home/runner/.cache/Cypress /home/runner/work/Ocelot-Social/Ocelot-Social /tmp/images/ - key: e2e-preparation-cache-${{github.run_id}} + key: ${{ github.run_id }}e2e-preparation-cache fail-on-cache-miss: true - name: Boot up test system | docker-compose @@ -108,5 +108,5 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh extension install actions/gh-actions-cache - KEY="e2e-preparation-cache-$(($GITHUB_RUN_NUMBER))" + KEY="${{ github.run_id }}-e2e-preparation-cache" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm \ No newline at end of file diff --git a/.github/workflows/test-webapp.yml b/.github/workflows/test-webapp.yml index 5c6cce0f6..0f578dc46 100644 --- a/.github/workflows/test-webapp.yml +++ b/.github/workflows/test-webapp.yml @@ -53,7 +53,7 @@ jobs: uses: actions/cache/save@v3.3.1 with: path: /tmp/webapp.tar - key: "webapp-cache-${{ github.run_id }}" + key: ${{ github.run_id }}-webapp-cache lint_webapp: name: Lint Webapp @@ -82,7 +82,7 @@ jobs: uses: actions/cache/restore@v3.3.1 with: path: /tmp/webapp.tar - key: "webapp-cache-${{ github.run_id }}" + key: ${{ github.run_id }}-webapp-cache - name: Load Docker Image run: docker load < /tmp/webapp.tar @@ -110,6 +110,6 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh extension install actions/gh-actions-cache - KEY="webapp-cache-$(($GITHUB_RUN_NUMBER))" + KEY="${{ github.run_id }}-webapp-cache" gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm From b2632e3a8881b86fd1f629c7130a85eb72d5d77c Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 19:34:36 +0200 Subject: [PATCH 08/21] for testing use only backend test workflow triggered by pushes on this branch --- .github/workflows/test-backend.yml | 5 +- .github/workflows/test-e2e.yml | 202 ++++++++++++++--------------- .github/workflows/test-webapp.yml | 192 +++++++++++++-------------- 3 files changed, 201 insertions(+), 198 deletions(-) diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index fa43c9b81..2d2c9bb6b 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -1,7 +1,10 @@ name: ocelot.social backend test CI -on: [push] +on: + push: + branches: + - fix-runner jobs: files-changed: diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 921fb4fc8..9eafcddaa 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -1,112 +1,112 @@ -name: ocelot.social end-to-end test CI -on: push +# name: ocelot.social end-to-end test CI +# on: push -jobs: - docker_preparation: - name: Fullstack test preparation - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 +# jobs: +# docker_preparation: +# name: Fullstack test preparation +# runs-on: ubuntu-latest +# steps: +# - name: Checkout code +# uses: actions/checkout@v3 - - name: Copy env files - run: | - cp webapp/.env.template webapp/.env - cp backend/.env.template backend/.env +# - name: Copy env files +# run: | +# cp webapp/.env.template webapp/.env +# cp backend/.env.template backend/.env - - name: Build docker images - run: | - mkdir /tmp/images - docker build --target community -t "ocelotsocialnetwork/neo4j-community:test" neo4j/ - docker save "ocelotsocialnetwork/neo4j-community:test" > /tmp/images/neo4j.tar - docker build --target test -t "ocelotsocialnetwork/backend:test" backend/ - docker save "ocelotsocialnetwork/backend:test" > /tmp/images/backend.tar - docker build --target test -t "ocelotsocialnetwork/webapp:test" webapp/ - docker save "ocelotsocialnetwork/webapp:test" > /tmp/images/webapp.tar +# - name: Build docker images +# run: | +# mkdir /tmp/images +# docker build --target community -t "ocelotsocialnetwork/neo4j-community:test" neo4j/ +# docker save "ocelotsocialnetwork/neo4j-community:test" > /tmp/images/neo4j.tar +# docker build --target test -t "ocelotsocialnetwork/backend:test" backend/ +# docker save "ocelotsocialnetwork/backend:test" > /tmp/images/backend.tar +# docker build --target test -t "ocelotsocialnetwork/webapp:test" webapp/ +# docker save "ocelotsocialnetwork/webapp:test" > /tmp/images/webapp.tar - - name: Install cypress requirements - run: | - wget --no-verbose -O /opt/cucumber-json-formatter "https://github.com/cucumber/json-formatter/releases/download/v19.0.0/cucumber-json-formatter-linux-386" - cd backend - yarn install - yarn build - cd .. - yarn install +# - name: Install cypress requirements +# run: | +# wget --no-verbose -O /opt/cucumber-json-formatter "https://github.com/cucumber/json-formatter/releases/download/v19.0.0/cucumber-json-formatter-linux-386" +# cd backend +# yarn install +# yarn build +# cd .. +# yarn install - - name: Cache docker images - id: cache - uses: actions/cache/save@v3.3.1 - with: - path: | - /opt/cucumber-json-formatter - /home/runner/.cache/Cypress - /home/runner/work/Ocelot-Social/Ocelot-Social - /tmp/images/ - key: ${{ github.run_id }}-e2e-preparation-cache +# - name: Cache docker images +# id: cache +# uses: actions/cache/save@v3.3.1 +# with: +# path: | +# /opt/cucumber-json-formatter +# /home/runner/.cache/Cypress +# /home/runner/work/Ocelot-Social/Ocelot-Social +# /tmp/images/ +# key: ${{ github.run_id }}-e2e-preparation-cache - fullstack_tests: - name: Fullstack tests - if: success() - needs: docker_preparation - runs-on: ubuntu-latest - env: - jobs: 8 - strategy: - matrix: - # run copies of the current job in parallel - job: [1, 2, 3, 4, 5, 6, 7, 8] - steps: - - name: Restore cache - uses: actions/cache/restore@v3.3.1 - id: cache - with: - path: | - /opt/cucumber-json-formatter - /home/runner/.cache/Cypress - /home/runner/work/Ocelot-Social/Ocelot-Social - /tmp/images/ - key: ${{ github.run_id }}e2e-preparation-cache - fail-on-cache-miss: true +# fullstack_tests: +# name: Fullstack tests +# if: success() +# needs: docker_preparation +# runs-on: ubuntu-latest +# env: +# jobs: 8 +# strategy: +# matrix: +# # run copies of the current job in parallel +# job: [1, 2, 3, 4, 5, 6, 7, 8] +# steps: +# - name: Restore cache +# uses: actions/cache/restore@v3.3.1 +# id: cache +# with: +# path: | +# /opt/cucumber-json-formatter +# /home/runner/.cache/Cypress +# /home/runner/work/Ocelot-Social/Ocelot-Social +# /tmp/images/ +# key: ${{ github.run_id }}e2e-preparation-cache +# fail-on-cache-miss: true - - name: Boot up test system | docker-compose - run: | - chmod +x /opt/cucumber-json-formatter - sudo ln -fs /opt/cucumber-json-formatter /usr/bin/cucumber-json-formatter - docker load < /tmp/images/neo4j.tar - docker load < /tmp/images/backend.tar - docker load < /tmp/images/webapp.tar - docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp neo4j backend - sleep 90s +# - name: Boot up test system | docker-compose +# run: | +# chmod +x /opt/cucumber-json-formatter +# sudo ln -fs /opt/cucumber-json-formatter /usr/bin/cucumber-json-formatter +# docker load < /tmp/images/neo4j.tar +# docker load < /tmp/images/backend.tar +# docker load < /tmp/images/webapp.tar +# docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp neo4j backend +# sleep 90s - - name: Full stack tests | run tests - id: e2e-tests - run: yarn run cypress:run --spec $(cypress/parallel-features.sh ${{ matrix.job }} ${{ env.jobs }} ) +# - name: Full stack tests | run tests +# id: e2e-tests +# run: yarn run cypress:run --spec $(cypress/parallel-features.sh ${{ matrix.job }} ${{ env.jobs }} ) - - name: Full stack tests | if tests failed, compile html report - if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} - run: | - cd cypress/ - node create-cucumber-html-report.js +# - name: Full stack tests | if tests failed, compile html report +# if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} +# run: | +# cd cypress/ +# node create-cucumber-html-report.js - - name: Full stack tests | if tests failed, upload report - id: e2e-report - if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} - uses: actions/upload-artifact@v3 - with: - name: ocelot-e2e-test-report-pr${{ needs.docker_preparation.outputs.pr-number }} - path: /home/runner/work/Ocelot-Social/Ocelot-Social/cypress/reports/cucumber_html_report +# - name: Full stack tests | if tests failed, upload report +# id: e2e-report +# if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} +# uses: actions/upload-artifact@v3 +# with: +# name: ocelot-e2e-test-report-pr${{ needs.docker_preparation.outputs.pr-number }} +# path: /home/runner/work/Ocelot-Social/Ocelot-Social/cypress/reports/cucumber_html_report - cleanup: - name: Cleanup - if: success() - 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 - KEY="${{ github.run_id }}-e2e-preparation-cache" - gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm \ No newline at end of file +# cleanup: +# name: Cleanup +# if: success() +# 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 +# KEY="${{ github.run_id }}-e2e-preparation-cache" +# gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm \ No newline at end of file diff --git a/.github/workflows/test-webapp.yml b/.github/workflows/test-webapp.yml index 0f578dc46..0def21da3 100644 --- a/.github/workflows/test-webapp.yml +++ b/.github/workflows/test-webapp.yml @@ -1,115 +1,115 @@ -name: ocelot.social webapp test CI +# name: ocelot.social webapp test CI -on: [push] +# on: [push] -jobs: - files-changed: - name: Detect File Changes - Webapp - runs-on: ubuntu-latest - outputs: - docker: ${{ steps.changes.outputs.docker }} - webapp: ${{ steps.changes.outputs.webapp }} - steps: - - uses: actions/checkout@v3.3.0 +# jobs: +# files-changed: +# name: Detect File Changes - Webapp +# runs-on: ubuntu-latest +# outputs: +# docker: ${{ steps.changes.outputs.docker }} +# webapp: ${{ steps.changes.outputs.webapp }} +# steps: +# - uses: actions/checkout@v3.3.0 - - name: Check for frontend file changes - uses: dorny/paths-filter@v2.11.1 - id: changes - with: - token: ${{ github.token }} - filters: .github/file-filters.yml - list-files: shell +# - name: Check for frontend file changes +# uses: dorny/paths-filter@v2.11.1 +# id: changes +# with: +# token: ${{ github.token }} +# filters: .github/file-filters.yml +# list-files: shell - prepare: - name: Prepare - if: needs.files-changed.outputs.webapp == 'true' - needs: files-changed - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 +# prepare: +# name: Prepare +# if: needs.files-changed.outputs.webapp == 'true' +# needs: files-changed +# runs-on: ubuntu-latest +# steps: +# - name: Checkout code +# uses: actions/checkout@v3 - - name: Check translation files - run: | - scripts/translations/sort.sh - scripts/translations/missing-keys.sh +# - name: Check translation files +# run: | +# scripts/translations/sort.sh +# scripts/translations/missing-keys.sh - build_test_webapp: - name: Docker Build Test - Webapp - if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true' - needs: [files-changed, prepare] - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 +# build_test_webapp: +# name: Docker Build Test - Webapp +# if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true' +# needs: [files-changed, prepare] +# runs-on: ubuntu-latest +# steps: +# - name: Checkout code +# uses: actions/checkout@v3 - - name: Webapp | Build 'test' image - run: | - docker build --target test -t "ocelotsocialnetwork/webapp:test" webapp/ - docker save "ocelotsocialnetwork/webapp:test" > /tmp/webapp.tar +# - name: Webapp | Build 'test' image +# run: | +# docker build --target test -t "ocelotsocialnetwork/webapp:test" webapp/ +# docker save "ocelotsocialnetwork/webapp:test" > /tmp/webapp.tar - - name: Cache docker image - uses: actions/cache/save@v3.3.1 - with: - path: /tmp/webapp.tar - key: ${{ github.run_id }}-webapp-cache +# - name: Cache docker image +# uses: actions/cache/save@v3.3.1 +# with: +# path: /tmp/webapp.tar +# key: ${{ github.run_id }}-webapp-cache - lint_webapp: - name: Lint Webapp - if: needs.files-changed.outputs.webapp == 'true' - needs: files-changed - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 +# lint_webapp: +# name: Lint Webapp +# if: needs.files-changed.outputs.webapp == 'true' +# needs: files-changed +# runs-on: ubuntu-latest +# steps: +# - name: Checkout code +# uses: actions/checkout@v3 - - name: webapp | Lint - run: cd webapp && yarn && yarn run lint +# - name: webapp | Lint +# run: cd webapp && yarn && yarn run lint - unit_test_webapp: - name: Unit Tests - Webapp - if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true' - needs: [files-changed, build_test_webapp] - runs-on: ubuntu-latest - permissions: - checks: write - steps: - - name: Checkout code - uses: actions/checkout@v3 +# unit_test_webapp: +# name: Unit Tests - Webapp +# if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true' +# needs: [files-changed, build_test_webapp] +# runs-on: ubuntu-latest +# permissions: +# checks: write +# steps: +# - name: Checkout code +# uses: actions/checkout@v3 - - name: Restore webapp cache - uses: actions/cache/restore@v3.3.1 - with: - path: /tmp/webapp.tar - key: ${{ github.run_id }}-webapp-cache +# - name: Restore webapp cache +# uses: actions/cache/restore@v3.3.1 +# with: +# path: /tmp/webapp.tar +# key: ${{ github.run_id }}-webapp-cache - - name: Load Docker Image - run: docker load < /tmp/webapp.tar +# - name: Load Docker Image +# run: docker load < /tmp/webapp.tar - - name: Copy env files - run: | - cp webapp/.env.template webapp/.env - cp backend/.env.template backend/.env +# - name: Copy env files +# run: | +# cp webapp/.env.template webapp/.env +# cp backend/.env.template backend/.env - - name: backend | docker-compose - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp +# - name: backend | docker-compose +# run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp - - name: webapp | Unit tests incl. coverage check - run: docker-compose exec -T webapp yarn test +# - name: webapp | Unit tests incl. coverage check +# run: docker-compose exec -T webapp yarn test - cleanup: - name: Cleanup - if: (needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true') || success() - 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 - KEY="${{ github.run_id }}-webapp-cache" - gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm +# cleanup: +# name: Cleanup +# if: (needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true') || success() +# 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 +# KEY="${{ github.run_id }}-webapp-cache" +# gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm From ca721228cd768d1f1ae80456a8b85a7bf2e0061b Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 19:41:24 +0200 Subject: [PATCH 09/21] change backend cache deletion job dependency --- .github/workflows/test-backend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index 2d2c9bb6b..357a8f26e 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -127,7 +127,7 @@ jobs: cleanup: name: Cleanup - if: (needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.docker == 'true') || success() + if: ${{ needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.docker == 'true' }} needs: [files-changed, unit_test_backend] runs-on: ubuntu-latest continue-on-error: true From 991e5c5ec30338e1e93c5bf17c8d94f7d06a9dd1 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 19:55:27 +0200 Subject: [PATCH 10/21] make backend tests fail for testing --- .github/workflows/test-backend.yml | 2 +- backend/src/schema/resolvers/groups.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index 357a8f26e..64647dde7 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -123,7 +123,7 @@ jobs: run: docker-compose exec -T backend yarn db:migrate up - name: backend | Unit test incl. coverage check - run: docker-compose exec -T backend yarn test + run: docker-compose exec -T backend yarn test src/schema/resolvers/groups.spec.ts cleanup: name: Cleanup diff --git a/backend/src/schema/resolvers/groups.ts b/backend/src/schema/resolvers/groups.ts index cd1eb8db3..16d1ecc23 100644 --- a/backend/src/schema/resolvers/groups.ts +++ b/backend/src/schema/resolvers/groups.ts @@ -1,4 +1,4 @@ -import { v4 as uuid } from 'uuid' +import { v4TEST as uuid } from 'uuid' import { UserInputError } from 'apollo-server' import CONFIG from '../../config' import { CATEGORIES_MIN, CATEGORIES_MAX } from '../../constants/categories' From 0e73d53e9afbf7bbb2e1ef792fa1893da6088222 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 19:57:37 +0200 Subject: [PATCH 11/21] fix typo --- .github/workflows/test-backend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index 64647dde7..bda03edf3 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -100,7 +100,7 @@ jobs: uses: actions/cache/restore@v3.3.1 with: path: /tmp/backend.tar - key: ${{ github.run_id }}backend-cache + key: ${{ github.run_id }}-backend-cache fail-on-cache-miss: true - name: Load Docker Images From b712e3084ee22a6d4274f99c16f01f0dac9a1af1 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 20:26:09 +0200 Subject: [PATCH 12/21] Revert "make backend tests fail for testing" This reverts commit 991e5c5ec30338e1e93c5bf17c8d94f7d06a9dd1. --- .github/workflows/test-backend.yml | 2 +- backend/src/schema/resolvers/groups.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index bda03edf3..3f7559980 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -123,7 +123,7 @@ jobs: run: docker-compose exec -T backend yarn db:migrate up - name: backend | Unit test incl. coverage check - run: docker-compose exec -T backend yarn test src/schema/resolvers/groups.spec.ts + run: docker-compose exec -T backend yarn test cleanup: name: Cleanup diff --git a/backend/src/schema/resolvers/groups.ts b/backend/src/schema/resolvers/groups.ts index 16d1ecc23..cd1eb8db3 100644 --- a/backend/src/schema/resolvers/groups.ts +++ b/backend/src/schema/resolvers/groups.ts @@ -1,4 +1,4 @@ -import { v4TEST as uuid } from 'uuid' +import { v4 as uuid } from 'uuid' import { UserInputError } from 'apollo-server' import CONFIG from '../../config' import { CATEGORIES_MIN, CATEGORIES_MAX } from '../../constants/categories' From 715ab9d0cb0460c2cd6320a1b87f11da5bd97019 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 21:06:00 +0200 Subject: [PATCH 13/21] set webapp cache delete job wo run only, if needed jobs were successful --- .github/workflows/test-webapp.yml | 195 +++++++++++++++--------------- 1 file changed, 99 insertions(+), 96 deletions(-) diff --git a/.github/workflows/test-webapp.yml b/.github/workflows/test-webapp.yml index 0def21da3..364ad4796 100644 --- a/.github/workflows/test-webapp.yml +++ b/.github/workflows/test-webapp.yml @@ -1,115 +1,118 @@ -# name: ocelot.social webapp test CI +name: ocelot.social webapp test CI -# on: [push] +on: + push: + branches: + - fix-runner -# jobs: -# files-changed: -# name: Detect File Changes - Webapp -# runs-on: ubuntu-latest -# outputs: -# docker: ${{ steps.changes.outputs.docker }} -# webapp: ${{ steps.changes.outputs.webapp }} -# steps: -# - uses: actions/checkout@v3.3.0 +jobs: + files-changed: + name: Detect File Changes - Webapp + runs-on: ubuntu-latest + outputs: + docker: ${{ steps.changes.outputs.docker }} + webapp: ${{ steps.changes.outputs.webapp }} + steps: + - uses: actions/checkout@v3.3.0 -# - name: Check for frontend file changes -# uses: dorny/paths-filter@v2.11.1 -# id: changes -# with: -# token: ${{ github.token }} -# filters: .github/file-filters.yml -# list-files: shell + - name: Check for frontend file changes + uses: dorny/paths-filter@v2.11.1 + id: changes + with: + token: ${{ github.token }} + filters: .github/file-filters.yml + list-files: shell -# prepare: -# name: Prepare -# if: needs.files-changed.outputs.webapp == 'true' -# needs: files-changed -# runs-on: ubuntu-latest -# steps: -# - name: Checkout code -# uses: actions/checkout@v3 + prepare: + name: Prepare + if: needs.files-changed.outputs.webapp == 'true' + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 -# - name: Check translation files -# run: | -# scripts/translations/sort.sh -# scripts/translations/missing-keys.sh + - name: Check translation files + run: | + scripts/translations/sort.sh + scripts/translations/missing-keys.sh -# build_test_webapp: -# name: Docker Build Test - Webapp -# if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true' -# needs: [files-changed, prepare] -# runs-on: ubuntu-latest -# steps: -# - name: Checkout code -# uses: actions/checkout@v3 + build_test_webapp: + name: Docker Build Test - Webapp + if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true' + needs: [files-changed, prepare] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 -# - name: Webapp | Build 'test' image -# run: | -# docker build --target test -t "ocelotsocialnetwork/webapp:test" webapp/ -# docker save "ocelotsocialnetwork/webapp:test" > /tmp/webapp.tar + - name: Webapp | Build 'test' image + run: | + docker build --target test -t "ocelotsocialnetwork/webapp:test" webapp/ + docker save "ocelotsocialnetwork/webapp:test" > /tmp/webapp.tar -# - name: Cache docker image -# uses: actions/cache/save@v3.3.1 -# with: -# path: /tmp/webapp.tar -# key: ${{ github.run_id }}-webapp-cache + - name: Cache docker image + uses: actions/cache/save@v3.3.1 + with: + path: /tmp/webapp.tar + key: ${{ github.run_id }}-webapp-cache -# lint_webapp: -# name: Lint Webapp -# if: needs.files-changed.outputs.webapp == 'true' -# needs: files-changed -# runs-on: ubuntu-latest -# steps: -# - name: Checkout code -# uses: actions/checkout@v3 + lint_webapp: + name: Lint Webapp + if: needs.files-changed.outputs.webapp == 'true' + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 -# - name: webapp | Lint -# run: cd webapp && yarn && yarn run lint + - name: webapp | Lint + run: cd webapp && yarn && yarn run lint -# unit_test_webapp: -# name: Unit Tests - Webapp -# if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true' -# needs: [files-changed, build_test_webapp] -# runs-on: ubuntu-latest -# permissions: -# checks: write -# steps: -# - name: Checkout code -# uses: actions/checkout@v3 + unit_test_webapp: + name: Unit Tests - Webapp + if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true' + needs: [files-changed, build_test_webapp] + runs-on: ubuntu-latest + permissions: + checks: write + steps: + - name: Checkout code + uses: actions/checkout@v3 -# - name: Restore webapp cache -# uses: actions/cache/restore@v3.3.1 -# with: -# path: /tmp/webapp.tar -# key: ${{ github.run_id }}-webapp-cache + - name: Restore webapp cache + uses: actions/cache/restore@v3.3.1 + with: + path: /tmp/webapp.tar + key: ${{ github.run_id }}-webapp-cache -# - name: Load Docker Image -# run: docker load < /tmp/webapp.tar + - name: Load Docker Image + run: docker load < /tmp/webapp.tar -# - name: Copy env files -# run: | -# cp webapp/.env.template webapp/.env -# cp backend/.env.template backend/.env + - name: Copy env files + run: | + cp webapp/.env.template webapp/.env + cp backend/.env.template backend/.env -# - name: backend | docker-compose -# run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp + - name: backend | docker-compose + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp -# - name: webapp | Unit tests incl. coverage check -# run: docker-compose exec -T webapp yarn test + - name: webapp | Unit tests incl. coverage check + run: docker-compose exec -T webapp yarn test -# cleanup: -# name: Cleanup -# if: (needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true') || success() -# 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 -# KEY="${{ github.run_id }}-webapp-cache" -# gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm + cleanup: + name: Cleanup + if: ${{ needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true' }} + 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 + KEY="${{ github.run_id }}-webapp-cache" + gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm From b4383d38a10a609aa0c25b984785cd83ddfe6a89 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 21:10:54 +0200 Subject: [PATCH 14/21] set e2e test cache delete job wo run only, if needed jobs were successful --- .github/workflows/test-e2e.yml | 201 ++++++++++++++++----------------- 1 file changed, 100 insertions(+), 101 deletions(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 9eafcddaa..0012f15da 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -1,112 +1,111 @@ -# name: ocelot.social end-to-end test CI -# on: push +name: ocelot.social end-to-end test CI +on: push -# jobs: -# docker_preparation: -# name: Fullstack test preparation -# runs-on: ubuntu-latest -# steps: -# - name: Checkout code -# uses: actions/checkout@v3 +jobs: + docker_preparation: + name: Fullstack test preparation + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 -# - name: Copy env files -# run: | -# cp webapp/.env.template webapp/.env -# cp backend/.env.template backend/.env + - name: Copy env files + run: | + cp webapp/.env.template webapp/.env + cp backend/.env.template backend/.env -# - name: Build docker images -# run: | -# mkdir /tmp/images -# docker build --target community -t "ocelotsocialnetwork/neo4j-community:test" neo4j/ -# docker save "ocelotsocialnetwork/neo4j-community:test" > /tmp/images/neo4j.tar -# docker build --target test -t "ocelotsocialnetwork/backend:test" backend/ -# docker save "ocelotsocialnetwork/backend:test" > /tmp/images/backend.tar -# docker build --target test -t "ocelotsocialnetwork/webapp:test" webapp/ -# docker save "ocelotsocialnetwork/webapp:test" > /tmp/images/webapp.tar + - name: Build docker images + run: | + mkdir /tmp/images + docker build --target community -t "ocelotsocialnetwork/neo4j-community:test" neo4j/ + docker save "ocelotsocialnetwork/neo4j-community:test" > /tmp/images/neo4j.tar + docker build --target test -t "ocelotsocialnetwork/backend:test" backend/ + docker save "ocelotsocialnetwork/backend:test" > /tmp/images/backend.tar + docker build --target test -t "ocelotsocialnetwork/webapp:test" webapp/ + docker save "ocelotsocialnetwork/webapp:test" > /tmp/images/webapp.tar -# - name: Install cypress requirements -# run: | -# wget --no-verbose -O /opt/cucumber-json-formatter "https://github.com/cucumber/json-formatter/releases/download/v19.0.0/cucumber-json-formatter-linux-386" -# cd backend -# yarn install -# yarn build -# cd .. -# yarn install + - name: Install cypress requirements + run: | + wget --no-verbose -O /opt/cucumber-json-formatter "https://github.com/cucumber/json-formatter/releases/download/v19.0.0/cucumber-json-formatter-linux-386" + cd backend + yarn install + yarn build + cd .. + yarn install -# - name: Cache docker images -# id: cache -# uses: actions/cache/save@v3.3.1 -# with: -# path: | -# /opt/cucumber-json-formatter -# /home/runner/.cache/Cypress -# /home/runner/work/Ocelot-Social/Ocelot-Social -# /tmp/images/ -# key: ${{ github.run_id }}-e2e-preparation-cache + - name: Cache docker images + id: cache + uses: actions/cache/save@v3.3.1 + with: + path: | + /opt/cucumber-json-formatter + /home/runner/.cache/Cypress + /home/runner/work/Ocelot-Social/Ocelot-Social + /tmp/images/ + key: ${{ github.run_id }}-e2e-preparation-cache -# fullstack_tests: -# name: Fullstack tests -# if: success() -# needs: docker_preparation -# runs-on: ubuntu-latest -# env: -# jobs: 8 -# strategy: -# matrix: -# # run copies of the current job in parallel -# job: [1, 2, 3, 4, 5, 6, 7, 8] -# steps: -# - name: Restore cache -# uses: actions/cache/restore@v3.3.1 -# id: cache -# with: -# path: | -# /opt/cucumber-json-formatter -# /home/runner/.cache/Cypress -# /home/runner/work/Ocelot-Social/Ocelot-Social -# /tmp/images/ -# key: ${{ github.run_id }}e2e-preparation-cache -# fail-on-cache-miss: true + fullstack_tests: + name: Fullstack tests + if: success() + needs: docker_preparation + runs-on: ubuntu-latest + env: + jobs: 8 + strategy: + matrix: + # run copies of the current job in parallel + job: [1, 2, 3, 4, 5, 6, 7, 8] + steps: + - name: Restore cache + uses: actions/cache/restore@v3.3.1 + id: cache + with: + path: | + /opt/cucumber-json-formatter + /home/runner/.cache/Cypress + /home/runner/work/Ocelot-Social/Ocelot-Social + /tmp/images/ + key: ${{ github.run_id }}e2e-preparation-cache + fail-on-cache-miss: true -# - name: Boot up test system | docker-compose -# run: | -# chmod +x /opt/cucumber-json-formatter -# sudo ln -fs /opt/cucumber-json-formatter /usr/bin/cucumber-json-formatter -# docker load < /tmp/images/neo4j.tar -# docker load < /tmp/images/backend.tar -# docker load < /tmp/images/webapp.tar -# docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp neo4j backend -# sleep 90s + - name: Boot up test system | docker-compose + run: | + chmod +x /opt/cucumber-json-formatter + sudo ln -fs /opt/cucumber-json-formatter /usr/bin/cucumber-json-formatter + docker load < /tmp/images/neo4j.tar + docker load < /tmp/images/backend.tar + docker load < /tmp/images/webapp.tar + docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp neo4j backend + sleep 90s -# - name: Full stack tests | run tests -# id: e2e-tests -# run: yarn run cypress:run --spec $(cypress/parallel-features.sh ${{ matrix.job }} ${{ env.jobs }} ) + - name: Full stack tests | run tests + id: e2e-tests + run: yarn run cypress:run --spec $(cypress/parallel-features.sh ${{ matrix.job }} ${{ env.jobs }} ) -# - name: Full stack tests | if tests failed, compile html report -# if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} -# run: | -# cd cypress/ -# node create-cucumber-html-report.js + - name: Full stack tests | if tests failed, compile html report + if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} + run: | + cd cypress/ + node create-cucumber-html-report.js -# - name: Full stack tests | if tests failed, upload report -# id: e2e-report -# if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} -# uses: actions/upload-artifact@v3 -# with: -# name: ocelot-e2e-test-report-pr${{ needs.docker_preparation.outputs.pr-number }} -# path: /home/runner/work/Ocelot-Social/Ocelot-Social/cypress/reports/cucumber_html_report + - name: Full stack tests | if tests failed, upload report + id: e2e-report + if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} + uses: actions/upload-artifact@v3 + with: + name: ocelot-e2e-test-report-pr${{ needs.docker_preparation.outputs.pr-number }} + path: /home/runner/work/Ocelot-Social/Ocelot-Social/cypress/reports/cucumber_html_report -# cleanup: -# name: Cleanup -# if: success() -# 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 -# KEY="${{ github.run_id }}-e2e-preparation-cache" -# gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm \ No newline at end of file + cleanup: + name: Cleanup + 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 + KEY="${{ github.run_id }}-e2e-preparation-cache" + gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm \ No newline at end of file From d0a597b07d1b53da2f9210e45ba1998046a4db46 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 21:12:31 +0200 Subject: [PATCH 15/21] make e2e testing fail for testing --- .github/workflows/test-e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 0012f15da..2437f680c 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -70,7 +70,7 @@ jobs: - name: Boot up test system | docker-compose run: | - chmod +x /opt/cucumber-json-formatter + chmod +x /opt/cucumber-json-formatterTEST sudo ln -fs /opt/cucumber-json-formatter /usr/bin/cucumber-json-formatter docker load < /tmp/images/neo4j.tar docker load < /tmp/images/backend.tar From 7f5730edc8efec15c1d4f911346f752463bebe68 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 21:37:26 +0200 Subject: [PATCH 16/21] fix typo --- .github/workflows/test-e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 2437f680c..371765ec3 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -65,7 +65,7 @@ jobs: /home/runner/.cache/Cypress /home/runner/work/Ocelot-Social/Ocelot-Social /tmp/images/ - key: ${{ github.run_id }}e2e-preparation-cache + key: ${{ github.run_id }}-e2e-preparation-cache fail-on-cache-miss: true - name: Boot up test system | docker-compose From 2eb507170a0f6042921d4948d55f4343fef2b24b Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 21:59:22 +0200 Subject: [PATCH 17/21] Revert "make e2e testing fail for testing" This reverts commit d0a597b07d1b53da2f9210e45ba1998046a4db46. --- .github/workflows/test-e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 371765ec3..81c068ba5 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -70,7 +70,7 @@ jobs: - name: Boot up test system | docker-compose run: | - chmod +x /opt/cucumber-json-formatterTEST + chmod +x /opt/cucumber-json-formatter sudo ln -fs /opt/cucumber-json-formatter /usr/bin/cucumber-json-formatter docker load < /tmp/images/neo4j.tar docker load < /tmp/images/backend.tar From 09e887fc3c86e21258d7e697daae68c292ddb4d8 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 22:32:21 +0200 Subject: [PATCH 18/21] make workflows fail to stress test github cache deletion --- .../workflows/cleanup-cache-at-pr-closing.yml | 24 +++++++++++++++++++ .github/workflows/test-backend.yml | 2 +- .github/workflows/test-e2e.yml | 2 +- .github/workflows/test-webapp.yml | 2 +- 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/cleanup-cache-at-pr-closing.yml diff --git a/.github/workflows/cleanup-cache-at-pr-closing.yml b/.github/workflows/cleanup-cache-at-pr-closing.yml new file mode 100644 index 000000000..2171cc2d5 --- /dev/null +++ b/.github/workflows/cleanup-cache-at-pr-closing.yml @@ -0,0 +1,24 @@ +name: ocelot.social cache cleanup on pr closing + + +on: + pull_request: + types: + - closed + +jobs: + clean-branch-cache: + name: Clean branch cache + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh extension install actions/gh-actions-cache + gh actions-cache list --branch TODO:this_current_branch --order desc --sort created-at + # gh actions-cache delete -R Ocelot-Social-Community/Ocelot-Social --confirm diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index 3f7559980..a24a9415e 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -92,7 +92,7 @@ jobs: - name: Restore Neo4J cache uses: actions/cache/restore@v3.3.1 with: - path: /tmp/neo4j.tar + path: /tmp/neo4j.tarTEST key: ${{ github.run_id }}-backend-neo4j-cache fail-on-cache-miss: true diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 81c068ba5..059e758bf 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -61,7 +61,7 @@ jobs: id: cache with: path: | - /opt/cucumber-json-formatter + /opt/cucumber-json-formatterTEST /home/runner/.cache/Cypress /home/runner/work/Ocelot-Social/Ocelot-Social /tmp/images/ diff --git a/.github/workflows/test-webapp.yml b/.github/workflows/test-webapp.yml index 364ad4796..80b93f3f7 100644 --- a/.github/workflows/test-webapp.yml +++ b/.github/workflows/test-webapp.yml @@ -84,7 +84,7 @@ jobs: - name: Restore webapp cache uses: actions/cache/restore@v3.3.1 with: - path: /tmp/webapp.tar + path: /tmp/webapp.tarTEST key: ${{ github.run_id }}-webapp-cache - name: Load Docker Image From f348e18ce2330159b01ddbf1cc2b67bd9d22512c Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 22:54:14 +0200 Subject: [PATCH 19/21] Revert "make workflows fail to stress test github cache deletion" This reverts commit 09e887fc3c86e21258d7e697daae68c292ddb4d8. --- .../workflows/cleanup-cache-at-pr-closing.yml | 24 ------------------- .github/workflows/test-backend.yml | 2 +- .github/workflows/test-e2e.yml | 2 +- .github/workflows/test-webapp.yml | 2 +- 4 files changed, 3 insertions(+), 27 deletions(-) delete mode 100644 .github/workflows/cleanup-cache-at-pr-closing.yml diff --git a/.github/workflows/cleanup-cache-at-pr-closing.yml b/.github/workflows/cleanup-cache-at-pr-closing.yml deleted file mode 100644 index 2171cc2d5..000000000 --- a/.github/workflows/cleanup-cache-at-pr-closing.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: ocelot.social cache cleanup on pr closing - - -on: - pull_request: - types: - - closed - -jobs: - clean-branch-cache: - name: Clean branch cache - runs-on: ubuntu-latest - continue-on-error: true - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh extension install actions/gh-actions-cache - gh actions-cache list --branch TODO:this_current_branch --order desc --sort created-at - # gh actions-cache delete -R Ocelot-Social-Community/Ocelot-Social --confirm diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index a24a9415e..3f7559980 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -92,7 +92,7 @@ jobs: - name: Restore Neo4J cache uses: actions/cache/restore@v3.3.1 with: - path: /tmp/neo4j.tarTEST + path: /tmp/neo4j.tar key: ${{ github.run_id }}-backend-neo4j-cache fail-on-cache-miss: true diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 059e758bf..81c068ba5 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -61,7 +61,7 @@ jobs: id: cache with: path: | - /opt/cucumber-json-formatterTEST + /opt/cucumber-json-formatter /home/runner/.cache/Cypress /home/runner/work/Ocelot-Social/Ocelot-Social /tmp/images/ diff --git a/.github/workflows/test-webapp.yml b/.github/workflows/test-webapp.yml index 80b93f3f7..364ad4796 100644 --- a/.github/workflows/test-webapp.yml +++ b/.github/workflows/test-webapp.yml @@ -84,7 +84,7 @@ jobs: - name: Restore webapp cache uses: actions/cache/restore@v3.3.1 with: - path: /tmp/webapp.tarTEST + path: /tmp/webapp.tar key: ${{ github.run_id }}-webapp-cache - name: Load Docker Image From 3ffa8c9af5dbcb19dfef2d7335233492896a00ad Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 23:37:44 +0200 Subject: [PATCH 20/21] add recommended branch cache cleanup at pr closing workflow --- .../workflows/cleanup-cache-at-pr-closing.yml | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/cleanup-cache-at-pr-closing.yml diff --git a/.github/workflows/cleanup-cache-at-pr-closing.yml b/.github/workflows/cleanup-cache-at-pr-closing.yml new file mode 100644 index 000000000..284702e76 --- /dev/null +++ b/.github/workflows/cleanup-cache-at-pr-closing.yml @@ -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 }} \ No newline at end of file From aa7c54a052e723b5ad2e72d023ce471a4f13c0e1 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 18 Jul 2023 23:59:34 +0200 Subject: [PATCH 21/21] set back workflow triggers to push --- .github/workflows/test-backend.yml | 5 +---- .github/workflows/test-e2e.yml | 1 + .github/workflows/test-webapp.yml | 5 +---- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index 3f7559980..03e517826 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -1,10 +1,7 @@ name: ocelot.social backend test CI -on: - push: - branches: - - fix-runner +on: push jobs: files-changed: diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 81c068ba5..02d65ba9e 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -1,4 +1,5 @@ name: ocelot.social end-to-end test CI + on: push jobs: diff --git a/.github/workflows/test-webapp.yml b/.github/workflows/test-webapp.yml index 364ad4796..2b1e144a5 100644 --- a/.github/workflows/test-webapp.yml +++ b/.github/workflows/test-webapp.yml @@ -1,10 +1,7 @@ name: ocelot.social webapp test CI -on: - push: - branches: - - fix-runner +on: push jobs: files-changed: