From ebb308c7d3f0700d60c4f37b9832c7c5369c5e66 Mon Sep 17 00:00:00 2001 From: Ola Bekkevold Date: Wed, 25 Mar 2026 12:30:24 +0100 Subject: [PATCH 1/8] feat: cache playwright browsers in order to reduce running time the playwright browser binaries will be cached instead of downloading each time Refs: #72 --- .github/workflows/test.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cf2b293..e9043fc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,7 @@ name: Tests on: push: - branches: [ main, develop, test ] + branches: [ main, develop, test, 72-change-workflow-structure ] pull_request: branches: [ main, develop, test ] @@ -48,11 +48,20 @@ jobs: run: npx tsx src/lib/db/testDb.ts env: NODE_ENV: test - + + - name: Cache Playwright browsers + uses: actions/cache@v4 + id: playwright-cache + with: + path: /root/.cache/ms-playwright + key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-playwright- - name: Install Playwright Browsers env: HOME: /root + if: steps.playwright-cache.outputs.cache-hit != 'true' run: npx playwright install --with-deps - name: Run tests From 7695814a5b29bf176d15871544adf4e79b340acc Mon Sep 17 00:00:00 2001 From: Ola Bekkevold Date: Wed, 25 Mar 2026 12:34:48 +0100 Subject: [PATCH 2/8] feat: run to test cache Refs: #72 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e9043fc..4c8ca64 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,7 @@ jobs: --health-retries 5 steps: - # Downloads a copy of the code in your repository before running CI tests + # Downloads a copy of the code in your repository before running CI test - name: Check out repository code uses: actions/checkout@v5 From 58d71a533dc95394724ee09fc4ead2592f7066f6 Mon Sep 17 00:00:00 2001 From: Ola Bekkevold Date: Wed, 25 Mar 2026 12:46:21 +0100 Subject: [PATCH 3/8] feat: install non-cacheable dependices seperately Refs: #72 --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4c8ca64..1f72b93 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,6 +49,9 @@ jobs: env: NODE_ENV: test + - name: Install Playwright system dependencies + run: npx playwright install-deps + - name: Cache Playwright browsers uses: actions/cache@v4 id: playwright-cache @@ -62,7 +65,7 @@ jobs: env: HOME: /root if: steps.playwright-cache.outputs.cache-hit != 'true' - run: npx playwright install --with-deps + run: npx playwright install - name: Run tests env: From cfdb2d8f5ced738b8726a65553dab2e801998b68 Mon Sep 17 00:00:00 2001 From: Ola Bekkevold Date: Wed, 25 Mar 2026 13:04:26 +0100 Subject: [PATCH 4/8] feat: add caching for node modules in workflow Refs: #72 --- .github/workflows/test.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1f72b93..723f2a7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,8 +38,24 @@ jobs: - name: Check out repository code uses: actions/checkout@v5 + - name: Cache node modules + id: cache-npm + uses: actions/cache@v4 + with: + path: ~/.npm + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-npm- + ${{ runner.os }}- + + + - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} + name: List the state of node modules + continue-on-error: true + run: npm list + - name: Install dependencies - run: npm install + run: npm ci - name: Create database run: npm run migrate:test From f4085f9d7300f254b641ba3e20289883c838de0f Mon Sep 17 00:00:00 2001 From: Ola Bekkevold Date: Wed, 25 Mar 2026 13:16:07 +0100 Subject: [PATCH 5/8] feat: test npm cache Refs: #72 --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 723f2a7..41d2436 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,6 @@ jobs: --health-retries 5 steps: - # Downloads a copy of the code in your repository before running CI test - name: Check out repository code uses: actions/checkout@v5 From 36af4599ba38cf38757e75ef923f8e0e9ae7d498 Mon Sep 17 00:00:00 2001 From: Ola Bekkevold Date: Wed, 25 Mar 2026 14:07:58 +0100 Subject: [PATCH 6/8] feat: remove uneccesary step Refs: #72 --- .github/workflows/test.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 41d2436..4e5fcad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,12 +46,6 @@ jobs: restore-keys: | ${{ runner.os }}-npm- ${{ runner.os }}- - - - - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} - name: List the state of node modules - continue-on-error: true - run: npm list - name: Install dependencies run: npm ci From 42ae08b1d93cea6c2f829e413c282c46402332e3 Mon Sep 17 00:00:00 2001 From: Ola Bekkevold Date: Wed, 25 Mar 2026 15:28:55 +0100 Subject: [PATCH 7/8] feat: combine workflows move tests and deploy jobs into the same workflow which will allow easier control Refs: #72 --- .github/workflows/build-push.yml | 58 ------------------- .../{test.yml => test-build-push.yml} | 47 +++++++++++++++ 2 files changed, 47 insertions(+), 58 deletions(-) delete mode 100644 .github/workflows/build-push.yml rename .github/workflows/{test.yml => test-build-push.yml} (62%) diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml deleted file mode 100644 index b98d99c..0000000 --- a/.github/workflows/build-push.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Build and push docker image to GHCR -on: - workflow_run: - workflows: ["Tests"] - types: - - completed - branches: [main, test] - -jobs: - build-and-push: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - - steps: - - name: Checkout - uses: actions/checkout@v5 - with: - ref: ${{ github.event.workflow_run.head_sha }} - - - name: Log in to container registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: olabekkevold - password: ${{ secrets.PAT }} - - - name: Get version from package.json - id: version - run: | - VERSION=$(jq -r '.version' ./labman/package.json) - echo "VERSION=$VERSION" >> $GITHUB_OUTPUT - echo "Version: $VERSION" - - - name: Determine image tag - id: tag - run: | - BRANCH="${{ github.event.workflow_run.head_branch }}" - if [ "$BRANCH" = "main" ]; then - echo "env_tag=latest" >> $GITHUB_OUTPUT - else - echo "env_tag=test" >> $GITHUB_OUTPUT - fi - echo "Image tag: ${{ steps.tag.outputs.env_tag }}" - - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - context: ./labman - push: true - tags: | - ghcr.io/olabekkevold/labmanager:${{ steps.tag.outputs.env_tag }} - ghcr.io/olabekkevold/labmanager:${{ github.sha }} - build-args: | - NEXT_PUBLIC_VERSION=${{ steps.version.outputs.VERSION }} - NEXT_PUBLIC_ENV=${{ steps.tag.outputs.env_tag }} - - - diff --git a/.github/workflows/test.yml b/.github/workflows/test-build-push.yml similarity index 62% rename from .github/workflows/test.yml rename to .github/workflows/test-build-push.yml index 4e5fcad..a34556e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test-build-push.yml @@ -102,3 +102,50 @@ jobs: - name: Run Vitest run: npm run test + + + build-and-push: + runs-on: ubuntu-latest + needs: [vitest, playwright] + if: ${{ needs.vitest.result == 'success' && needs.playwright.result == 'success' && github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/test')}} + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Log in to container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: olabekkevold + password: ${{ secrets.PAT }} + + - name: Get version from package.json + id: version + run: | + VERSION=$(jq -r '.version' ./labman/package.json) + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + echo "Version: $VERSION" + + - name: Determine image tag + id: tag + run: | + + if [ "${{ github.ref }}" = "refs/heads/main" ]; then + echo "env_tag=latest" >> $GITHUB_OUTPUT + else + echo "env_tag=test" >> $GITHUB_OUTPUT + fi + echo "Image tag: ${{ steps.tag.outputs.env_tag }}" + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: ./labman + push: true + tags: | + ghcr.io/olabekkevold/labmanager:${{ steps.tag.outputs.env_tag }} + ghcr.io/olabekkevold/labmanager:${{ github.sha }} + build-args: | + NEXT_PUBLIC_VERSION=${{ steps.version.outputs.VERSION }} + NEXT_PUBLIC_ENV=${{ steps.tag.outputs.env_tag }} From 9b66f648a8bbb697fd865ed69604d9836e1f3d0b Mon Sep 17 00:00:00 2001 From: Ola Bekkevold Date: Wed, 25 Mar 2026 15:45:57 +0100 Subject: [PATCH 8/8] feat: rename workflow Refs: #72 --- .github/workflows/test-build-push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-build-push.yml b/.github/workflows/test-build-push.yml index a34556e..2b171f2 100644 --- a/.github/workflows/test-build-push.yml +++ b/.github/workflows/test-build-push.yml @@ -1,7 +1,7 @@ -name: Tests +name: Test, Build and Push Docker Image on: push: - branches: [ main, develop, test, 72-change-workflow-structure ] + branches: [ main, develop, test ] pull_request: branches: [ main, develop, test ]