mirror of
https://github.com/booklore-app/booklore.git
synced 2026-05-07 03:19:34 -04:00
a8cbf49bab
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6.2.0 to 6.4.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/6044e13b5dc448c55e2357c09f80417699197238...48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 6.4.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: acx10 <8075870+acx10@users.noreply.github.com>
263 lines
8.4 KiB
YAML
263 lines
8.4 KiB
YAML
name: Develop & PR – Build, Test, and Container Publish
|
||
|
||
on:
|
||
push:
|
||
branches:
|
||
- develop
|
||
pull_request:
|
||
branches:
|
||
- '**'
|
||
|
||
jobs:
|
||
migration-check:
|
||
name: Flyway Migration Check
|
||
uses: ./.github/workflows/migrations-check.yml
|
||
with:
|
||
base_ref: 'develop'
|
||
head_ref: 'HEAD'
|
||
|
||
backend-tests:
|
||
name: Backend Tests
|
||
needs: [ migration-check ]
|
||
if: needs.migration-check.result == 'success' || needs.migration-check.result == 'skipped'
|
||
runs-on: ubuntu-latest
|
||
|
||
permissions:
|
||
contents: read
|
||
checks: write
|
||
pull-requests: write
|
||
|
||
steps:
|
||
- name: Checkout Repository
|
||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||
|
||
- name: Set Up JDK 25
|
||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
|
||
with:
|
||
java-version: '25'
|
||
distribution: 'temurin'
|
||
cache: gradle
|
||
|
||
- name: Execute Backend Tests
|
||
id: backend_tests
|
||
working-directory: ./booklore-api
|
||
run: |
|
||
echo "Running backend tests..."
|
||
./gradlew test --no-daemon --parallel --build-cache
|
||
continue-on-error: true
|
||
|
||
- name: Publish Backend Test Results
|
||
uses: EnricoMi/publish-unit-test-result-action@c950f6fb443cb5af20a377fd0dfaa78838901040 # v2
|
||
if: always()
|
||
with:
|
||
files: booklore-api/build/test-results/**/*.xml
|
||
check_name: Backend Test Results
|
||
|
||
- name: Upload Backend Test Reports
|
||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||
if: always()
|
||
with:
|
||
name: backend-test-reports
|
||
path: |
|
||
booklore-api/build/reports/tests/
|
||
booklore-api/build/test-results/
|
||
retention-days: 30
|
||
|
||
- name: Validate Backend Test Results
|
||
if: steps.backend_tests.outcome == 'failure'
|
||
run: |
|
||
echo "❌ Backend tests failed"
|
||
exit 1
|
||
|
||
frontend-tests:
|
||
name: Frontend Tests
|
||
needs: [ migration-check ]
|
||
if: needs.migration-check.result == 'success' || needs.migration-check.result == 'skipped'
|
||
runs-on: ubuntu-latest
|
||
|
||
permissions:
|
||
contents: read
|
||
checks: write
|
||
pull-requests: write
|
||
|
||
steps:
|
||
- name: Checkout Repository
|
||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||
|
||
- name: Set Up Node.js
|
||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||
with:
|
||
node-version: '24'
|
||
cache: 'npm'
|
||
cache-dependency-path: booklore-ui/package-lock.json
|
||
|
||
- name: Install Frontend Dependencies
|
||
working-directory: ./booklore-ui
|
||
run: npm ci
|
||
|
||
- name: Audit Frontend Dependencies
|
||
working-directory: ./booklore-ui
|
||
run: npm audit --audit-level=high
|
||
|
||
- name: Validate Dependency Tree
|
||
working-directory: ./booklore-ui
|
||
run: npm ls --depth=0
|
||
|
||
|
||
- name: Execute Frontend Tests
|
||
id: frontend_tests
|
||
working-directory: ./booklore-ui
|
||
run: |
|
||
echo "Running frontend tests..."
|
||
npx ng test
|
||
continue-on-error: true
|
||
|
||
- name: Publish Frontend Test Results
|
||
uses: EnricoMi/publish-unit-test-result-action@c950f6fb443cb5af20a377fd0dfaa78838901040 # v2
|
||
if: always()
|
||
with:
|
||
files: booklore-ui/test-results/vitest-results.xml
|
||
check_name: Frontend Test Results
|
||
|
||
- name: Upload Frontend Test Reports
|
||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||
if: always()
|
||
with:
|
||
name: frontend-test-reports
|
||
path: |
|
||
booklore-ui/test-results/vitest-results.xml
|
||
retention-days: 30
|
||
|
||
- name: Validate Frontend Test Results
|
||
if: steps.frontend_tests.outcome == 'failure'
|
||
run: |
|
||
echo "❌ Frontend tests failed"
|
||
exit 1
|
||
|
||
build-and-push:
|
||
name: Build and Push Container
|
||
needs: [ backend-tests, frontend-tests ]
|
||
runs-on: ubuntu-latest
|
||
|
||
permissions:
|
||
contents: read
|
||
packages: write
|
||
|
||
steps:
|
||
- name: Checkout Repository
|
||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||
with:
|
||
fetch-depth: 0
|
||
|
||
# ----------------------------------------
|
||
# Image tagging
|
||
# ----------------------------------------
|
||
- name: Generate Image Tag
|
||
id: set_image_tag
|
||
run: |
|
||
short_sha=$(git rev-parse --short HEAD)
|
||
|
||
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
||
image_tag="pr-${{ github.event.pull_request.number }}-${short_sha}"
|
||
else
|
||
image_tag="develop-${short_sha}"
|
||
fi
|
||
|
||
echo "image_tag=$image_tag" >> $GITHUB_ENV
|
||
echo "Image tag: $image_tag"
|
||
|
||
# ----------------------------------------
|
||
# Native Angular build
|
||
# ----------------------------------------
|
||
- name: Set Up Node.js
|
||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||
with:
|
||
node-version: '24'
|
||
cache: 'npm'
|
||
cache-dependency-path: booklore-ui/package-lock.json
|
||
|
||
- name: Install Frontend Dependencies
|
||
working-directory: ./booklore-ui
|
||
run: npm ci
|
||
|
||
- name: Audit Frontend Dependencies
|
||
working-directory: ./booklore-ui
|
||
run: npm audit --audit-level=high
|
||
|
||
- name: Validate Dependency Tree
|
||
working-directory: ./booklore-ui
|
||
run: npm ls --depth=0
|
||
|
||
|
||
- name: Build Angular App
|
||
working-directory: ./booklore-ui
|
||
run: npx ng build --configuration=production
|
||
|
||
# ----------------------------------------
|
||
# Native Gradle build
|
||
# ----------------------------------------
|
||
- name: Set Up JDK 25
|
||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
|
||
with:
|
||
java-version: '25'
|
||
distribution: 'temurin'
|
||
cache: gradle
|
||
|
||
- name: Copy Angular Dist to Spring Boot Resources
|
||
run: cp -r booklore-ui/dist/booklore/browser/. booklore-api/src/main/resources/static/
|
||
|
||
- name: Inject Version into application.yaml
|
||
env:
|
||
APP_VERSION: ${{ env.image_tag }}
|
||
run: |
|
||
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.52.2/yq_linux_amd64
|
||
sudo chmod +x /usr/local/bin/yq
|
||
yq eval '.app.version = strenv(APP_VERSION)' -i booklore-api/src/main/resources/application.yaml
|
||
|
||
- name: Build Spring Boot JAR
|
||
working-directory: ./booklore-api
|
||
run: ./gradlew clean build -x test --no-daemon --parallel --build-cache
|
||
|
||
# ----------------------------------------
|
||
# Environment setup
|
||
# ----------------------------------------
|
||
- name: Set Up QEMU for Multi-Arch Builds
|
||
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
|
||
|
||
- name: Set Up Docker Buildx
|
||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
|
||
|
||
# ----------------------------------------
|
||
# Docker login (pushes & internal PRs only)
|
||
# ----------------------------------------
|
||
- name: Authenticate to GitHub Container Registry
|
||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
|
||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
||
with:
|
||
registry: ghcr.io
|
||
username: ${{ github.actor }}
|
||
password: ${{ github.token }}
|
||
|
||
# ----------------------------------------
|
||
# Docker build & push (push + internal PRs)
|
||
# ----------------------------------------
|
||
- name: Build and push Docker image
|
||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
|
||
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
|
||
with:
|
||
context: .
|
||
file: Dockerfile.ci
|
||
platforms: linux/amd64,linux/arm64
|
||
push: true
|
||
tags: |
|
||
ghcr.io/booklore-app/booklore:${{ env.image_tag }}
|
||
build-args: |
|
||
APP_VERSION=${{ env.image_tag }}
|
||
APP_REVISION=${{ github.sha }}
|
||
cache-from: |
|
||
type=gha
|
||
type=registry,ref=ghcr.io/booklore-app/booklore:buildcache
|
||
cache-to: |
|
||
type=gha,mode=max
|
||
type=registry,ref=ghcr.io/booklore-app/booklore:buildcache,mode=max
|