145 lines
4.2 KiB
YAML
145 lines
4.2 KiB
YAML
name: CI compile & test & build
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
|
|
jobs:
|
|
ci-fe:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Setup Node.js 24.x
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 24.x
|
|
- name: Cache NPM packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
key: npm-${{ hashFiles('./frontend/yarn.lock') }}
|
|
path: |
|
|
./frontend/node_modules
|
|
restore-keys: |
|
|
npm-${{ hashFiles('./frontend/yarn.lock') }}
|
|
npm-
|
|
- name: Yarn Install
|
|
run: |
|
|
cd ./frontend
|
|
yarn install --frozen-lockfile
|
|
- name: Yarn Test
|
|
run: |
|
|
cd ./frontend
|
|
yarn run test
|
|
- name: Yarn Lint
|
|
run: |
|
|
cd ./frontend
|
|
yarn run lint
|
|
|
|
docker-fe-build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
attestations: write
|
|
id-token: write
|
|
outputs:
|
|
image_tag: ${{ steps.image-tag.outputs.image_tag }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-buildx-action@v3
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Compute frontend image tag
|
|
id: image-tag
|
|
run: echo "image_tag=ghcr.io/${{ github.repository_owner }}/kemkas-frontend:${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
|
|
- name: Build and push frontend image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./frontend/
|
|
file: ./frontend/Dockerfile
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
push: true
|
|
tags: |
|
|
${{ steps.image-tag.outputs.image_tag }}
|
|
|
|
docker-e2e-build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
attestations: write
|
|
id-token: write
|
|
outputs:
|
|
image_tag: ${{ steps.image-tag.outputs.image_tag }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-buildx-action@v3
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Compute e2e image tag
|
|
id: image-tag
|
|
run: echo "image_tag=ghcr.io/${{ github.repository_owner }}/kemkas-e2e:${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
|
|
- name: Build and push e2e image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./e2e/
|
|
file: ./e2e/Dockerfile
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
push: true
|
|
tags: |
|
|
${{ steps.image-tag.outputs.image_tag }}
|
|
|
|
ci-e2e-docker:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- docker-fe-build
|
|
- docker-e2e-build
|
|
permissions:
|
|
contents: read
|
|
packages: read
|
|
env:
|
|
BACKEND_IMAGE: ${{ vars.BACKEND_IMAGE || 'ghcr.io/morbalint/kemkas-backend:b8565f8e' }}
|
|
FRONTEND_IMAGE: ${{ needs.docker-fe-build.outputs.image_tag }}
|
|
E2E_IMAGE: ${{ needs.docker-e2e-build.outputs.image_tag }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Pull images for test run
|
|
run: docker compose -f docker-compose.e2e.yaml pull
|
|
- name: Run Docker Compose E2E tests
|
|
run: docker compose -f docker-compose.e2e.yaml up --no-build --abort-on-container-exit --exit-code-from e2e e2e
|
|
- name: Upload Playwright HTML report
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: playwright-report
|
|
path: e2e/playwright-report
|
|
if-no-files-found: ignore
|
|
- name: Upload Playwright test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: playwright-test-results
|
|
path: e2e/test-results
|
|
if-no-files-found: ignore
|
|
- name: Tear down Docker Compose stack
|
|
if: always()
|
|
run: docker compose -f docker-compose.e2e.yaml down -v --remove-orphans
|