Test #121
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: Test | |
on: | |
workflow_dispatch: | |
schedule: | |
# weekly, randomly chosen time | |
- cron: "17 18 * * 0" | |
push: | |
branches-ignore: | |
- 'test-report' | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
env: | |
REPORT_DIR: /tmp/build-report | |
jobs: | |
test-action: | |
name: Test action | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-20.04 | |
- ubuntu-22.04 | |
remove-android: | |
- 'true' | |
- 'false' | |
remove-dotnet: | |
- 'true' | |
- 'false' | |
remove-haskell: | |
- 'true' | |
- 'false' | |
remove-codeql: | |
- 'true' | |
- 'false' | |
remove-docker-images: | |
- 'true' | |
- 'false' | |
steps: | |
- name: Record start time | |
run: | | |
echo "START_TIME=$(date +%s)" >> $GITHUB_ENV | |
- name: Determine free space before | |
run: | | |
echo "FREE_GIG_BEFORE=$(df --output=avail --sync -BG "${{ github.workspace }}" | tail -1 | sed 's/[^0-9]*//g')" >> $GITHUB_ENV | |
- name: Check out Maximize Build Space action | |
uses: actions/checkout@v3 | |
with: | |
path: ./.github/actions/maximize-test | |
- name: Maximize build space | |
uses: ./.github/actions/maximize-test | |
with: | |
remove-android: ${{ matrix.remove-android }} | |
remove-dotnet: ${{ matrix.remove-dotnet }} | |
remove-haskell: ${{ matrix.remove-haskell }} | |
remove-codeql: ${{ matrix.remove-codeql }} | |
remove-docker-images: ${{ matrix.remove-docker-images }} | |
- name: Record end time | |
run: | | |
echo "END_TIME=$(date +%s)" >> $GITHUB_ENV | |
- name: Determine free space after | |
run: | | |
echo "FREE_GIG_AFTER=$(df --output=avail --sync -BG "${{ github.workspace }}" | tail -1 | sed 's/[^0-9]*//g')" >> $GITHUB_ENV | |
- name: Calculate freed space and elapsed time | |
run: | | |
REPORT_FILENAME_BASE="${REPORT_DIR}/${{ matrix.os }}_${{ matrix.remove-android }}_${{ matrix.remove-dotnet }}_${{ matrix.remove-haskell }}_${{ matrix.remove-codeql }}_${{ matrix.remove-docker-images }}" | |
FREED_GIG=$(expr ${FREE_GIG_AFTER} - ${FREE_GIG_BEFORE}) | |
ELAPSED_TIME=$(expr ${END_TIME} - ${START_TIME}) | |
echo "Free space before: ${FREE_GIG_BEFORE}G" | |
echo "Free space after : ${FREE_GIG_AFTER}G" | |
echo "Space freed : ${FREED_GIG}G" | |
echo "Time elapsed : ${ELAPSED_TIME} seconds" | |
mkdir -p "${REPORT_DIR}" | |
REMOVE_ANDROID="${{ matrix.remove-android }}" | |
REMOVE_DOTNET="${{ matrix.remove-dotnet }}" | |
REMOVE_HASKELL="${{ matrix.remove-haskell }}" | |
REMOVE_CODEQL="${{ matrix.remove-codeql }}" | |
REMOVE_DOCKER_IMAGES="${{ matrix.remove-docker-images }}" | |
cat <<EOF > "${REPORT_FILENAME_BASE}.json" | |
{ | |
"os": "${{ matrix.os }}", | |
"remove_android": "${REMOVE_ANDROID//false/}", | |
"remove_dotnet": "${REMOVE_DOTNET//false/}", | |
"remove_haskell": "${REMOVE_HASKELL//false/}", | |
"remove_codeql": "${REMOVE_CODEQL//false/}", | |
"remove_docker_images": "${REMOVE_DOCKER_IMAGES//false/}", | |
"space_free_before": "${FREE_GIG_BEFORE}", | |
"space_free_after": "${FREE_GIG_AFTER}", | |
"space_freed": "${FREED_GIG}", | |
"elapsed_time": "${ELAPSED_TIME}" | |
} | |
EOF | |
jq -r '[.os, .remove_android, .remove_dotnet, .remove_haskell, .remove_codeql, .remove_docker_images, .space_freed, .space_free_after, .elapsed_time] | join(" | ")' < "${REPORT_FILENAME_BASE}.json" >> "${REPORT_FILENAME_BASE}.txt" | |
- name: Upload disk space report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: disk-space-report-single | |
path: ${{ env.REPORT_DIR }} | |
collect-reports: | |
name: Collect reports | |
runs-on: ubuntu-latest | |
needs: test-action | |
env: | |
REPORT_FILE: space-free-report.md | |
steps: | |
- name: Download single reports | |
uses: actions/download-artifact@v3 | |
with: | |
name: disk-space-report-single | |
path: ${{ env.REPORT_DIR }} | |
- name: Join Markdown report | |
run: | | |
echo 'OS | Android SDKs removed | .NET SDKs removed | Haskell removed | CodeQL Removed | Cached Docker Images Removed | GB freed | GB free | Elapsed Time (seconds) |' > "${REPORT_DIR}/${REPORT_FILE}" | |
echo '---|:--------------------:|:-----------------:|:---------------:|:--------------:|:----------------------------:|:--------:|:-------:|:----------------------:|' >> "${REPORT_DIR}/${REPORT_FILE}" | |
cat ${REPORT_DIR}/*.txt >> "${REPORT_DIR}/${REPORT_FILE}" | |
- name: Upload collected report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: disk-space-report-markdown | |
path: ${{ env.REPORT_DIR }}/${{ env.REPORT_FILE }} | |
- name: Checkout report branch | |
uses: actions/checkout@v3 | |
with: | |
ref: test-report | |
- name: Overwrite old report | |
run: | | |
cp README.md.template README.md | |
cat ${{ env.REPORT_DIR }}/${{ env.REPORT_FILE }} >> README.md | |
cat "${REPORT_DIR}/${REPORT_FILE}" | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add README.md | |
git commit -m "Generated new report" && git push || echo "Report unchanged, not updating." |