Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ZCH-126): caching #118

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions .github/actions/dotnet/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,32 @@ inputs:
SHELL:
required: false
type: string
default: 'bash'
default: "bash"
CACHE_SUFFIX:
required: false
type: string
default: ""

runs:
using: composite
steps:
- name: Restore NuGet packages cache
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: ${{ runner.os }}-nuget-
# - name: Restore NuGet packages cache
# uses: actions/cache@v4
# with:
# path: ~/.nuget/packages
# key: ${{ runner.os }}-nuget-${{ github.run_id }}-${{ github.run_attempt }} # Temporary fix: ${{ hashFiles(format('{0}/**/packages.lock.json', inputs.WORKING_DIRECTORY)) }}
# restore-keys: ${{ runner.os }}-nuget-
# - name: Create folder if not exist
# shell: bash
# run: mkdir -p ~/.nuget/packages${{ inputs.CACHE_SUFFIX }}

# - name: Restore NuGet packages cache
# uses: actions/cache@v3
# with:
# path: ~/.nuget/packages${{ inputs.CACHE_SUFFIX }}
# # key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
# key: ${{ runner.os }}-nuget-${{ github.run_id }}-${{ github.run_attempt }} # Temporary fix: ${{ hashFiles(format('{0}/**/packages.lock.json', inputs.WORKING_DIRECTORY)) }}
# restore-keys: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}

- name: Restore dependencies
shell: ${{ inputs.SHELL }}
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/dotnet/release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ inputs:
SHELL:
required: false
type: string
default: 'bash'
default: "bash"

runs:
using: composite
steps:
- name: Build
uses: zupit-it/pipeline-templates/.github/actions/dotnet/build@v1.24.0
uses: zupit-it/pipeline-templates/.github/actions/dotnet/build@ZCH-126/caching
with:
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}
BUILD_CONFIG: ${{ inputs.BUILD_CONFIG }}
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/dotnet-step-azure-webapp-build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:
RUN_ON:
required: false
type: string
default: 'zupit-agents'
default: "zupit-agents"
RUNNERS_CONTAINER_GROUP:
required: false
type: string
default: 'Container'
default: "Container"
RELEASE_ENVIRONMENT:
required: true
type: string
Expand All @@ -26,21 +26,20 @@ on:
CHECKOUT_REF:
required: false
type: string
default: ''
default: ""
ENV_VARIABLES:
required: false
type: string
default: '{}'
default: "{}"
DOTNET_IMAGE:
required: false
type: string
default: 'mcr.microsoft.com/dotnet/sdk:7.0'
default: "mcr.microsoft.com/dotnet/sdk:7.0"
AZURE_CLI_IMAGE:
required: false
type: string
default: "mcr.microsoft.com/azure-cli:2.50.0"


env: "${{secrets}}"

jobs:
Expand Down Expand Up @@ -72,7 +71,7 @@ jobs:
NAME_PREFIX: dotnet-build

- name: Build
uses: zupit-it/pipeline-templates/.github/actions/dotnet/release@v1.24.0
uses: zupit-it/pipeline-templates/.github/actions/dotnet/release@ZCH-126/caching
with:
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}
BUILD_CONFIG: "Release"
Expand All @@ -94,7 +93,7 @@ jobs:
container:
image: ${{ inputs.AZURE_CLI_IMAGE }}

needs: [ build ]
needs: [build]
steps:
- name: Download build artifact
id: output-folder
Expand All @@ -106,6 +105,6 @@ jobs:
uses: zupit-it/pipeline-templates/.github/actions/azure/app-service/[email protected]
with:
WORKING_DIRECTORY: ${{ steps.output-folder.outputs.OUTPUT_FOLDER }}
BINARIES_DIRECTORY: ''
BINARIES_DIRECTORY: ""
AZURE_CREDENTIALS: ${{ secrets.CI_AZURE_CREDENTIALS }}
WEBAPP_NAME: ${{ inputs.WEBAPP_NAME }}
7 changes: 6 additions & 1 deletion .github/workflows/dotnet-workflow-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ on:
required: false
type: string
default: "all"
CACHE_SUFFIX:
required: false
type: string
default: ""

env:
CHECK_DIR: ${{ inputs.WORKING_DIRECTORY }}
Expand Down Expand Up @@ -96,10 +100,11 @@ jobs:
CSHARPIER_VERSION: ${{ inputs.CSHARPIER_VERSION }}

- name: Build
uses: zupit-it/pipeline-templates/.github/actions/dotnet/build@v1.24.0
uses: zupit-it/pipeline-templates/.github/actions/dotnet/build@ZCH-126/caching
with:
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}
BUILD_CONFIG: "Debug"
CACHE_SUFFIX: ${{ inputs.CACHE_SUFFIX }}

- name: Lint
uses: zupit-it/pipeline-templates/.github/actions/dotnet/[email protected]
Expand Down
59 changes: 29 additions & 30 deletions .github/workflows/node-step-format-lint-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:
RUN_ON:
required: false
type: string
default: 'zupit-agents'
default: "zupit-agents"
RUNNERS_CONTAINER_GROUP:
required: false
type: string
default: 'Container'
default: "Container"
NODE_VERSION:
required: true
type: string
Expand Down Expand Up @@ -45,40 +45,39 @@ jobs:
working-directory: ${{ inputs.WORKING_DIRECTORY }}

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ inputs.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.NODE_VERSION }}
# cache: 'npm'
# cache-dependency-path: ${{ inputs.WORKING_DIRECTORY }}/package-lock.json
- uses: actions/checkout@v4
with:
fetch-depth: 0

# Set NPM cache directory to a new clean directory to avoid sharing with other runners
- name: Set NPM cache directory
run: echo "NPM_CONFIG_CACHE=~/.npm$(npm -v)" >> $GITHUB_ENV
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.NODE_VERSION }}
cache: "npm"
cache-dependency-path: "**/*/package-lock.json"

- name: Authenticate with private NPM package
if: ${{ env.github_token }}
run: echo "//npm.pkg.github.com/:_authToken=${{ env.github_token }}" > ~/.npmrc
- name: Authenticate with private NPM package
if: ${{ env.github_token }}
run: echo "//npm.pkg.github.com/:_authToken=${{ env.github_token }}" > ~/.npmrc

- run: npm ci
- run: npm ci

# GENERIC
- run: npm run ci:format:check
if: ${{ inputs.PROJECT == '' }}
# GENERIC
- run: npm run ci:format:check
if: ${{ inputs.PROJECT == '' }}

- run: npm run ci:lint
if: ${{ inputs.PROJECT == '' }}
- run: npm run ci:lint
if: ${{ inputs.PROJECT == '' }}

- run: npm run ci:build
if: ${{ inputs.PROJECT == '' }}
- run: npm run ci:build
if: ${{ inputs.PROJECT == '' }}

# PROJECT SPECIFIC
- run: npm run ${{ inputs.PROJECT }}:ci:format:check
if: ${{ inputs.PROJECT != '' }}
# PROJECT SPECIFIC
- run: npm run ${{ inputs.PROJECT }}:ci:format:check
if: ${{ inputs.PROJECT != '' }}

- run: npm run ${{ inputs.PROJECT }}:ci:lint
if: ${{ inputs.PROJECT != '' }}
- run: npm run ${{ inputs.PROJECT }}:ci:lint
if: ${{ inputs.PROJECT != '' }}

- run: npm run ${{ inputs.PROJECT }}:ci:build
if: ${{ inputs.PROJECT != '' }}
- run: npm run ${{ inputs.PROJECT }}:ci:build
if: ${{ inputs.PROJECT != '' }}
11 changes: 7 additions & 4 deletions .github/workflows/sonar-step-dotnet-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ on:
required: false
type: string
default: "all"
CACHE_SUFFIX:
required: false
type: string
default: ""

env:
CHECK_DIR: ${{ inputs.WORKING_DIRECTORY }}
Expand Down Expand Up @@ -102,11 +106,9 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install .NET
uses: zupit-it/pipeline-templates/.github/actions/dotnet/install@v1.24.0
uses: zupit-it/pipeline-templates/.github/actions/dotnet/install@ZCH-126/caching
with:
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}
DOTNET_VERSION: ${{ inputs.DOTNET_VERSION }}
Expand Down Expand Up @@ -135,10 +137,11 @@ jobs:
"${params[@]}"

- name: Build
uses: zupit-it/pipeline-templates/.github/actions/dotnet/build@v1.24.0
uses: zupit-it/pipeline-templates/.github/actions/dotnet/build@ZCH-126/caching
with:
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}
BUILD_CONFIG: "Debug"
CACHE_SUFFIX: ${{ inputs.CACHE_SUFFIX }}

- name: Run tests
uses: zupit-it/pipeline-templates/.github/actions/dotnet/[email protected]
Expand Down
Loading