mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-19 09:13:25 +03:00
ci/cd: setup caching and improve ci job performance (#465)
This commit is contained in:
73
.github/workflows/e2e-tests.yml
vendored
73
.github/workflows/e2e-tests.yml
vendored
@@ -19,21 +19,28 @@ jobs:
|
|||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Build and export
|
- name: Build and export
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
tags: pocket-id/pocket-id:test
|
push: false
|
||||||
|
load: false
|
||||||
|
tags: pocket-id:test
|
||||||
outputs: type=docker,dest=/tmp/docker-image.tar
|
outputs: type=docker,dest=/tmp/docker-image.tar
|
||||||
build-args: BUILD_TAGS=e2etest
|
build-args: BUILD_TAGS=e2etest
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
- name: Upload Docker image artifact
|
- name: Upload Docker image artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: docker-image
|
name: docker-image
|
||||||
path: /tmp/docker-image.tar
|
path: /tmp/docker-image.tar
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
test-sqlite:
|
test-sqlite:
|
||||||
if: github.event.pull_request.head.ref != 'i18n_crowdin'
|
if: github.event.pull_request.head.ref != 'i18n_crowdin'
|
||||||
@@ -47,13 +54,22 @@ jobs:
|
|||||||
cache: "npm"
|
cache: "npm"
|
||||||
cache-dependency-path: frontend/package-lock.json
|
cache-dependency-path: frontend/package-lock.json
|
||||||
|
|
||||||
|
- name: Cache Playwright Browsers
|
||||||
|
uses: actions/cache@v3
|
||||||
|
id: playwright-cache
|
||||||
|
with:
|
||||||
|
path: ~/.cache/ms-playwright
|
||||||
|
key: ${{ runner.os }}-playwright-${{ hashFiles('frontend/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-playwright-
|
||||||
|
|
||||||
- name: Download Docker image artifact
|
- name: Download Docker image artifact
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: docker-image
|
name: docker-image
|
||||||
path: /tmp
|
path: /tmp
|
||||||
|
|
||||||
- name: Load Docker Image
|
- name: Load Docker image
|
||||||
run: docker load -i /tmp/docker-image.tar
|
run: docker load -i /tmp/docker-image.tar
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
- name: Install frontend dependencies
|
||||||
@@ -62,6 +78,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install Playwright Browsers
|
- name: Install Playwright Browsers
|
||||||
working-directory: ./frontend
|
working-directory: ./frontend
|
||||||
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
||||||
run: npx playwright install --with-deps chromium
|
run: npx playwright install --with-deps chromium
|
||||||
|
|
||||||
- name: Run Docker Container with Sqlite DB
|
- name: Run Docker Container with Sqlite DB
|
||||||
@@ -69,7 +86,7 @@ jobs:
|
|||||||
docker run -d --name pocket-id-sqlite \
|
docker run -d --name pocket-id-sqlite \
|
||||||
-p 80:80 \
|
-p 80:80 \
|
||||||
-e APP_ENV=test \
|
-e APP_ENV=test \
|
||||||
pocket-id/pocket-id:test
|
pocket-id:test
|
||||||
|
|
||||||
docker logs -f pocket-id-sqlite &> /tmp/backend.log &
|
docker logs -f pocket-id-sqlite &> /tmp/backend.log &
|
||||||
|
|
||||||
@@ -77,16 +94,18 @@ jobs:
|
|||||||
working-directory: ./frontend
|
working-directory: ./frontend
|
||||||
run: npx playwright test
|
run: npx playwright test
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- name: Upload Frontend Test Report
|
||||||
if: always()
|
uses: actions/upload-artifact@v4
|
||||||
|
if: always() && github.event.pull_request.head.ref != 'i18n_crowdin'
|
||||||
with:
|
with:
|
||||||
name: playwright-report-sqlite
|
name: playwright-report-sqlite
|
||||||
path: frontend/tests/.report
|
path: frontend/tests/.report
|
||||||
include-hidden-files: true
|
include-hidden-files: true
|
||||||
retention-days: 15
|
retention-days: 15
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- name: Upload Backend Test Report
|
||||||
if: always()
|
uses: actions/upload-artifact@v4
|
||||||
|
if: always() && github.event.pull_request.head.ref != 'i18n_crowdin'
|
||||||
with:
|
with:
|
||||||
name: backend-sqlite
|
name: backend-sqlite
|
||||||
path: /tmp/backend.log
|
path: /tmp/backend.log
|
||||||
@@ -105,12 +124,39 @@ jobs:
|
|||||||
cache: "npm"
|
cache: "npm"
|
||||||
cache-dependency-path: frontend/package-lock.json
|
cache-dependency-path: frontend/package-lock.json
|
||||||
|
|
||||||
|
- name: Cache Playwright Browsers
|
||||||
|
uses: actions/cache@v3
|
||||||
|
id: playwright-cache
|
||||||
|
with:
|
||||||
|
path: ~/.cache/ms-playwright
|
||||||
|
key: ${{ runner.os }}-playwright-${{ hashFiles('frontend/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-playwright-
|
||||||
|
|
||||||
|
- name: Cache PostgreSQL Docker image
|
||||||
|
uses: actions/cache@v3
|
||||||
|
id: postgres-cache
|
||||||
|
with:
|
||||||
|
path: /tmp/postgres-image.tar
|
||||||
|
key: postgres-17-${{ runner.os }}
|
||||||
|
|
||||||
|
- name: Pull and save PostgreSQL image
|
||||||
|
if: steps.postgres-cache.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
docker pull postgres:17
|
||||||
|
docker save postgres:17 > /tmp/postgres-image.tar
|
||||||
|
|
||||||
|
- name: Load PostgreSQL image from cache
|
||||||
|
if: steps.postgres-cache.outputs.cache-hit == 'true'
|
||||||
|
run: docker load < /tmp/postgres-image.tar
|
||||||
|
|
||||||
- name: Download Docker image artifact
|
- name: Download Docker image artifact
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: docker-image
|
name: docker-image
|
||||||
path: /tmp
|
path: /tmp
|
||||||
- name: Load Docker Image
|
|
||||||
|
- name: Load Docker image
|
||||||
run: docker load -i /tmp/docker-image.tar
|
run: docker load -i /tmp/docker-image.tar
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
- name: Install frontend dependencies
|
||||||
@@ -119,6 +165,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install Playwright Browsers
|
- name: Install Playwright Browsers
|
||||||
working-directory: ./frontend
|
working-directory: ./frontend
|
||||||
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
||||||
run: npx playwright install --with-deps chromium
|
run: npx playwright install --with-deps chromium
|
||||||
|
|
||||||
- name: Create Docker network
|
- name: Create Docker network
|
||||||
@@ -153,7 +200,7 @@ jobs:
|
|||||||
-e APP_ENV=test \
|
-e APP_ENV=test \
|
||||||
-e DB_PROVIDER=postgres \
|
-e DB_PROVIDER=postgres \
|
||||||
-e DB_CONNECTION_STRING=postgresql://postgres:postgres@pocket-id-db:5432/pocket-id \
|
-e DB_CONNECTION_STRING=postgresql://postgres:postgres@pocket-id-db:5432/pocket-id \
|
||||||
pocket-id/pocket-id:test
|
pocket-id:test
|
||||||
|
|
||||||
docker logs -f pocket-id-postgres &> /tmp/backend.log &
|
docker logs -f pocket-id-postgres &> /tmp/backend.log &
|
||||||
|
|
||||||
@@ -161,7 +208,8 @@ jobs:
|
|||||||
working-directory: ./frontend
|
working-directory: ./frontend
|
||||||
run: npx playwright test
|
run: npx playwright test
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- name: Upload Frontend Test Report
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
if: always() && github.event.pull_request.head.ref != 'i18n_crowdin'
|
if: always() && github.event.pull_request.head.ref != 'i18n_crowdin'
|
||||||
with:
|
with:
|
||||||
name: playwright-report-postgres
|
name: playwright-report-postgres
|
||||||
@@ -169,8 +217,9 @@ jobs:
|
|||||||
include-hidden-files: true
|
include-hidden-files: true
|
||||||
retention-days: 15
|
retention-days: 15
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- name: Upload Backend Test Report
|
||||||
if: always()
|
uses: actions/upload-artifact@v4
|
||||||
|
if: always() && github.event.pull_request.head.ref != 'i18n_crowdin'
|
||||||
with:
|
with:
|
||||||
name: backend-postgres
|
name: backend-postgres
|
||||||
path: /tmp/backend.log
|
path: /tmp/backend.log
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module github.com/pocket-id/pocket-id/backend
|
module github.com/pocket-id/pocket-id/backend
|
||||||
|
|
||||||
go 1.24
|
go 1.24.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/caarlos0/env/v11 v11.3.1
|
github.com/caarlos0/env/v11 v11.3.1
|
||||||
|
|||||||
Reference in New Issue
Block a user