@@ -15,37 +15,23 @@ name: 'Aggregate compute-benchmark results and produce historical averages'
1515# 
1616
1717inputs :
18-   cutoff_timestamp :
19-     type : string 
18+   lookback_days :
19+     type : number 
2020    required : true 
2121
2222runs :
2323  using : " composite" 
2424  steps :
25-   - name : Sanitize provided  timestamp
25+   - name : Obtain oldest  timestamp allowed for data in aggregation 
2626    shell : bash 
2727    run : | 
28-       # Sanitize the cutoff timestamp provided 
29-       # 
30-       # This timestamp controls which historical results are used to compute 
31-       # measures of central tendency: Any files timestamped *before* this time 
32-       # will be *excluded* from the central tendency calculation. 
33- 
34-       # Regex greps YYYYMMDD_HHMMSS 
35-       TIMESTAMP_RE='^[0-9]{4}(0[1-9]|1[0-2])([0-2][0-9]|3[01])_([01][0-9]|2[0-3])([0-5][0-9])([0-5][0-9])$' 
36- 
37-       # Note: 
38-       # - variables from input context should be surrounded with '' to prevent 
39-       #   remote code execution 
40-       # - `-o` needs to be kept in the grep command; `-o` is exact match only, 
41-       #   incase user somehow manages to inject extra text, `-o` should take 
42-       #   care of it. 
43-       # - DO NOT use input.cutoff_timestamp directly, only use SANITIZED_TIMESTAMP 
44-       SANITIZED_TIMESTAMP="$(echo '${{ inputs.cutoff_timestamp }}' | grep -oE "$TIMESTAMP_RE")" 
28+       # DO NOT use inputs.lookback_days directly, only use SANITIZED_TIMESTAMP. 
29+       SANITIZED_LOOKBACK_DAYS ="$(echo '${{ inputs.lookback_days }}' | grep -o "^[0-9]$")" 
4530      if [ -z "$SANITIZED_TIMESTAMP" ]; then 
46-         echo "Please ensure input in input.cutoff_timestamp  is exactly YYYYMMDD_HHMMSS."  
47-         exit 1  # Terminate workflow  
31+         echo "Please ensure inputs.lookback_days  is a number.  
32+         exit 1 
4833      fi 
34+       SANITIZED_TIMESTAMP="$(date -d "$SANITIZED_LOOKBACK_DAYS days ago" +%Y%m%d_%H%M%S)" 
4935      echo "SANITIZED_TIMESTAMP=$SANITIZED_TIMESTAMP" >> $GITHUB_ENV 
5036   - name : Load benchmarking configuration 
5137    shell : bash 
0 commit comments