Compare commits

...

1 Commits

Author SHA1 Message Date
Lorenz Hilpert
13616adaac Enhanced Nx caching in CI pipeline for improved build performance.
-  **Feature**: Added Nx cache variables for caching mechanism
- ⚙️ **Config**: Implemented cache restore and save tasks in CI jobs
- 🛠️ **Refactor**: Updated Docker build arguments to include cache settings
2025-04-25 11:05:49 +02:00

View File

@@ -17,6 +17,13 @@ variables:
value: "$[counter(format('{0}.{1}', variables['Major'], variables['Minor']),0)]"
- name: 'BuildUniqueID'
value: '$(Build.BuildID)-$(Agent.Id)-$(System.DefinitionId)-$(System.JobId)'
# Nx cache variables
- name: 'NX_CACHE_DIRECTORY'
value: '.nx/cache'
- name: 'NX_CACHE_ENABLED'
value: 'true'
- name: 'NX_CACHE_RESTORE_KEY'
value: nx-cache-$(Agent.OS)-$(System.TeamProjectId)
- group: 'GithubCMF'
jobs:
@@ -28,6 +35,16 @@ jobs:
- Agent.OS -equals Linux
- docker
steps:
# Restore Nx cache from Azure Pipelines cache
- task: Cache@2
displayName: 'Restore Nx Cache'
inputs:
key: $(NX_CACHE_RESTORE_KEY)
path: $(NX_CACHE_DIRECTORY)
restoreKeys: |
$(NX_CACHE_RESTORE_KEY)
nx-cache-$(Agent.OS)
- task: npmAuthenticate@0
displayName: 'npm auth'
inputs:
@@ -41,7 +58,9 @@ jobs:
--no-cache \
--target test \
--build-arg SEMVERSION=$(Major).$(Minor).$(Patch) \
--build-arg BuildUniqueID=$(BuildUniqueID)
--build-arg BuildUniqueID=$(BuildUniqueID) \
--build-arg NX_CACHE_ENABLED=$(NX_CACHE_ENABLED) \
--mount type=bind,source=$(pwd)/$(NX_CACHE_DIRECTORY),target=/app/$(NX_CACHE_DIRECTORY)
displayName: Build and Run Tests in docker
- bash: |
echo Copy Tests from docker container
@@ -67,6 +86,15 @@ jobs:
summaryFileLocation: $(Build.StagingDirectory)/coverage/**/cobertura-coverage.xml
pathToSources: $(Build.SourcesDirectory)
condition: always()
# Save Nx cache to Azure Pipelines cache
- task: Cache@2
displayName: 'Save Nx Cache'
inputs:
key: $(NX_CACHE_RESTORE_KEY)
path: $(NX_CACHE_DIRECTORY)
condition: always()
- bash: |
echo ##############
docker images -f "label=build.uniqueid=$(BuildUniqueID)"
@@ -95,6 +123,16 @@ jobs:
$(Build.BuildNumber)-$(Build.SourceVersion)
$(DockerTagSourceBranch)
steps:
# Restore Nx cache from Azure Pipelines cache
- task: Cache@2
displayName: 'Restore Nx Cache'
inputs:
key: $(NX_CACHE_RESTORE_KEY)
path: $(NX_CACHE_DIRECTORY)
restoreKeys: |
$(NX_CACHE_RESTORE_KEY)
nx-cache-$(Agent.OS)
- task: npmAuthenticate@0
displayName: 'npm auth'
inputs:
@@ -114,6 +152,8 @@ jobs:
--target publish
--build-arg SEMVERSION=$(Major).$(Minor).$(Patch)
--build-arg BuildUniqueID=$(BuildUniqueID)
--build-arg NX_CACHE_ENABLED=$(NX_CACHE_ENABLED)
--mount type=bind,source=$(pwd)/$(NX_CACHE_DIRECTORY),target=/app/$(NX_CACHE_DIRECTORY)
--label BuildType=Debug
- task: Docker@2
@@ -124,6 +164,14 @@ jobs:
command: 'push'
tags: '$(DockerTag)'
# Save Nx cache to Azure Pipelines cache
- task: Cache@2
displayName: 'Save Nx Cache'
inputs:
key: $(NX_CACHE_RESTORE_KEY)
path: $(NX_CACHE_DIRECTORY)
condition: always()
- task: PublishBuildArtifacts@1
displayName: 'Artefakt veröffentlichen: HelmValues'
inputs:
@@ -164,6 +212,16 @@ jobs:
$(Build.BuildNumber)-$(Build.SourceVersion)
$(DockerTagSourceBranch)
steps:
# Restore Nx cache from Azure Pipelines cache
- task: Cache@2
displayName: 'Restore Nx Cache'
inputs:
key: $(NX_CACHE_RESTORE_KEY)
path: $(NX_CACHE_DIRECTORY)
restoreKeys: |
$(NX_CACHE_RESTORE_KEY)
nx-cache-$(Agent.OS)
- task: npmAuthenticate@0
displayName: 'npm auth'
inputs:
@@ -184,6 +242,8 @@ jobs:
--build-arg IS_PRODUCTION=true
--build-arg SEMVERSION=$(Major).$(Minor).$(Patch)
--build-arg BuildUniqueID=$(BuildUniqueID)
--build-arg NX_CACHE_ENABLED=$(NX_CACHE_ENABLED)
--mount type=bind,source=$(pwd)/$(NX_CACHE_DIRECTORY),target=/app/$(NX_CACHE_DIRECTORY)
--label BuildType=Production
- task: Docker@2
@@ -194,6 +254,14 @@ jobs:
command: 'push'
tags: '$(DockerTag)'
# Save Nx cache to Azure Pipelines cache
- task: Cache@2
displayName: 'Save Nx Cache'
inputs:
key: $(NX_CACHE_RESTORE_KEY)
path: $(NX_CACHE_DIRECTORY)
condition: always()
- task: PublishBuildArtifacts@1
displayName: 'Artefakt veröffentlichen: HelmValues'
inputs: