mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 15:14:00 +00:00 
			
		
		
		
	add primary key reevaluation boolean logic & jobs to Tests workflow
This commit is contained in:
		
							parent
							
								
									78b8f18c17
								
							
						
					
					
						commit
						226c25a2b7
					
				
							
								
								
									
										28
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							@ -53,6 +53,7 @@ jobs:
 | 
				
			|||||||
    strategy:
 | 
					    strategy:
 | 
				
			||||||
      matrix:
 | 
					      matrix:
 | 
				
			||||||
        os: [ubuntu-latest, windows-latest, macOS-latest]
 | 
					        os: [ubuntu-latest, windows-latest, macOS-latest]
 | 
				
			||||||
 | 
					        reeval: [false, true]
 | 
				
			||||||
      fail-fast: false
 | 
					      fail-fast: false
 | 
				
			||||||
    runs-on: ${{ matrix.os }}
 | 
					    runs-on: ${{ matrix.os }}
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
@ -67,7 +68,8 @@ jobs:
 | 
				
			|||||||
    - name: Save cache
 | 
					    - name: Save cache
 | 
				
			||||||
      uses: ./
 | 
					      uses: ./
 | 
				
			||||||
      with:
 | 
					      with:
 | 
				
			||||||
        key: test-${{ runner.os }}-${{ github.run_id }}
 | 
					        reeval: ${{ matrix.reeval }}
 | 
				
			||||||
 | 
					        key: test-${{ runner.os }}-${{ github.run_id }}-${{ matrix.reeval }}
 | 
				
			||||||
        path: |
 | 
					        path: |
 | 
				
			||||||
          test-cache
 | 
					          test-cache
 | 
				
			||||||
          ~/test-cache
 | 
					          ~/test-cache
 | 
				
			||||||
@ -85,7 +87,8 @@ jobs:
 | 
				
			|||||||
      uses: ./
 | 
					      uses: ./
 | 
				
			||||||
      with:
 | 
					      with:
 | 
				
			||||||
        only-restore: true
 | 
					        only-restore: true
 | 
				
			||||||
        key: test-${{ runner.os }}-${{ github.run_id }}
 | 
					        reeval: ${{ matrix.reeval }}
 | 
				
			||||||
 | 
					        key: test-${{ runner.os }}-${{ github.run_id }}-${{ matrix.reeval }}
 | 
				
			||||||
        path: |
 | 
					        path: |
 | 
				
			||||||
          test-cache
 | 
					          test-cache
 | 
				
			||||||
          ~/test-cache
 | 
					          ~/test-cache
 | 
				
			||||||
@ -108,7 +111,8 @@ jobs:
 | 
				
			|||||||
    - name: Restore cache
 | 
					    - name: Restore cache
 | 
				
			||||||
      uses: ./
 | 
					      uses: ./
 | 
				
			||||||
      with:
 | 
					      with:
 | 
				
			||||||
        key: test-${{ runner.os }}-${{ github.run_id }}
 | 
					        reeval: ${{ matrix.reeval }}
 | 
				
			||||||
 | 
					        key: test-${{ runner.os }}-${{ github.run_id }}-${{ matrix.reeval }}
 | 
				
			||||||
        path: |
 | 
					        path: |
 | 
				
			||||||
          test-cache
 | 
					          test-cache
 | 
				
			||||||
          ~/test-cache
 | 
					          ~/test-cache
 | 
				
			||||||
@ -121,6 +125,9 @@ jobs:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  # End to end with proxy
 | 
					  # End to end with proxy
 | 
				
			||||||
  test-proxy-save:
 | 
					  test-proxy-save:
 | 
				
			||||||
 | 
					    strategy:
 | 
				
			||||||
 | 
					      matrix:
 | 
				
			||||||
 | 
					        reeval: [false, true]
 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
    container:
 | 
					    container:
 | 
				
			||||||
      image: ubuntu:latest
 | 
					      image: ubuntu:latest
 | 
				
			||||||
@ -140,10 +147,14 @@ jobs:
 | 
				
			|||||||
    - name: Save cache
 | 
					    - name: Save cache
 | 
				
			||||||
      uses: ./
 | 
					      uses: ./
 | 
				
			||||||
      with:
 | 
					      with:
 | 
				
			||||||
        key: test-proxy-${{ github.run_id }}
 | 
					        reeval: ${{ matrix.reeval }}
 | 
				
			||||||
 | 
					        key: test-proxy-${{ github.run_id }}-${{ matrix.reeval }}
 | 
				
			||||||
        path: test-cache
 | 
					        path: test-cache
 | 
				
			||||||
  test-proxy-only-restore:
 | 
					  test-proxy-only-restore:
 | 
				
			||||||
    needs: test-proxy-save
 | 
					    needs: test-proxy-save
 | 
				
			||||||
 | 
					    strategy:
 | 
				
			||||||
 | 
					      matrix:
 | 
				
			||||||
 | 
					        reeval: [false, true]
 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
    container:
 | 
					    container:
 | 
				
			||||||
      image: ubuntu:latest
 | 
					      image: ubuntu:latest
 | 
				
			||||||
@ -162,12 +173,16 @@ jobs:
 | 
				
			|||||||
      uses: ./
 | 
					      uses: ./
 | 
				
			||||||
      with:
 | 
					      with:
 | 
				
			||||||
        only-restore: true
 | 
					        only-restore: true
 | 
				
			||||||
        key: test-proxy-${{ github.run_id }}
 | 
					        reeval: ${{ matrix.reeval }}
 | 
				
			||||||
 | 
					        key: test-proxy-${{ github.run_id }}-${{ matrix.reeval }}
 | 
				
			||||||
        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
 | 
				
			||||||
  test-proxy-restore:
 | 
					  test-proxy-restore:
 | 
				
			||||||
    needs: test-proxy-save
 | 
					    needs: test-proxy-save
 | 
				
			||||||
 | 
					    strategy:
 | 
				
			||||||
 | 
					      matrix:
 | 
				
			||||||
 | 
					        reeval: [false, true]
 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
    container:
 | 
					    container:
 | 
				
			||||||
      image: ubuntu:latest
 | 
					      image: ubuntu:latest
 | 
				
			||||||
@ -185,7 +200,8 @@ jobs:
 | 
				
			|||||||
    - name: Restore cache
 | 
					    - name: Restore cache
 | 
				
			||||||
      uses: ./
 | 
					      uses: ./
 | 
				
			||||||
      with:
 | 
					      with:
 | 
				
			||||||
        key: test-proxy-${{ github.run_id }}
 | 
					        reeval: ${{ matrix.reeval }}
 | 
				
			||||||
 | 
					        key: test-proxy-${{ github.run_id }}-${{ matrix.reeval }}
 | 
				
			||||||
        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
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										11
									
								
								src/save.ts
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/save.ts
									
									
									
									
									
								
							@ -28,8 +28,15 @@ async function run(): Promise<void> {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            const state = utils.getCacheState();
 | 
					            const state = utils.getCacheState();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Inputs are re-evaluted before the post action, so we want the original key used for restore
 | 
					            let primaryKey: string = '';
 | 
				
			||||||
            const primaryKey = core.getState(State.CachePrimaryKey);
 | 
					            const reeval = core.getBooleanInput(Inputs.Reeval);
 | 
				
			||||||
 | 
					            if (!reeval) {
 | 
				
			||||||
 | 
					                // Inputs are reevaluted before the post action, so we want the original key used for restore
 | 
				
			||||||
 | 
					                primaryKey = core.getState(State.CachePrimaryKey);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                // choose to reevaluate primary key
 | 
				
			||||||
 | 
					                primaryKey = core.getInput(Inputs.Key, { required: true });
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            if (!primaryKey) {
 | 
					            if (!primaryKey) {
 | 
				
			||||||
                utils.logWarning(`Error retrieving key from state.`);
 | 
					                utils.logWarning(`Error retrieving key from state.`);
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user