Measure effect of CI #239
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Measure effect of CI | |
on: | |
workflow_dispatch: | |
push: | |
schedule: | |
# daily | |
- cron: "16 16 * * *" | |
jobs: | |
measure: | |
name: Measure effects | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
setting: [hosted-tool-cache, go, codeql, powershell, android-sdk, haskell-ghc, swift, dotnet, docker-images, swap] | |
os: [ubuntu-20.04, ubuntu-22.04] | |
run: [1, 2, 3, 4, 5] | |
steps: | |
- name: Check out action | |
uses: actions/checkout@v4 | |
with: | |
path: ./.github/actions/measurements | |
- name: Record starting conditions | |
id: before | |
run: | | |
echo "disk_free=$(df --output=avail --sync -BG "${{ github.workspace }}" | tail -1 | sed 's/[^0-9]*//g')" >> $GITHUB_OUTPUT | |
printf 'timestamp=%(%s)T\n' >> "$GITHUB_OUTPUT" | |
- name: Reclaim the bytes | |
uses: ./.github/actions/measurements | |
with: | |
remove-hosted-tool-cache: ${{ matrix.setting == 'hosted-tool-cache' }} | |
remove-go: ${{ matrix.setting == 'go' }} | |
remove-codeql: ${{ matrix.setting == 'codeql' }} | |
remove-powershell: ${{ matrix.setting == 'powershell' }} | |
remove-android-sdk: ${{ matrix.setting == 'android-sdk' }} | |
remove-haskell-ghc: ${{ matrix.setting == 'haskell-ghc' }} | |
remove-swift: ${{ matrix.setting == 'swift' }} | |
remove-dotnet: ${{ matrix.setting == 'dotnet' }} | |
remove-docker-images: ${{ matrix.setting == 'docker-images' }} | |
remove-swap: ${{ matrix.setting == 'swap' }} | |
- name: Record stopping conditions | |
id: after | |
run: | | |
echo "disk_free=$(df --output=avail --sync -BG "${{ github.workspace }}" | tail -1 | sed 's/[^0-9]*//g')" >> $GITHUB_OUTPUT | |
printf 'timestamp=%(%s)T\n' >> "$GITHUB_OUTPUT" | |
- name: Create measurements json | |
id: json | |
run: | | |
OUTPUT_JSON="/tmp/single_${{matrix.os}}_${{matrix.setting}}_${{matrix.run}}.json" | |
echo "output=$OUTPUT_JSON" >> $GITHUB_OUTPUT | |
DURATION=$((${{ steps.after.outputs.timestamp }} - ${{ steps.before.outputs.timestamp }})) | |
FREED_DISK=$((${{ steps.after.outputs.disk_free }} - ${{ steps.before.outputs.disk_free }})) | |
echo "Free before : ${{ steps.before.outputs.disk_free }}G" | |
echo "Free after : ${{ steps.after.outputs.disk_free }}G" | |
echo "Freed : ${FREED_DISK}G" | |
echo "Duration : ${DURATION}s" | |
cat > "$OUTPUT_JSON" << HERE | |
[{ | |
"os": "${{ matrix.os }}", | |
"to_remove": "${{ matrix.setting}}", | |
"run": ${{ matrix.run}}, | |
"free_before_gb": ${{ steps.before.outputs.disk_free }}, | |
"free_after_gb": ${{ steps.after.outputs.disk_free }}, | |
"freed_gb": ${FREED_DISK}, | |
"duration_s": ${DURATION} | |
}] | |
HERE | |
- name: Upload disk space report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: measurement_jsons | |
path: ${{ steps.json.outputs.output }} | |
collect-jsons: | |
name: Collect jsons | |
runs-on: ubuntu-latest | |
needs: measure | |
env: | |
JSON_DIR: /tmp/jsons | |
steps: | |
- name: Download single jsons | |
uses: actions/download-artifact@v3 | |
with: | |
name: measurement_jsons | |
path: ${{ env.JSON_DIR }} | |
- name: Merge json files | |
run: | | |
tree "${{ env.JSON_DIR }}" | |
jq -s add ${{ env.JSON_DIR }}/single_*.json > "${{ env.JSON_DIR }}/measurements.json" | |
tree "${{ env.JSON_DIR }}" | |
- name: Upload merged json | |
uses: actions/upload-artifact@v3 | |
with: | |
name: output | |
path: "${{ env.JSON_DIR }}/measurements.json" |