mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 15:48:39 +08: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:
 | 
			
		||||
      matrix:
 | 
			
		||||
        os: [ubuntu-latest, windows-latest, macOS-latest]
 | 
			
		||||
        reeval: [false, true]
 | 
			
		||||
      fail-fast: false
 | 
			
		||||
    runs-on: ${{ matrix.os }}
 | 
			
		||||
    steps:
 | 
			
		||||
| 
						 | 
				
			
			@ -67,7 +68,8 @@ jobs:
 | 
			
		|||
    - name: Save cache
 | 
			
		||||
      uses: ./
 | 
			
		||||
      with:
 | 
			
		||||
        key: test-${{ runner.os }}-${{ github.run_id }}
 | 
			
		||||
        reeval: ${{ matrix.reeval }}
 | 
			
		||||
        key: test-${{ runner.os }}-${{ github.run_id }}-${{ matrix.reeval }}
 | 
			
		||||
        path: |
 | 
			
		||||
          test-cache
 | 
			
		||||
          ~/test-cache
 | 
			
		||||
| 
						 | 
				
			
			@ -85,7 +87,8 @@ jobs:
 | 
			
		|||
      uses: ./
 | 
			
		||||
      with:
 | 
			
		||||
        only-restore: true
 | 
			
		||||
        key: test-${{ runner.os }}-${{ github.run_id }}
 | 
			
		||||
        reeval: ${{ matrix.reeval }}
 | 
			
		||||
        key: test-${{ runner.os }}-${{ github.run_id }}-${{ matrix.reeval }}
 | 
			
		||||
        path: |
 | 
			
		||||
          test-cache
 | 
			
		||||
          ~/test-cache
 | 
			
		||||
| 
						 | 
				
			
			@ -108,7 +111,8 @@ jobs:
 | 
			
		|||
    - name: Restore cache
 | 
			
		||||
      uses: ./
 | 
			
		||||
      with:
 | 
			
		||||
        key: test-${{ runner.os }}-${{ github.run_id }}
 | 
			
		||||
        reeval: ${{ matrix.reeval }}
 | 
			
		||||
        key: test-${{ runner.os }}-${{ github.run_id }}-${{ matrix.reeval }}
 | 
			
		||||
        path: |
 | 
			
		||||
          test-cache
 | 
			
		||||
          ~/test-cache
 | 
			
		||||
| 
						 | 
				
			
			@ -121,6 +125,9 @@ jobs:
 | 
			
		|||
 | 
			
		||||
  # End to end with proxy
 | 
			
		||||
  test-proxy-save:
 | 
			
		||||
    strategy:
 | 
			
		||||
      matrix:
 | 
			
		||||
        reeval: [false, true]
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    container:
 | 
			
		||||
      image: ubuntu:latest
 | 
			
		||||
| 
						 | 
				
			
			@ -140,10 +147,14 @@ jobs:
 | 
			
		|||
    - name: Save cache
 | 
			
		||||
      uses: ./
 | 
			
		||||
      with:
 | 
			
		||||
        key: test-proxy-${{ github.run_id }}
 | 
			
		||||
        reeval: ${{ matrix.reeval }}
 | 
			
		||||
        key: test-proxy-${{ github.run_id }}-${{ matrix.reeval }}
 | 
			
		||||
        path: test-cache
 | 
			
		||||
  test-proxy-only-restore:
 | 
			
		||||
    needs: test-proxy-save
 | 
			
		||||
    strategy:
 | 
			
		||||
      matrix:
 | 
			
		||||
        reeval: [false, true]
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    container:
 | 
			
		||||
      image: ubuntu:latest
 | 
			
		||||
| 
						 | 
				
			
			@ -162,12 +173,16 @@ jobs:
 | 
			
		|||
      uses: ./
 | 
			
		||||
      with:
 | 
			
		||||
        only-restore: true
 | 
			
		||||
        key: test-proxy-${{ github.run_id }}
 | 
			
		||||
        reeval: ${{ matrix.reeval }}
 | 
			
		||||
        key: test-proxy-${{ github.run_id }}-${{ matrix.reeval }}
 | 
			
		||||
        path: test-cache
 | 
			
		||||
    - name: Verify cache
 | 
			
		||||
      run: __tests__/verify-cache-files.sh proxy test-cache
 | 
			
		||||
  test-proxy-restore:
 | 
			
		||||
    needs: test-proxy-save
 | 
			
		||||
    strategy:
 | 
			
		||||
      matrix:
 | 
			
		||||
        reeval: [false, true]
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    container:
 | 
			
		||||
      image: ubuntu:latest
 | 
			
		||||
| 
						 | 
				
			
			@ -185,7 +200,8 @@ jobs:
 | 
			
		|||
    - name: Restore cache
 | 
			
		||||
      uses: ./
 | 
			
		||||
      with:
 | 
			
		||||
        key: test-proxy-${{ github.run_id }}
 | 
			
		||||
        reeval: ${{ matrix.reeval }}
 | 
			
		||||
        key: test-proxy-${{ github.run_id }}-${{ matrix.reeval }}
 | 
			
		||||
        path: test-cache
 | 
			
		||||
    - name: Verify 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();
 | 
			
		||||
 | 
			
		||||
            // Inputs are re-evaluted before the post action, so we want the original key used for restore
 | 
			
		||||
            const primaryKey = core.getState(State.CachePrimaryKey);
 | 
			
		||||
            let primaryKey: string = '';
 | 
			
		||||
            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) {
 | 
			
		||||
                utils.logWarning(`Error retrieving key from state.`);
 | 
			
		||||
                return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user