From f7946d4289eb6ddaf1cfe1f699a08b953498f4e6 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 3 Jan 2025 23:25:54 +1100 Subject: [PATCH] Cache page assets during CI/CD --- .gitea/workflows/build_docker.yaml | 99 ++++++++++++++++++++---------- 1 file changed, 65 insertions(+), 34 deletions(-) diff --git a/.gitea/workflows/build_docker.yaml b/.gitea/workflows/build_docker.yaml index 12cdca3..3b8c3ca 100644 --- a/.gitea/workflows/build_docker.yaml +++ b/.gitea/workflows/build_docker.yaml @@ -6,32 +6,39 @@ env: DOCKER_HOST: tcp://127.0.0.1:2375 jobs: -# test: -# strategy: -# matrix: -# arch: -# - x86_64 -# # arm64 -# -# name: Test Application -# runs-on: docker-${{ matrix.arch }} -# container: -# image: docker:dind -# privileged: true -# -# steps: -# - name: Environment Setup -# run: | -# # If we have a proxy use it -# if [ -n "${HTTP_PROXY}" ]; then echo "HTTP PROXY [${HTTP_PROXY}]"; sed -i -e s'/https/http/' /etc/apk/repositories; fi -# # Some pre-reqs -# apk add git nodejs npm -# ## Some debugging info -# # env|sort -# -# - name: Code Checkout -# uses: actions/checkout@v4 -# + test: + strategy: + matrix: + arch: + - x86_64 + # arm64 + + name: Test Application + runs-on: docker-${{ matrix.arch }} + container: + image: docker:dind + privileged: true + + steps: + - name: Environment Setup + run: | + # If we have a proxy use it + if [ -n "${HTTP_PROXY}" ]; then echo "HTTP PROXY [${HTTP_PROXY}]"; sed -i -e s'/https/http/' /etc/apk/repositories; fi + # Some pre-reqs + apk add git nodejs npm + ## Some debugging info + # env|sort + + - name: Code Checkout + uses: actions/checkout@v4 + + - name: Build Assets + run: | + # Build assets + npm i + npm run prod + ls -al public/css/app.css + # - name: Run Tests # run: | # mv .env.testing .env @@ -43,19 +50,29 @@ jobs: # php artisan key:generate # php artisan migrate # php artisan db:seed -# # Build assets -# npm i -# npm run prod # # run laravel tests # # XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text --colors=never + - name: Cache page assets + id: cache-page-assets + uses: actions/cache@v3 + env: + cache-name: page-assets + with: + path: | + public/css/app.css + key: + ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + build: strategy: matrix: arch: - x86_64 - arm64 -# needs: [test] + needs: [test] name: Build Docker Image runs-on: docker-${{ matrix.arch }} @@ -95,11 +112,25 @@ jobs: - name: Code Checkout uses: actions/checkout@v4 - - name: Build Assets + - name: Cache page assets + id: cache-page-assets + uses: actions/cache@v3 + env: + cache-name: page-assets + with: + path: | + public/css/app.css + key: + ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + + - if: ${{ steps.cache-page-assets.outputs.cache-hit != 'true' }} + name: List the state of page assets + continue-on-error: false run: | - # Build assets - npm i - npm run prod + ls -al + ls -al public/css/ - name: Record version and Delete Unnecessary files run: |