Skip to content

Commit

Permalink
fix: better caching
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-sartori-zupit committed Oct 3, 2024
1 parent a74e8f8 commit 8861b7f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 43 deletions.
18 changes: 10 additions & 8 deletions .github/actions/dotnet/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ inputs:
runs:
using: composite
steps:
- name: List NuGet cache size
run: |
du -h ~/.nuget/packages | sort -hr | head -n 20
- name: Create folder if not exist
shell: bash
run: mkdir -p ~/.nuget/packages-carbon
- name: List NuGet carbon cache size
shell: bash
run: du -h ~/.nuget/packages-carbon | sort -hr | head -n 20
- 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
# key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
# key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
# restore-keys: ${{ runner.os }}-nuget-
# retention-days: 30
path: ~/.nuget/packages-carbon
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: ${{ runner.os }}-nuget-

- name: Restore dependencies
shell: ${{ inputs.SHELL }}
Expand Down
62 changes: 27 additions & 35 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 All @@ -30,7 +30,7 @@ on:
type: string
default: "ubuntu:23.04"

env: "${{secrets}}"
env: "${{ secrets }}"

jobs:
lint-check-build:
Expand All @@ -45,40 +45,32 @@ 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
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history

# 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: Ensure necessary packages are installed
run: |
apt-get update
apt-get install -y unzip git
git config --global --add safe.directory "$GITHUB_WORKSPACE"
shell: bash

- name: Authenticate with private NPM package
if: ${{ env.github_token }}
run: echo "//npm.pkg.github.com/:_authToken=${{ env.github_token }}" > ~/.npmrc
- name: Checkout repository again
uses: actions/checkout@v4
with:
fetch-depth: 0

- run: npm ci
- name: Use bun
uses: oven-sh/setup-bun@v1
with:
bun-version: v1.1.29

# GENERIC
- run: npm run ci:format:check
if: ${{ inputs.PROJECT == '' }}
- name: Install Dependencies
env:
BUN_AUTH_TOKEN: ${{ env.github_token }}
run: bun install --frozen-lockfile

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

- run: npm run ci:build
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:build
if: ${{ inputs.PROJECT != '' }}
- name: Run affected lint and build
run: bun nx affected -t lint build --base=origin/main --head=HEAD

0 comments on commit 8861b7f

Please sign in to comment.