This commit is contained in:
Michał Zieliński
2025-09-12 12:12:36 +02:00
parent ae6d2de4f6
commit 148bf73406
2 changed files with 55 additions and 89 deletions

View File

@@ -1,13 +1,9 @@
name: BuildApp name: BuildApp
on: on:
# push:
# branches: [ main ]
# pull_request:
#branches: [ main ]
workflow_dispatch: {} workflow_dispatch: {}
# (opcjonalnie) ogranicz równoległe runy # (opcjonalnie; jeśli coś krzyczy w Twojej wersji Gitei, usuń całą sekcję concurrency)
concurrency: concurrency:
group: build-${{ github.ref }} group: build-${{ github.ref }}
cancel-in-progress: false cancel-in-progress: false
@@ -24,14 +20,11 @@ jobs:
with: with:
node-version: 20 node-version: 20
# Zostawiamy jak u Ciebie, jeśli chcesz można też użyć corepack (pnpm) zamiast global install
- name: Install Angular CLI - name: Install Angular CLI
run: npm install -g @angular/cli run: npm install -g @angular/cli
- name: Install PNPM - name: Install PNPM
run: npm install -g pnpm run: npm install -g pnpm
# alternatywa:
# run: corepack enable && corepack prepare pnpm@latest --activate
- name: Install dependencies - name: Install dependencies
working-directory: src/Frontend working-directory: src/Frontend
@@ -45,8 +38,7 @@ jobs:
uses: https://github.com/actions/upload-artifact@v3 uses: https://github.com/actions/upload-artifact@v3
with: with:
name: frontend name: frontend
path: | path: src/Frontend/dist
src/Frontend/dist
if-no-files-found: error if-no-files-found: error
retention-days: 7 retention-days: 7
@@ -124,28 +116,41 @@ jobs:
if-no-files-found: error if-no-files-found: error
retention-days: 7 retention-days: 7
copy-artifacts: store-artifacts:
runs-on: ubuntu-latest runs-on: ubuntu-latest
- name: Upload artifact needs: [build-frontend, build-backend]
uses: actions/upload-artifact@v3 if: ${{ success() }}
steps:
- name: Download frontend artifacts
uses: https://github.com/actions/download-artifact@v3
with:
name: frontend
path: frontend
- name: Download webapi artifacts
uses: https://github.com/actions/download-artifact@v3
with: with:
name: webapi name: webapi
path: build/webapi path: webapi
- name: Store artifacts locally on runner - name: Store artifacts locally on runner
if: success() env:
BUILD_DIR: /runner-cache/builds/${{ github.run_id }}
run: | run: |
BUILD_DIR="/runner-cache/builds/$GITHUB_RUN_ID" set -euo pipefail
mkdir -p "$BUILD_DIR" mkdir -p "$BUILD_DIR"
cp -r webapi "$BUILD_DIR/"
cp -r build/webapi/ "$BUILD_DIR/" cp -r frontend "$BUILD_DIR/"
cp -r src/Frontend/dist/ "$BUILD_DIR/frontend/" mkdir -p /runner-cache/builds
ln -sfn "$BUILD_DIR" /runner-cache/builds/latest ln -sfn "$BUILD_DIR" /runner-cache/builds/latest
echo "BUILD_TIME=$(date -Iseconds)" > "$BUILD_DIR/build-info.txt" {
echo "COMMIT_SHA=${GITHUB_SHA}" >> "$BUILD_DIR/build-info.txt" echo "BUILD_TIME=$(date -Iseconds)"
echo "BRANCH=${GITHUB_REF_NAME}" >> "$BUILD_DIR/build-info.txt" echo "COMMIT_SHA=${GITHUB_SHA}"
echo "BUILD_ID=${GITHUB_RUN_ID}" >> "$BUILD_DIR/build-info.txt" echo "BRANCH=${GITHUB_REF_NAME}"
echo "BUILD_ID=${GITHUB_RUN_ID}"
ls -la "$BUILD_DIR/" } > "$BUILD_DIR/build-info.txt"
echo "Build artifacts stored in: $BUILD_DIR"
ls -la "$BUILD_DIR/"
echo "Symlink 'latest' -> $(readlink -f /runner-cache/builds/latest)"

View File

@@ -1,21 +1,21 @@
name: BuildApp name: BuildApp
on: on:
workflow_dispatch: {} push:
branches:
concurrency: - main
group: build-${{ github.ref }} pull_request:
cancel-in-progress: false branches:
- main
workflow_dispatch:
jobs: jobs:
build-frontend: build-frontend:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - uses: actions/checkout@v4
uses: https://github.com/actions/checkout@v4
- name: Use Node.js 20 - name: Use Node.js 20
uses: https://github.com/actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 20 node-version: 20
@@ -33,22 +33,19 @@ jobs:
working-directory: src/Frontend working-directory: src/Frontend
run: ng build --configuration=production run: ng build --configuration=production
- name: Upload artifact (frontend) - name: Upload artifact
uses: https://github.com/actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: frontend name: frontend
path: src/Frontend/dist path: src/Frontend/dist
if-no-files-found: error
retention-days: 7
build-backend: build-backend:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - uses: actions/checkout@v4
uses: https://github.com/actions/checkout@v4
- name: Setup .NET 8 - name: Setup .NET 8
uses: https://github.com/actions/setup-dotnet@v4 uses: actions/setup-dotnet@v4
with: with:
dotnet-version: 8.0.x dotnet-version: 8.0.x
@@ -59,12 +56,13 @@ jobs:
- name: Build solution and prepare plugins - name: Build solution and prepare plugins
working-directory: src/Backend working-directory: src/Backend
run: | run: |
set -e
dotnet build DiunaBI.sln --configuration Release dotnet build DiunaBI.sln --configuration Release
dotnet build DiunaBI.Plugins.Morska/DiunaBI.Plugins.Morska.csproj --configuration Release dotnet build DiunaBI.Plugins.Morska/DiunaBI.Plugins.Morska.csproj --configuration Release
# Przygotuj katalog dla testów
mkdir -p DiunaBI.Tests/bin/Release/net8.0/Plugins mkdir -p DiunaBI.Tests/bin/Release/net8.0/Plugins
cp DiunaBI.Plugins.Morska/bin/Release/net8.0/DiunaBI.Plugins.Morska.dll DiunaBI.Tests/bin/Release/net8.0/Plugins/ cp DiunaBI.Plugins.Morska/bin/Release/net8.0/DiunaBI.Plugins.Morska.dll DiunaBI.Tests/bin/Release/net8.0/Plugins/
cp DiunaBI.Plugins.Morska/bin/Release/net8.0/DiunaBI.Core.dll DiunaBI.Tests/bin/Release/net8.0/Plugins/ cp DiunaBI.Plugins.Morska/bin/Release/net8.0/DiunaBI.Core.dll DiunaBI.Tests/bin/Release/net8.0/Plugins/
echo "✅ Plugins copied to test directory:"
ls -la DiunaBI.Tests/bin/Release/net8.0/Plugins/ ls -la DiunaBI.Tests/bin/Release/net8.0/Plugins/
- name: Run Tests - name: Run Tests
@@ -79,14 +77,13 @@ jobs:
--filter "Category!=LocalOnly" --filter "Category!=LocalOnly"
- name: Publish Test Results - name: Publish Test Results
uses: https://github.com/actions/upload-artifact@v3 uses: actions/upload-artifact@v4
if: success() || failure() if: success() || failure()
with: with:
name: test-results name: test-results
path: | path: |
src/Backend/DiunaBI.Tests/TestResults/*.trx src/Backend/DiunaBI.Tests/TestResults/*.trx
src/Backend/DiunaBI.Tests/TestResults/**/coverage.cobertura.xml src/Backend/DiunaBI.Tests/TestResults/**/coverage.cobertura.xml
retention-days: 7
- name: Publish WebAPI - name: Publish WebAPI
if: success() if: success()
@@ -97,56 +94,20 @@ jobs:
--framework net8.0 \ --framework net8.0 \
--self-contained false \ --self-contained false \
--output ../../build/webapi --output ../../build/webapi
# Kopiuj pluginy do katalogu webapi
mkdir -p ../../build/webapi/Plugins mkdir -p ../../build/webapi/Plugins
cp DiunaBI.Plugins.Morska/bin/Release/net8.0/DiunaBI.Plugins.Morska.dll ../../build/webapi/Plugins/ cp DiunaBI.Plugins.Morska/bin/Release/net8.0/DiunaBI.Plugins.Morska.dll ../../build/webapi/Plugins/
echo "✅ Plugins copied to webapi:"
ls -la ../../build/webapi/Plugins/ ls -la ../../build/webapi/Plugins/
- name: Clean up sensitive files - name: Clean up sensitive files
working-directory: build/webapi working-directory: build/webapi
run: | run: |
rm -f appsettings.Development.json || true rm -f appsettings.Development.json
rm -f client_secrets.Development.json || true rm -f client_secrets.Development.json
- name: Upload artifact (webapi) - name: Upload artifact
uses: https://github.com/actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: webapi name: webapi
path: build/webapi path: build/webapi
if-no-files-found: error
retention-days: 7
store-artifacts:
runs-on: ubuntu-latest
needs: [build-frontend, build-backend]
if: success()
steps:
- name: Download frontend artifacts
uses: https://github.com/actions/download-artifact@v3
with:
name: frontend
path: frontend
- name: Download webapi artifacts
uses: https://github.com/actions/download-artifact@v3
with:
name: webapi
path: webapi
- name: Store artifacts locally on runner
run: |
BUILD_DIR="/runner-cache/builds/$GITHUB_RUN_ID"
mkdir -p "$BUILD_DIR"
cp -r webapi/ "$BUILD_DIR/"
cp -r frontend/ "$BUILD_DIR/"
mkdir -p /runner-cache/builds
ln -sfn "$BUILD_DIR" /runner-cache/builds/latest
echo "BUILD_TIME=$(date -Iseconds)" > "$BUILD_DIR/build-info.txt"
echo "COMMIT_SHA=${GITHUB_SHA}" >> "$BUILD_DIR/build-info.txt"
echo "BRANCH=${GITHUB_REF_NAME}" >> "$BUILD_DIR/build-info.txt"
echo "BUILD_ID=${GITHUB_RUN_ID}" >> "$BUILD_DIR/build-info.txt"
echo "Build artifacts stored in: $BUILD_DIR"
ls -la "$BUILD_DIR/"