diff --git a/.github/workflows/ci-optimized.yml b/.github/workflows/ci-optimized.yml new file mode 100644 index 0000000..c865e4b --- /dev/null +++ b/.github/workflows/ci-optimized.yml @@ -0,0 +1,93 @@ +name: CI - Optimized + +on: + push: + branches: [ main ] + pull_request: + +jobs: + + backend: + name: Backend (.NET) + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + + - name: Cache NuGet packages + uses: actions/cache@v4 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('lab5/sample-ci/backend/**/*.csproj') }} + + - name: Restore + run: | + cd lab5/sample-ci/backend/ProductApi + dotnet restore + cd ../ProductApi.Tests + dotnet restore + + - name: Build + run: | + cd lab5/sample-ci/backend/ProductApi + dotnet build --no-restore --configuration Release + cd ../ProductApi.Tests + dotnet build --no-restore --configuration Release + + - name: Test + run: | + cd lab5/sample-ci/backend/ProductApi.Tests + dotnet test --no-build --configuration Release --logger trx + + - name: Publish + run: | + cd lab5/sample-ci/backend/ProductApi + dotnet publish --no-build --configuration Release --output ./publish + + - name: Upload backend artifact + uses: actions/upload-artifact@v4 + with: + name: backend + path: lab5/sample-ci/backend/ProductApi/publish + + frontend: + name: Frontend (Node.js) + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: lab5/sample-ci/frontend/package-lock.json + + - name: Install dependencies + run: | + cd lab5/sample-ci/frontend + npm ci + + - name: Run tests + run: | + cd lab5/sample-ci/frontend + npm test + + - name: Build + run: | + cd lab5/sample-ci/frontend + npm run build + + - name: Upload frontend artifact + uses: actions/upload-artifact@v4 + with: + name: frontend + path: lab5/sample-ci/frontend/dist diff --git a/lab5/sample-ci/README.md b/lab5/sample-ci/README.md index 024de05..1cf1496 100644 Binary files a/lab5/sample-ci/README.md and b/lab5/sample-ci/README.md differ diff --git a/lab5/sample-ci/frontend/index.html b/lab5/sample-ci/frontend/index.html index ece0929..4cc6904 100644 --- a/lab5/sample-ci/frontend/index.html +++ b/lab5/sample-ci/frontend/index.html @@ -53,5 +53,9 @@