• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: Upload test artifacts
2
3description: Upload various artifacts produced by our testing process
4
5inputs:
6  use-gha:
7    description: If set to any value, upload GHA. Otherwise upload to S3.
8    required: false
9  file-suffix:
10    description: |
11      Suffix to add to the filename of the artifacts. This should include the
12      workflow job id, see [Job id in artifacts].
13    required: true
14  s3-bucket:
15    description: S3 bucket to download builds
16    required: false
17    default: "gha-artifacts"
18
19runs:
20  using: composite
21  steps:
22    # Mac/Linux zip
23    - name: Zip JSONs for upload
24      if: runner.os != 'Windows' && !inputs.use-gha
25      shell: bash
26      env:
27        FILE_SUFFIX: ${{ inputs.file-suffix }}
28      run: |
29        # Remove any previous test jsons if they exist
30        rm -f test-jsons-*.zip
31        zip -r "test-jsons-${FILE_SUFFIX}.zip" test -i '*.json'
32
33    - name: Zip test reports for upload
34      if: runner.os != 'Windows' && !inputs.use-gha
35      shell: bash
36      env:
37        FILE_SUFFIX: ${{ inputs.file-suffix }}
38      run: |
39        # Remove any previous test reports if they exist
40        rm -f test-reports-*.zip
41        zip -r "test-reports-${FILE_SUFFIX}.zip" test -i '*.xml' -i '*.csv'
42
43    - name: Zip usage log for upload
44      if: runner.os != 'Windows' && !inputs.use-gha
45      shell: bash
46      env:
47        FILE_SUFFIX: ${{ inputs.file-suffix }}
48      run: |
49        # Remove any previous usage logs if they exist
50        rm -f logs-*.zip
51        # this workflow is also run in bazel build test, but we dont generate usage reports for it
52        # so check to see if the file exists first
53        if [ -f 'usage_log.txt' ]; then
54            zip "logs-${FILE_SUFFIX}.zip" 'usage_log.txt'
55        fi
56        if ls test/**/*.log 1> /dev/null 2>&1; then
57            zip -r "logs-${FILE_SUFFIX}.zip" test -i '*.log'
58        fi
59
60    - name: Zip debugging artifacts for upload
61      if: runner.os != 'Windows' && !inputs.use-gha
62      shell: bash
63      env:
64        FILE_SUFFIX: ${{ inputs.file-suffix }}
65      run: |
66        # Remove any previous debugging artifacts if they exist
67        rm -f debug-*.zip
68        if [ -d 'test/debug' ]; then
69          zip -r "debug-${FILE_SUFFIX}.zip" test/debug
70        fi
71
72    # Windows zip
73    - name: Zip JSONs for upload
74      if: runner.os == 'Windows' && !inputs.use-gha
75      shell: powershell
76      env:
77        FILE_SUFFIX: ${{ inputs.file-suffix }}
78      run: |
79        # -ir => recursive include all files in pattern
80        7z a "test-jsons-$Env:FILE_SUFFIX.zip" -ir'!test\*.json'
81
82    - name: Zip test reports for upload
83      if: runner.os == 'Windows' && !inputs.use-gha
84      shell: powershell
85      env:
86        FILE_SUFFIX: ${{ inputs.file-suffix }}
87      run: |
88        # -ir => recursive include all files in pattern
89        7z a "test-reports-$Env:FILE_SUFFIX.zip" -ir'!test\*.xml' -ir'!test\*.csv'
90
91    - name: Zip usage log for upload
92      if: runner.os == 'Windows' && !inputs.use-gha
93      continue-on-error: true
94      shell: powershell
95      env:
96        FILE_SUFFIX: ${{ inputs.file-suffix }}
97      run: |
98        # -ir => recursive include all files in pattern
99        7z a "logs-$Env:FILE_SUFFIX.zip" 'usage_log.txt' -ir'!test\*.log'
100
101    # S3 upload
102    - name: Store Test Downloaded JSONs on S3
103      uses: seemethere/upload-artifact-s3@v5
104      if: ${{ !inputs.use-gha }}
105      with:
106        s3-bucket: ${{ inputs.s3-bucket }}
107        s3-prefix: |
108          ${{ github.repository }}/${{ github.run_id }}/${{ github.run_attempt }}/artifact
109        retention-days: 14
110        if-no-files-found: warn
111        path: test-jsons-*.zip
112
113    - name: Store Test Reports on S3
114      uses: seemethere/upload-artifact-s3@v5
115      if: ${{ !inputs.use-gha }}
116      with:
117        s3-bucket: ${{ inputs.s3-bucket }}
118        s3-prefix: |
119          ${{ github.repository }}/${{ github.run_id }}/${{ github.run_attempt }}/artifact
120        retention-days: 14
121        if-no-files-found: error
122        path: test-reports-*.zip
123
124    - name: Store Usage Logs on S3
125      uses: seemethere/upload-artifact-s3@v5
126      if: ${{ !inputs.use-gha }}
127      continue-on-error: true
128      with:
129        s3-bucket: ${{ inputs.s3-bucket }}
130        s3-prefix: |
131          ${{ github.repository }}/${{ github.run_id }}/${{ github.run_attempt }}/artifact
132        retention-days: 14
133        if-no-files-found: ignore
134        path: logs-*.zip
135
136    - name: Store Debug Artifacts on S3
137      uses: seemethere/upload-artifact-s3@v5
138      if: ${{ !inputs.use-gha }}
139      continue-on-error: true
140      with:
141        s3-bucket: ${{ inputs.s3-bucket }}
142        s3-prefix: |
143          ${{ github.repository }}/${{ github.run_id }}/${{ github.run_attempt }}/artifact
144        retention-days: 14
145        if-no-files-found: ignore
146        path: debug-*.zip
147
148    # GHA upload
149    - name: Store Test Downloaded JSONs on Github
150      uses: actions/upload-artifact@v3
151      if: inputs.use-gha
152      continue-on-error: true
153      with:
154        # Add the run attempt, see [Artifact run attempt]
155        name: test-jsons-runattempt${{ github.run_attempt }}-${{ inputs.file-suffix }}.zip
156        retention-days: 14
157        if-no-files-found: warn
158        path: test/**/*.json
159
160    - name: Store Test Reports on Github
161      uses: actions/upload-artifact@v3
162      if: inputs.use-gha
163      continue-on-error: true
164      with:
165        # Add the run attempt, see [Artifact run attempt]
166        name: test-reports-runattempt${{ github.run_attempt }}-${{ inputs.file-suffix }}.zip
167        retention-days: 14
168        # Don't want to fail the workflow here because not all workflows have csv files
169        if-no-files-found: ignore
170        path: |
171          test/**/*.xml
172          test/**/*.csv
173
174    - name: Store Usage Logs on Github
175      uses: actions/upload-artifact@v3
176      if: inputs.use-gha
177      continue-on-error: true
178      with:
179        # Add the run attempt, see [Artifact run attempt]
180        name: logs-runattempt${{ github.run_attempt }}-${{ inputs.file-suffix }}.zip
181        retention-days: 14
182        if-no-files-found: ignore
183        path: |
184          usage_log.txt
185          test/**/*.log
186