GitHub actions - idempotency test: Bugfix ./x/helix/.git/ #305
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: Ubuntu GH | |
on: | |
schedule: | |
# weekly, randomly chosen time | |
# Runs at 03:17, only on Wednesday | |
- cron: "17 3 * * 3" | |
push: | |
branches: [ "devel", "testing", "stable", "LTS" ] | |
paths: | |
- '*.sh' | |
- 'CommonInitScripts/**.sh*' | |
- 'UbuntuCLI/**.sh' | |
- 'Ubuntu_22.04/**.sh' | |
- 'Ubuntu_22.04/RootDotfiles/**' | |
- '.github/workflows/UbuntuGH.yml' | |
pull_request: | |
branches: [ "devel", "testing", "stable", "LTS" ] | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04, ubuntu-24.04] | |
gui: [GNOME, CLI] # TODO add this to containers.yml | |
name: ${{ matrix.os }}_${{ matrix.gui }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check disk space on the GitHub runner (before) | |
run: df -ha | |
- name: List tools in $AGENT_TOOLSDIRECTORY | |
run: echo $AGENT_TOOLSDIRECTORY && ls $AGENT_TOOLSDIRECTORY | |
- name: Print default paths | |
run: | | |
echo RUNNER_TEMP = $RUNNER_TEMP | |
echo RUNNER_TOOL_CACHE = $RUNNER_TOOL_CACHE | |
echo GITHUB_WORKSPACE = $GITHUB_WORKSPACE | |
- name: List /mnt | |
run: ls /mnt && echo . && cat /mnt/DATALOSS_WARNING_README.txt | |
# Note: Free Disk Space was added because the idempotency test | |
# i.e. copying home to /tmp was running out of disk space on | |
# Ubuntu 22.04 with GNOME. This only needs to be run for branches | |
# of the matrix that fail because of low disk space (otherwise | |
# this step should be skipped). | |
# Note2: Also running Free Disk Space on Ubuntu 24.04 with GNOME | |
# as it only has 5GB of disk space left. | |
- name: Free Disk Space (Ubuntu) | |
if: matrix.gui == 'GNOME' | |
uses: jlumbroso/free-disk-space@main | |
with: | |
# this might remove tools that are actually needed, | |
# if set to "true" but frees about 6 GB | |
tool-cache: true | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
docker-images: true | |
swap-storage: true | |
- name: Update APT & upgrade | |
run: sudo apt-get update -y && sudo apt-get upgrade -y | |
- name: Install GNOME Desktop (if needed) | |
if: matrix.gui == 'GNOME' | |
run: sudo apt-get install -y ubuntu-desktop-minimal | |
- uses: actions/checkout@v4 | |
- name: print `github.ref=${{ github.ref }}` and `github.sha=${{ github.sha }}` | |
run: "echo Ref: ${{ github.ref }}, SHA: ${{ github.sha }}" | |
- name: Running iniPC script for the 1st time should not fail. | |
run: ./run_init.sh --noninteractive | |
# TODO research on what is the /mnt partition on GitHub runners for | |
# and whether it is a better place to store the old_home directory | |
# (it probably does not count to the root file system limit) | |
# TODO maybe if I stored the old_home directory in /mnt | |
# I would not need to run the Free Disk Space step | |
# See the Check disk space step for more info | |
# TODO confirm that /mnt can be used this way | |
# MNT is so called "temporary disk" | |
# https://learn.microsoft.com/en-us/azure/virtual-machines/managed-disks-overview#disk-roles | |
# https://github.com/marketplace/actions/maximize-build-disk-space | |
# but it is not documented wel... so I hope this is not error prone... | |
# EXPERIMENT RESULT: I get `cp: cannot create directory '/mnt/old_home/': Permission denied` | |
# when I try to use /mnt instead of /tmp | |
- name: save ~/ for idempotency test | |
run: cp -r ~/ /tmp/old_home/ | |
- name: Running iniPC script for the 2nd time should not fail. | |
run: ./run_init.sh --noninteractive | |
# TODO consolidate disk space usage (there some almost free partitions here... | |
# see whether I can use them and how <https://github.com/marketplace/actions/maximize-build-disk-space>) | |
# https://www.synacktiv.com/en/publications/github-actions-exploitation-self-hosted-runners | |
# https://docs.github.com/en/actions/sharing-automations/reusing-workflows?learn=getting_started&learnProduct=actions | |
- name: Check disk space on the GitHub runner (after) | |
run: df -ha | |
# TODO split this command to multiple lines | |
# TODO also test that the first run of initPC script does change the state of home dir | |
# TODO - test whether the test works as expected | |
# TODO - add more paths e.g. /etc/ a.s.o. | |
# TODO - be more specific in work/_temp/ path | |
# TODO also add other config style directories such as /etc | |
- name: The initPC script should be idempotent on ~/ directory (WIP - needs testing & tuning) | |
run: | | |
cd ~ | |
pwd | |
find . -type f \( \ | |
! -path "./.cargo/.global-cache" \ | |
! -path "./.cache/*" \ | |
! -path "./.dotfiles/logs/HEAD" \ | |
! -path "*work/_temp/*" \ | |
! -path "./runners/*" \ | |
! -path "./x/helix/.git/*" \ | |
! -iname "*.log" \ | |
! -name ".wget-hsts" \ | |
\) -print0 | | |
xargs -0 -I{} bash -c 'if ! diff "$1" "/tmp/old_home/$1"; then echo "diff failed for: $1"; exit 1; fi' bash {} |