mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 03:04:01 +00:00 
			
		
		
		
	ci(workflow): add 'npm' cache for actions/setup-node in .github/workflows
This commit is contained in:
		
							parent
							
								
									5807af2642
								
							
						
					
					
						commit
						16f6b94fce
					
				
							
								
								
									
										170
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										170
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							@ -6,13 +6,13 @@ on:
 | 
				
			|||||||
      - main
 | 
					      - main
 | 
				
			||||||
      - releases/**
 | 
					      - releases/**
 | 
				
			||||||
    paths-ignore:
 | 
					    paths-ignore:
 | 
				
			||||||
      - '**.md'
 | 
					      - "**.md"
 | 
				
			||||||
  push:
 | 
					  push:
 | 
				
			||||||
    branches:
 | 
					    branches:
 | 
				
			||||||
      - main
 | 
					      - main
 | 
				
			||||||
      - releases/**
 | 
					      - releases/**
 | 
				
			||||||
    paths-ignore:
 | 
					    paths-ignore:
 | 
				
			||||||
      - '**.md'
 | 
					      - "**.md"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
jobs:
 | 
					jobs:
 | 
				
			||||||
  # Build and unit test
 | 
					  # Build and unit test
 | 
				
			||||||
@ -23,41 +23,41 @@ jobs:
 | 
				
			|||||||
      fail-fast: false
 | 
					      fail-fast: false
 | 
				
			||||||
    runs-on: ${{ matrix.os }}
 | 
					    runs-on: ${{ matrix.os }}
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
    - name: Checkout
 | 
					      - name: Checkout
 | 
				
			||||||
      uses: actions/checkout@v2
 | 
					        uses: actions/checkout@v2
 | 
				
			||||||
    - name: Setup Node.js
 | 
					      - name: Setup Node.js
 | 
				
			||||||
      uses: actions/setup-node@v1
 | 
					        uses: actions/setup-node@v2
 | 
				
			||||||
      with:
 | 
					        with:
 | 
				
			||||||
        node-version: '12.x'
 | 
					          node-version: "12.x"
 | 
				
			||||||
    - name: Determine npm cache directory
 | 
					          cache: npm
 | 
				
			||||||
      id: npm-cache
 | 
					      - name: Determine npm cache directory
 | 
				
			||||||
      run: |
 | 
					        id: npm-cache
 | 
				
			||||||
        echo "::set-output name=dir::$(npm config get cache)"
 | 
					        run: |
 | 
				
			||||||
    - name: Restore npm cache
 | 
					          echo "::set-output name=dir::$(npm config get cache)"
 | 
				
			||||||
      uses: actions/cache@v2
 | 
					      - name: Restore npm cache
 | 
				
			||||||
      with:
 | 
					        uses: actions/cache@v2
 | 
				
			||||||
        path: ${{ steps.npm-cache.outputs.dir }}
 | 
					        with:
 | 
				
			||||||
        key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
 | 
					          path: ${{ steps.npm-cache.outputs.dir }}
 | 
				
			||||||
        restore-keys: |
 | 
					          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
 | 
				
			||||||
          ${{ runner.os }}-node-
 | 
					          restore-keys: |
 | 
				
			||||||
    - run: npm ci
 | 
					            ${{ runner.os }}-node-
 | 
				
			||||||
    - name: Prettier Format Check
 | 
					      - run: npm ci
 | 
				
			||||||
      run: npm run format-check
 | 
					      - name: Prettier Format Check
 | 
				
			||||||
    - name: ESLint Check
 | 
					        run: npm run format-check
 | 
				
			||||||
      run: npm run lint
 | 
					      - name: ESLint Check
 | 
				
			||||||
    - name: Build & Test
 | 
					        run: npm run lint
 | 
				
			||||||
      run: npm run test
 | 
					      - name: Build & Test
 | 
				
			||||||
    - name: Ensure dist/ folder is up-to-date
 | 
					        run: npm run test
 | 
				
			||||||
      if: ${{ runner.os == 'Linux' }}
 | 
					      - name: Ensure dist/ folder is up-to-date
 | 
				
			||||||
      shell: bash
 | 
					        if: ${{ runner.os == 'Linux' }}
 | 
				
			||||||
      run: |
 | 
					        shell: bash
 | 
				
			||||||
        npm run build
 | 
					        run: |
 | 
				
			||||||
        if [ "$(git diff --ignore-space-at-eol | wc -l)" -gt "0" ]; then
 | 
					          npm run build
 | 
				
			||||||
          echo "Detected uncommitted changes after build.  See status below:"
 | 
					          if [ "$(git diff --ignore-space-at-eol | wc -l)" -gt "0" ]; then
 | 
				
			||||||
          git diff
 | 
					            echo "Detected uncommitted changes after build.  See status below:"
 | 
				
			||||||
          exit 1
 | 
					            git diff
 | 
				
			||||||
        fi
 | 
					            exit 1
 | 
				
			||||||
        
 | 
					          fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # End to end save and restore
 | 
					  # End to end save and restore
 | 
				
			||||||
  test-save:
 | 
					  test-save:
 | 
				
			||||||
@ -67,21 +67,21 @@ jobs:
 | 
				
			|||||||
      fail-fast: false
 | 
					      fail-fast: false
 | 
				
			||||||
    runs-on: ${{ matrix.os }}
 | 
					    runs-on: ${{ matrix.os }}
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
    - name: Checkout
 | 
					      - name: Checkout
 | 
				
			||||||
      uses: actions/checkout@v2
 | 
					        uses: actions/checkout@v2
 | 
				
			||||||
    - name: Generate files in working directory
 | 
					      - name: Generate files in working directory
 | 
				
			||||||
      shell: bash
 | 
					        shell: bash
 | 
				
			||||||
      run: __tests__/create-cache-files.sh ${{ runner.os }} test-cache
 | 
					        run: __tests__/create-cache-files.sh ${{ runner.os }} test-cache
 | 
				
			||||||
    - name: Generate files outside working directory
 | 
					      - name: Generate files outside working directory
 | 
				
			||||||
      shell: bash
 | 
					        shell: bash
 | 
				
			||||||
      run: __tests__/create-cache-files.sh ${{ runner.os }} ~/test-cache
 | 
					        run: __tests__/create-cache-files.sh ${{ runner.os }} ~/test-cache
 | 
				
			||||||
    - name: Save cache
 | 
					      - name: Save cache
 | 
				
			||||||
      uses: ./
 | 
					        uses: ./
 | 
				
			||||||
      with:
 | 
					        with:
 | 
				
			||||||
        key: test-${{ runner.os }}-${{ github.run_id }}
 | 
					          key: test-${{ runner.os }}-${{ github.run_id }}
 | 
				
			||||||
        path: |
 | 
					          path: |
 | 
				
			||||||
          test-cache
 | 
					            test-cache
 | 
				
			||||||
          ~/test-cache
 | 
					            ~/test-cache
 | 
				
			||||||
  test-restore:
 | 
					  test-restore:
 | 
				
			||||||
    needs: test-save
 | 
					    needs: test-save
 | 
				
			||||||
    strategy:
 | 
					    strategy:
 | 
				
			||||||
@ -90,21 +90,21 @@ jobs:
 | 
				
			|||||||
      fail-fast: false
 | 
					      fail-fast: false
 | 
				
			||||||
    runs-on: ${{ matrix.os }}
 | 
					    runs-on: ${{ matrix.os }}
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
    - name: Checkout
 | 
					      - name: Checkout
 | 
				
			||||||
      uses: actions/checkout@v2
 | 
					        uses: actions/checkout@v2
 | 
				
			||||||
    - name: Restore cache
 | 
					      - name: Restore cache
 | 
				
			||||||
      uses: ./
 | 
					        uses: ./
 | 
				
			||||||
      with:
 | 
					        with:
 | 
				
			||||||
        key: test-${{ runner.os }}-${{ github.run_id }}
 | 
					          key: test-${{ runner.os }}-${{ github.run_id }}
 | 
				
			||||||
        path: |
 | 
					          path: |
 | 
				
			||||||
          test-cache
 | 
					            test-cache
 | 
				
			||||||
          ~/test-cache
 | 
					            ~/test-cache
 | 
				
			||||||
    - name: Verify cache files in working directory
 | 
					      - name: Verify cache files in working directory
 | 
				
			||||||
      shell: bash
 | 
					        shell: bash
 | 
				
			||||||
      run: __tests__/verify-cache-files.sh ${{ runner.os }} test-cache
 | 
					        run: __tests__/verify-cache-files.sh ${{ runner.os }} test-cache
 | 
				
			||||||
    - name: Verify cache files outside working directory
 | 
					      - name: Verify cache files outside working directory
 | 
				
			||||||
      shell: bash
 | 
					        shell: bash
 | 
				
			||||||
      run: __tests__/verify-cache-files.sh ${{ runner.os }} ~/test-cache
 | 
					        run: __tests__/verify-cache-files.sh ${{ runner.os }} ~/test-cache
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # End to end with proxy
 | 
					  # End to end with proxy
 | 
				
			||||||
  test-proxy-save:
 | 
					  test-proxy-save:
 | 
				
			||||||
@ -120,15 +120,15 @@ jobs:
 | 
				
			|||||||
    env:
 | 
					    env:
 | 
				
			||||||
      https_proxy: http://squid-proxy:3128
 | 
					      https_proxy: http://squid-proxy:3128
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
    - name: Checkout
 | 
					      - name: Checkout
 | 
				
			||||||
      uses: actions/checkout@v2
 | 
					        uses: actions/checkout@v2
 | 
				
			||||||
    - name: Generate files
 | 
					      - name: Generate files
 | 
				
			||||||
      run: __tests__/create-cache-files.sh proxy test-cache
 | 
					        run: __tests__/create-cache-files.sh proxy test-cache
 | 
				
			||||||
    - name: Save cache
 | 
					      - name: Save cache
 | 
				
			||||||
      uses: ./
 | 
					        uses: ./
 | 
				
			||||||
      with:
 | 
					        with:
 | 
				
			||||||
        key: test-proxy-${{ github.run_id }}
 | 
					          key: test-proxy-${{ github.run_id }}
 | 
				
			||||||
        path: test-cache
 | 
					          path: test-cache
 | 
				
			||||||
  test-proxy-restore:
 | 
					  test-proxy-restore:
 | 
				
			||||||
    needs: test-proxy-save
 | 
					    needs: test-proxy-save
 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
@ -143,12 +143,12 @@ jobs:
 | 
				
			|||||||
    env:
 | 
					    env:
 | 
				
			||||||
      https_proxy: http://squid-proxy:3128
 | 
					      https_proxy: http://squid-proxy:3128
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
    - name: Checkout
 | 
					      - name: Checkout
 | 
				
			||||||
      uses: actions/checkout@v2
 | 
					        uses: actions/checkout@v2
 | 
				
			||||||
    - name: Restore cache
 | 
					      - name: Restore cache
 | 
				
			||||||
      uses: ./
 | 
					        uses: ./
 | 
				
			||||||
      with:
 | 
					        with:
 | 
				
			||||||
        key: test-proxy-${{ github.run_id }}
 | 
					          key: test-proxy-${{ github.run_id }}
 | 
				
			||||||
        path: test-cache
 | 
					          path: test-cache
 | 
				
			||||||
    - name: Verify cache
 | 
					      - name: Verify cache
 | 
				
			||||||
      run: __tests__/verify-cache-files.sh proxy test-cache
 | 
					        run: __tests__/verify-cache-files.sh proxy test-cache
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user