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: better caching #116

Draft
wants to merge 12 commits into
base: chore/dotnet-conditional-workflow
Choose a base branch
from
12 changes: 8 additions & 4 deletions .github/actions/dotnet/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ inputs:
SHELL:
required: false
type: string
default: 'bash'
default: "bash"

runs:
using: composite
steps:
- name: Create folder if not exist
shell: bash
run: mkdir -p ~/.nuget/packages-carbon

- 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-
path: ~/.nuget/packages-carbon
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}

- name: Restore dependencies
shell: ${{ inputs.SHELL }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-workflow-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
CSHARPIER_VERSION: ${{ inputs.CSHARPIER_VERSION }}

- name: Build
uses: zupit-it/pipeline-templates/.github/actions/dotnet/build@v1.23.2
uses: zupit-it/pipeline-templates/.github/actions/dotnet/build@chore/better-caching
with:
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}
BUILD_CONFIG: "Debug"
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 != '' }}
4 changes: 1 addition & 3 deletions .github/workflows/sonar-step-dotnet-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install .NET
uses: zupit-it/pipeline-templates/.github/actions/dotnet/[email protected]
Expand Down Expand Up @@ -135,7 +133,7 @@ jobs:
"${params[@]}"

- name: Build
uses: zupit-it/pipeline-templates/.github/actions/dotnet/build@v1.23.2
uses: zupit-it/pipeline-templates/.github/actions/dotnet/build@chore/better-caching
with:
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}
BUILD_CONFIG: "Debug"
Expand Down