reworking on cache

This commit is contained in:
Marco Carrozzo
2023-01-19 12:56:23 +01:00
parent 815550a13d
commit c26ce3b690
2 changed files with 30 additions and 27 deletions
+13 -10
View File
@@ -1,6 +1,11 @@
name: 'Setup'
description: 'Initialize cache, env var load'
inputs:
cache-key-suffix:
description: 'suffix for cache key'
required: false
type: string
default: ''
enable-global-nx-cache:
description: 'enable caching'
required: false
@@ -29,19 +34,18 @@ runs:
id: tag-sha
uses: Alfresco/alfresco-build-tools/.github/actions/git-latest-tag@v1.29.0
# CACHE
- name: Node cache
id: node-cache
- name: NX cache
id: nx-cache
if: ${{ inputs.enable-global-nx-cache == 'true' }}
uses: actions/cache@v3
env:
cache-name: node-cache
cache-name: nx-cache
with:
path: |
nxcache
key: nxcache-${{ github.ref_name }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}-${{ steps.tag-sha.outputs.tag_long_sha }}
key: nxcache-${{ github.ref_name }}-${{ inputs.cache-key-suffix }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
nxcache-${{ github.ref_name }}-build-${{ env.cache-name }}-
nxcache-${{ github.ref_name }}-build-
nxcache-${{ github.ref_name }}-build-${{ inputs.cache-key-suffix }}
nxcache-${{ github.ref_name }}-
- name: Node Modules cache
id: node-modules-cache
@@ -52,11 +56,10 @@ runs:
with:
path: |
node_modules
key: .npm-${{ github.ref_name }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}-${{ steps.tag-sha.outputs.tag_long_sha }}
key: node_modules-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
node_modules-${{ github.ref_name }}-build-${{ env.cache-name }}-
node_modules-${{ github.ref_name }}-build-
node_modules-${{ github.ref_name }}-
node_modules-${{ env.cache-name }}-
node_modules-
- name: pip cache
uses: actions/cache@v3
if: ${{ inputs.enable-global-nx-cache == 'true' }}
+17 -17
View File
@@ -118,16 +118,18 @@ jobs:
with:
fetch-depth: 0 # Fetch all history for all tags and branches
- uses: ./.github/actions/setup
id: setup
with:
enable-global-nx-cache: false
enable-global-node-modules-cache: true
- run: npm ci
- name: run ci
if: steps.setup.outputs.cache-hit != 'true'
run: npm ci
- run: nx run cli:bundle
- run: nx run testing:bundle
- run: nx print-affected $NX_CALCULATION_FLAGS
- uses: ./.github/actions/upload-cache-and-artifacts
with:
packages: 'dist nxcache node_modules'
packages: 'dist node_modules'
unit-tests:
timeout-minutes: 30
@@ -156,9 +158,10 @@ jobs:
with:
enable-global-nx-cache: false
enable-global-node-modules-cache: false
cache-key-suffix: unit-tests
- uses: ./.github/actions/download-cache-and-artifacts
with:
packages: 'dist nxcache node_modules'
packages: 'dist nxcache node_modules'
- name: Run unit tests
run: |
/usr/bin/xvfb-run --auto-servernum nx affected:test $NX_CALCULATION_FLAGS --exclude=${{ matrix.unit-tests.exclude }}
@@ -176,18 +179,14 @@ jobs:
fetch-depth: 0 # Fetch all history for all tags and branches
- uses: ./.github/actions/setup
with:
enable-global-nx-cache: false
enable-global-node-modules-cache: true
enable-global-nx-cache: true
enable-global-node-modules-cache: false
cache-key-suffix: lint
- uses: ./.github/actions/download-cache-and-artifacts
with:
packages: 'dist nxcache node_modules'
packages: 'node_modules'
- run: nx affected --target=lint $NX_CALCULATION_FLAGS
#####NOT POSSIBLE AS ALREADY UPDATED BY BUILD-LIBS
# - uses: ./.github/actions/upload-cache-and-artifacts
# with:
# packages: 'nxcache'
build-libs:
# long timeout required when cache has to be recreated
timeout-minutes: 30
@@ -202,16 +201,17 @@ jobs:
- uses: ./.github/actions/setup
with:
enable-global-nx-cache: false
enable-global-node-modules-cache: false
- uses: ./.github/actions/download-cache-and-artifacts
with:
packages: 'dist nxcache node_modules'
enable-global-node-modules-cache: true
cache-key-suffix: build-libs
# - uses: ./.github/actions/download-cache-and-artifacts
# with:
# packages: 'node_modules'
- run: nx affected:build $NX_CALCULATION_FLAGS --prod
- run: nx build demoshell --configuration production
- run: nx affected --target=build-storybook $NX_CALCULATION_FLAGS --configuration ci
- uses: ./.github/actions/upload-cache-and-artifacts
with:
packages: 'dist nxcache'
packages: 'dist'
e2e-storybook:
timeout-minutes: 20